Skip to content

Correct percent printing #2859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ python:

script:
- PYTHONPATH=. python tools/test/config_test/config_test.py
- PYTHONPATH=. python tools/test/build_api/build_api_test.py
- python tools/test/pylint.py
- py.test tools/test/toolchains/api.py
- python tools/test/memap/memap_test.py
Expand All @@ -21,3 +22,4 @@ install:
- sudo pip install pytest
- sudo pip install pylint
- sudo pip install hypothesis
- sudo pip install mock
2 changes: 1 addition & 1 deletion tools/build_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def prepare_toolchain(src_paths, target, toolchain_name,
src_paths = [src_paths[0]] + list(set(src_paths[1:]))

# If the configuration object was not yet created, create it now
config = config or Config(target, src_paths)
config = config or Config(target, src_paths, app_config=app_config)
target = config.target

# Toolchain instance
Expand Down
51 changes: 41 additions & 10 deletions tools/test/build_api/build_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
"""

import unittest
from mock import patch
from tools.build_api import prepare_toolchain, build_project, build_library
from collections import namedtuple
from mock import patch, MagicMock
from tools.build_api import prepare_toolchain, build_project, build_library,\
scan_resources

"""
Tests for build_api.py
Expand Down Expand Up @@ -47,7 +49,30 @@ def tearDown(self):
"""
pass

@patch('tools.config.Config.__init__')
@patch('tools.toolchains.arm.ARM_STD.parse_dependencies',
return_value=["foo"])
@patch('tools.toolchains.mbedToolchain.need_update',
side_effect=[i % 2 for i in range(3000)])
@patch('os.mkdir')
@patch('tools.toolchains.exists', return_value=True)
@patch('tools.utils.run_cmd', return_value=("", "", 0))
def test_always_complete_build(self, *_):
with MagicMock() as notify:
toolchain = prepare_toolchain(self.src_paths, self.target,
self.toolchain_name, notify=notify)

res = scan_resources(self.src_paths, toolchain)

toolchain.RESPONSE_FILES=False
toolchain.config_processed = True
toolchain.config_file = "junk"
toolchain.compile_sources(res, self.build_path)

assert any('percent' in msg[0] and msg[0]['percent'] == 100.0
for _, msg, _ in notify.mock_calls if msg)


@patch('tools.build_api.Config')
def test_prepare_toolchain_app_config(self, mock_config_init):
"""
Test that prepare_toolchain uses app_config correctly
Expand All @@ -56,28 +81,34 @@ def test_prepare_toolchain_app_config(self, mock_config_init):
:return:
"""
app_config = "app_config"
mock_config_init.return_value = None
mock_config_init.return_value = namedtuple("Config", "target")(
namedtuple("Target",
"init_hooks name features core")(lambda _, __ : None,
"Junk", [], "Cortex-M3"))

prepare_toolchain(self.src_paths, self.target, self.toolchain_name,
app_config=app_config)

mock_config_init.assert_called_with(self.target, self.src_paths,
app_config=app_config)
mock_config_init.assert_called_once_with(self.target, self.src_paths,
app_config=app_config)

@patch('tools.config.Config.__init__')
@patch('tools.build_api.Config')
def test_prepare_toolchain_no_app_config(self, mock_config_init):
"""
Test that prepare_toolchain correctly deals with no app_config

:param mock_config_init: mock of Config __init__
:return:
"""
mock_config_init.return_value = None
mock_config_init.return_value = namedtuple("Config", "target")(
namedtuple("Target",
"init_hooks name features core")(lambda _, __ : None,
"Junk", [], "Cortex-M3"))

prepare_toolchain(self.src_paths, self.target, self.toolchain_name)

mock_config_init.assert_called_with(self.target, self.src_paths,
app_config=None)
mock_config_init.assert_called_once_with(self.target, self.src_paths,
app_config=None)

@patch('tools.build_api.scan_resources')
@patch('tools.build_api.mkdir')
Expand Down
1 change: 1 addition & 0 deletions tools/toolchains/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,7 @@ def compile_sources(self, resources, build_path, inc_dirs=None):
'chroot': self.CHROOT
})
else:
self.compiled += 1
objects.append(object)

# Use queues/multiprocessing if cpu count is higher than setting
Expand Down