def test_given_a_configuration_file(self): command_line = ["execute", "-c", "config.yml"] command = Command.extract_from(command_line) self.assertIsInstance(command, Execute) self.assertEqual("config.yml", command.configuration_file)
def test_given_all_configurations(self): command_line = "realize --output output" command = Command.extract_from(command_line.split()) self.assertIsInstance(command, Realize) self.assertEqual(command.output_directory, "output")
def test_given_atomic_mode(self): command_line = "generate --mode atomic" command = Command.extract_from(command_line.split()) self.assertIsInstance(command, Generate) self.assertEquals(command.mode, Generate.ATOMIC)
def test_given_working_directory(self): command_line = "realize -d my/test/directory" command = Command.extract_from(command_line.split()) self.assertIsInstance(command, Realize) self.assertEqual(command.working_directory, "my/test/directory")
def test_with_the_simulation_option(self): command_line = ["execute", "-s"] command = Command.extract_from(command_line) self.assertIsInstance(command, Execute) self.assertEqual(True, command.is_simulated)
def test_given_all_configurations_mode(self): command_line = "generate --mode all" command = Command.extract_from(command_line.split()) self.assertIsInstance(command, Generate) self.assertEquals(command.mode, Generate.ALL)
def test_given_an_output_directory(self): command_line = "realize -o output" command = Command.extract_from(command_line.split()) self.assertIsInstance(command, Realize) self.assertEqual(command.output_directory, "output")
def realize(self): camp = Camp(YAML(), Z3Problem, Builder()) command = Command.extract_from([ "realize", "-d", self._input_directory, "-o", self._output_directory ]) command.send_to(camp)
def test_given_no_working_directory(self): command_line = "generate -d my/directory" command = Command.extract_from(command_line.split()) self.assertIsInstance(command, Generate) self.assertEqual(command.mode, Generate.DEFAULT_MODE)
def test_given_working_directory(self): command_line = "generate --directory my/test/directory" command = Command.extract_from(command_line.split()) self.assertIsInstance(command, Generate) self.assertEqual(command.working_directory, "my/test/directory")
def test_given_covering_mode(self): command_line = "generate --mode covering" command = Command.extract_from(command_line.split()) self.assertIsInstance(command, Generate) self.assertTrue(command.mode, Generate.COVERING)
def test_with_the_include_option(self): command_line = ["execute", "-i", "1", "2", "3", "4"] command = Command.extract_from(command_line) self.assertIsInstance(command, Execute) self.assertEqual([1, 2, 3, 4], command.included_configurations)
def test_given_all_configurations(self): command_line = "generate --all" command = Command.extract_from(command_line.split()) self.assertIsInstance(command, Generate) self.assertFalse(command.only_coverage)
def test_given_only_coverage(self): command_line = "generate --coverage" command = Command.extract_from(command_line.split()) self.assertIsInstance(command, Generate) self.assertTrue(command.only_coverage)
def test_given_no_working_directory(self): command_line = "realize -o output" command = Command.extract_from(command_line.split()) self.assertIsInstance(command, Realize) self.assertEqual(command.working_directory, Realize.DEFAULT_WORKING_DIRECTORY)
def test_with_the_include_option(self): command_line = ["execute"] command = Command.extract_from(command_line) self.assertIsInstance(command, Execute) self.assertEqual(Execute.DEFAULT_INCLUDED, command.included_configurations)
def test_given_no_output_directory(self): command_line = "realize -d workspace" command = Command.extract_from(command_line.split()) self.assertIsInstance(command, Realize) self.assertEqual(command.output_directory, Realize.DEFAULT_OUTPUT_DIRECTORY)
def test_when_no_argument_is_given(self): command_line = ["execute"] command = Command.extract_from(command_line) self.assertIsInstance(command, Execute) self.assertEqual(Execute.DEFAULT_CONFIGURATION_FILE, command.configuration_file)
def test_given_no_parameters(self): command_line = "generate --mode all" command = Command.extract_from(command_line.split()) self.assertIsInstance(command, Generate) self.assertEqual(command.working_directory, Generate.DEFAULT_WORKING_DIRECTORY)
def test_given_working_directory(self): command = Command.extract_from(self._command_line) self.assertIsInstance(command, Execute) self.assertEqual(command.working_directory, Execute.DEFAULT_WORKING_DIRECTORY)
def test_with_the_simulation_option(self): command = Command.extract_from(self._command_line) self.assertIsInstance(command, Execute) self.assertEqual(Execute.DEFAULT_IS_SIMULATED, command.is_simulated)
def test_when_no_argument_is_given(self): command = Command.extract_from(self._command_line) self.assertIsInstance(command, Execute) self.assertEqual(Execute.DEFAULT_IS_SIMULATED, command.is_simulated)
def realize(self): camp = Camp(YAML(), Z3Problem, Builder()) command = Command.extract_from([ "realize", "-d", self.INPUT_DIRECTORY, "-o", self.OUTPUT_DIRECTORY ]) command.send_to(camp)
def invoke_camp_generate(self, mode=Generate.ALL): camp = Camp(YAML(), Z3Problem, Builder()) command = Command.extract_from( ["generate", "--mode", mode, "-d", self._working_directory]) command.send_to(camp)
def test_given_working_directory(self): command_line = "--version" command = Command.extract_from(command_line.split()) self.assertIsInstance(command, ShowVersions)
def test_given_the_shortcut(self): command_line = "-v" command = Command.extract_from(command_line.split()) self.assertIsInstance(command, ShowVersions)
def main(): camp = Camp(YAML(), Z3Problem, Builder()) command = Command.extract_from(argv[1:]) command.send_to(camp)
def camp(*arguments): camp = Camp(YAML(), Z3Problem, Builder()) command = Command.extract_from(arguments) command.send_to(camp)
def _parse(text): return Command.extract_from(text.split())