Skip to content

Commit 90c7cb3

Browse files
LDong-ArmPatater
authored andcommitted
build: Add test for --profile of compile subcommand
The `compile` subcommand supports `--profile` to specify build profile, but a test for it is missing. This commit adds a test.
1 parent a97be74 commit 90c7cb3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/cli/test_build.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,29 @@ def test_app_config_used_when_passed(
186186
generate_config.assert_called_once_with(target.upper(), toolchain.upper(), program)
187187
self.assertEqual(program.files.app_config_file, app_config_path)
188188

189+
def test_profile_used_when_passed(
190+
self, generate_config, mbed_program, build_project, generate_build_system
191+
):
192+
program = mbed_program.from_existing()
193+
mbed_program.reset_mock() # clear call count from previous line
194+
195+
with mock_project_directory(program, mbed_config_exists=True, build_tree_exists=True):
196+
generate_config.return_value = [mock.MagicMock(), mock.MagicMock()]
197+
198+
toolchain = "gcc_arm"
199+
target = "k64f"
200+
profile = "release"
201+
202+
runner = CliRunner()
203+
runner.invoke(build, ["-t", toolchain, "-m", target, "--profile", profile])
204+
205+
mbed_program.from_existing.assert_called_once_with(
206+
pathlib.Path(os.getcwd()),
207+
pathlib.Path(target.upper(), profile, toolchain.upper())
208+
)
209+
generate_config.assert_called_once_with(target.upper(), toolchain.upper(), program)
210+
generate_build_system.assert_called_once_with(program.root, program.files.cmake_build_dir, profile)
211+
189212
def test_build_folder_removed_when_clean_flag_passed(
190213
self, generate_config, mbed_program, build_project, generate_build_system
191214
):

0 commit comments

Comments
 (0)