def _compile(commands: List[str], project_dir: str, dep_dir: str, compile_base_path: str, logger: Logger) -> None: for command in commands: dependencies = BuildCommand.create(command).execute( project_dir, logger) Compile.__copy_dependencies(dependencies, dep_dir, compile_base_path)
def test_execute_runs_command_with_args(self, shell_mock): command = "-command- -arg- --arg--" uut = BuildCommand.create(command) uut.execute("-project_dir-", self.logger) shell_mock.assert_called_with(command, cwd="-project_dir-", logger=ANY)
def test_quotes_args_for_execution(self, shell_mock): uut = BuildCommand.create("-command- 'arg 1'") uut.execute("-pdir-", self.logger) shell_mock.assert_called_with("-command- 'arg 1'", cwd="-pdir-", logger=ANY)
def test_execute_runs_command(self, shell_mock): uut = BuildCommand.create("-command-") uut.execute("-project_dir-", self.logger) shell_mock.assert_called_with("-command-", cwd="-project_dir-", logger=ANY)
def test_default_does_not_filter_output_on_error(self, shell_mock): shell_mock.side_effect = CommandFailedError("-command-", "-output-") uut = BuildCommand.create("-some_command-") try: uut.execute("-project_dir-", self.logger) except CommandFailedError as e: assert_equals("\n-output-", e.output)
def test_raises_on_error(self, shell_mock): shell_mock.side_effect = CommandFailedError("-command-", "-output-") uut = BuildCommand.create("-some_command-") assert_raises(CommandFailedError, uut.execute, "-p-", self.logger)
def test_quoted_args_are_saved_without_quotes(self): uut = BuildCommand.create("-some_command- 'arg 1' \"arg 2\"") assert_equals(["arg 1", "arg 2"], uut.args)
def test_saves_args(self): uut = BuildCommand.create("-some_command- arg1 arg2") assert_equals(["arg1", "arg2"], uut.args)
def test_has_no_dependencies_by_default(self): uut = BuildCommand.create("-some_command-") assert not uut._get_dependencies("-output-", "-project_dir-", self.logger)
def test_generic_command_returns_base_implementation(self): uut = BuildCommand.create("-some_command-") assert_is_instance(uut, BuildCommand) assert_equals("-some_command-", uut._name)
def test_get_correct_command(self): actual = BuildCommand.create(BuildCommandTestImpl.TEST_COMMAND) assert_is_instance(actual, BuildCommandTestImpl)