|
20 | 20 | from mock import patch, MagicMock
|
21 | 21 | from tools.build_api import prepare_toolchain, build_project, build_library
|
22 | 22 | from tools.regions import merge_region_list
|
23 |
| -from tools.resources import Resources |
24 |
| -from tools.toolchains import TOOLCHAINS |
| 23 | +from tools.resources import Resources, FileRef |
| 24 | +from tools.toolchains import TOOLCHAINS, mbedToolchain |
25 | 25 | from tools.notifier.mock import MockNotifier
|
26 | 26 | from tools.config import Region, Config, ConfigException
|
27 | 27 | from tools.utils import ToolException
|
@@ -84,6 +84,53 @@ def test_always_complete_build(self, *_):
|
84 | 84 | assert any('percent' in msg and msg['percent'] == 100.0
|
85 | 85 | for msg in notify.messages if msg)
|
86 | 86 |
|
| 87 | + @patch('tools.toolchains.arm.ARM_STD.parse_dependencies', |
| 88 | + return_value=["foo"]) |
| 89 | + @patch('tools.toolchains.mbedToolchain.need_update', |
| 90 | + side_effect=[i % 2 for i in range(3000)]) |
| 91 | + @patch('os.mkdir') |
| 92 | + @patch('tools.toolchains.mbedToolchain.dump_build_profile') |
| 93 | + @patch('tools.utils.run_cmd', return_value=(b'', b'', 0)) |
| 94 | + def test_compile_legacy_sources_always_complete_build(self, *_): |
| 95 | + """Test that compile_legacy_sources() completes.""" |
| 96 | + notify = MockNotifier() |
| 97 | + toolchain = prepare_toolchain(self.src_paths, self.build_path, self.target, |
| 98 | + self.toolchain_name, notify=notify) |
| 99 | + |
| 100 | + res = Resources(MockNotifier()).scan_with_toolchain( |
| 101 | + self.src_paths, toolchain) |
| 102 | + |
| 103 | + toolchain.RESPONSE_FILES=False |
| 104 | + toolchain.config_processed = True |
| 105 | + toolchain.config_file = "junk" |
| 106 | + toolchain.compile_legacy_sources(res) |
| 107 | + |
| 108 | + assert any('percent' in msg and msg['percent'] == 100.0 |
| 109 | + for msg in notify.messages if msg) |
| 110 | + |
| 111 | + def test_dirs_exclusion_from_file_to_compile(self): |
| 112 | + """Test that dirs can be excluded from the build.""" |
| 113 | + files_to_compile = [ |
| 114 | + FileRef( |
| 115 | + name="platform/TARGET_CORTEX_M/TOOLCHAIN_ARM/except.S", |
| 116 | + path="./platform/TARGET_CORTEX_M/TOOLCHAIN_ARM/except.S", |
| 117 | + ), |
| 118 | + FileRef( |
| 119 | + name="rtos/TARGET_CORTEX/rtx5/RTX/Source/TOOLCHAIN_ARM/TARGET_RTOS_M4_M7/targets_irq_cm4f.S", |
| 120 | + path="./rtos/TARGET_CORTEX/rtx5/RTX/Source/TOOLCHAIN_ARM/TARGET_RTOS_M4_M7/targets_irq_cm4f.S", |
| 121 | + ), |
| 122 | + ] |
| 123 | + exclude_dirs = ["platform/", "drivers/", "targets/"] |
| 124 | + expected_compilation_queue = [ |
| 125 | + FileRef( |
| 126 | + name="rtos/TARGET_CORTEX/rtx5/RTX/Source/TOOLCHAIN_ARM/TARGET_RTOS_M4_M7/targets_irq_cm4f.S", |
| 127 | + path="./rtos/TARGET_CORTEX/rtx5/RTX/Source/TOOLCHAIN_ARM/TARGET_RTOS_M4_M7/targets_irq_cm4f.S", |
| 128 | + ) |
| 129 | + ] |
| 130 | + compilation_queue = mbedToolchain._exclude_files_from_build( |
| 131 | + files_to_compile, exclude_dirs |
| 132 | + ) |
| 133 | + self.assertEqual(compilation_queue, expected_compilation_queue) |
87 | 134 |
|
88 | 135 | @patch('tools.build_api.Config')
|
89 | 136 | def test_prepare_toolchain_app_config(self, mock_config_init):
|
|
0 commit comments