def test_specifier_converter_access(self): specifier_sorter = TestConfigurationConverter( self._all_test_configurations, MOCK_MACROS).specifier_sorter() self.assertEqual( specifier_sorter.category_for_specifier('snowleopard'), 'version') self.assertEqual(specifier_sorter.category_for_specifier('mac'), 'version')
def __init__(self, port, full_test_list, allow_rebaseline_modifier): self._port = port self._test_configuration_converter = TestConfigurationConverter( set(port.all_test_configurations()), port.configuration_specifier_macros()) self._full_test_list = full_test_list self._allow_rebaseline_modifier = allow_rebaseline_modifier
def test_macro_expansion(self): converter = TestConfigurationConverter(self._all_test_configurations, MOCK_MACROS) configs_to_match = set([ TestConfiguration('vista', 'x86', 'release'), TestConfiguration('win7', 'x86', 'release'), ]) self.assertEqual(converter.to_config_set(set(['win', 'release'])), configs_to_match) configs_to_match = set([ TestConfiguration('vista', 'x86', 'release'), TestConfiguration('win7', 'x86', 'release'), TestConfiguration('trusty', 'x86_64', 'release'), ]) self.assertEqual( converter.to_config_set(set(['win', 'trusty', 'release'])), configs_to_match) configs_to_match = set([ TestConfiguration('vista', 'x86', 'release'), TestConfiguration('win7', 'x86', 'release'), TestConfiguration('snowleopard', 'x86', 'release'), ]) self.assertEqual( converter.to_config_set(set(['win', 'mac', 'release'])), configs_to_match)
def __init__(self, argv, host, git_cl): self._args = parse_args(argv) self._host = host self._git_cl = git_cl self._expectations_model = TestExpectationsModel() self._test_configuration_converter = TestConfigurationConverter( set(BUILDERS.values()))
def __init__(self, port, full_test_list, allow_rebaseline_modifier, shorten_filename=lambda x: x): self._port = port self._test_configuration_converter = TestConfigurationConverter(set(port.all_test_configurations()), port.configuration_specifier_macros()) if full_test_list is None: self._full_test_list = None else: self._full_test_list = set(full_test_list) self._allow_rebaseline_modifier = allow_rebaseline_modifier self._shorten_filename = shorten_filename
def __init__(self, argv, host, git_cl): self._args = parse_args(argv) self._host = host self._git_cl = git_cl self._expectations_model = TestExpectationsModel() self._test_configuration_converter = TestConfigurationConverter( set(BUILDER_CONFIGS.values())) self._filesystem = self._host.filesystem self._path_finder = PathFinder(self._filesystem) self._git = self._host.git()
def __init__(self, tool, port): self._converter = TestConfigurationConverter( port.all_test_configurations(), port.configuration_specifier_macros()) self._extrapolator = BuildCoverageExtrapolator(self._converter) self._parser = TestExpectationParser(port, [], allow_rebaseline_modifier=False) self._path_to_test_expectations_file = port.path_to_test_expectations_file( ) self._tool = tool
def execute(self, options, args, tool): port = tool.port_factory.get( "chromium-win-win7") # FIXME: This should be selectable. expectation_lines = TestExpectationParser.tokenize_list( port.test_expectations()) parser = TestExpectationParser(port, [], allow_rebaseline_modifier=False) for expectation_line in expectation_lines: parser.parse(expectation_line) converter = TestConfigurationConverter( port.all_test_configurations(), port.configuration_specifier_macros()) tool.filesystem.write_text_file( port.path_to_test_expectations_file(), TestExpectationSerializer.list_to_string(expectation_lines, converter))
def __init__(self, port, tests, expectations, test_config, is_lint_mode=False, overrides=None): """Loads and parses the test expectations given in the string. Args: port: handle to object containing platform-specific functionality tests: list of all of the test files expectations: test expectations as a string test_config: specific values to check against when parsing the file (usually port.test_config(), but may be different when linting or doing other things). is_lint_mode: If True, just parse the expectations string looking for errors. overrides: test expectations that are allowed to override any entries in |expectations|. This is used by callers that need to manage two sets of expectations (e.g., upstream and downstream expectations). """ self._full_test_list = tests self._test_config = test_config self._is_lint_mode = is_lint_mode self._model = TestExpectationsModel() self._parser = TestExpectationParser(port, tests, is_lint_mode) self._port = port self._test_configuration_converter = TestConfigurationConverter( port.all_test_configurations(), port.configuration_specifier_macros()) self._skipped_tests_warnings = [] self._expectations = self._parser.parse(expectations) self._add_expectations(self._expectations, overrides_allowed=False) self._add_skipped_tests(port.skipped_tests(tests)) if overrides: overrides_expectations = self._parser.parse(overrides) self._add_expectations(overrides_expectations, overrides_allowed=True) self._expectations += overrides_expectations self._has_warnings = False self._report_errors() self._process_tests_without_expectations()
def test_converter_macro_collapsing(self): converter = TestConfigurationConverter(self._all_test_configurations, MOCK_MACROS) configs_to_match = set([ TestConfiguration('vista', 'x86', 'release'), TestConfiguration('win7', 'x86', 'release'), ]) self.assertEqual(converter.to_specifiers_list(configs_to_match), [set(['win', 'release'])]) configs_to_match = set([ TestConfiguration('vista', 'x86', 'release'), TestConfiguration('win7', 'x86', 'release'), TestConfiguration('linux32', 'x86', 'release'), TestConfiguration('precise', 'x86_64', 'release'), TestConfiguration('trusty', 'x86_64', 'release'), ]) self.assertEqual(converter.to_specifiers_list(configs_to_match), [set(['win', 'linux', 'release'])]) configs_to_match = set([ TestConfiguration('vista', 'x86', 'release'), TestConfiguration('win7', 'x86', 'release'), TestConfiguration('snowleopard', 'x86', 'release'), ]) self.assertEqual(converter.to_specifiers_list(configs_to_match), [set(['win', 'mac', 'release'])]) configs_to_match = set([ TestConfiguration('vista', 'x86', 'release'), TestConfiguration('win7', 'x86', 'release'), TestConfiguration('snowleopard', 'x86', 'release'), ]) self.assertEqual(converter.to_specifiers_list(configs_to_match), [set(['win', 'mac', 'release'])]) configs_to_match = set([ TestConfiguration('vista', 'x86', 'release'), TestConfiguration('win7', 'x86', 'release'), ]) self.assertEqual(converter.to_specifiers_list(configs_to_match), [set(['win', 'release'])])
def __init__(self, port, full_test_list, is_lint_mode): self._port = port self._test_configuration_converter = TestConfigurationConverter(set(port.all_test_configurations()), port.configuration_specifier_macros()) self._full_test_list = full_test_list self._is_lint_mode = is_lint_mode
def test_to_specifier_lists(self): converter = TestConfigurationConverter(self._all_test_configurations, MOCK_MACROS) self.assertEqual( converter.to_specifiers_list(set(self._all_test_configurations)), [[]]) self.assertEqual(converter.to_specifiers_list(set()), []) configs_to_match = set([ TestConfiguration('win7', 'x86', 'release'), ]) self.assertEqual(converter.to_specifiers_list(configs_to_match), [set(['release', 'win7'])]) configs_to_match = set([ TestConfiguration('win7', 'x86', 'release'), TestConfiguration('win7', 'x86', 'debug'), ]) self.assertEqual(converter.to_specifiers_list(configs_to_match), [set(['win7'])]) configs_to_match = set([ TestConfiguration('precise', 'x86_64', 'debug'), TestConfiguration('trusty', 'x86_64', 'debug'), TestConfiguration('win7', 'x86', 'release'), ]) self.assertEqual(converter.to_specifiers_list(configs_to_match), [set(['release', 'win7']), set(['debug', 'linux'])]) configs_to_match = set([ TestConfiguration('win7', 'x86', 'release'), TestConfiguration('win7', 'x86', 'release'), TestConfiguration('trusty', 'x86_64', 'debug'), TestConfiguration('precise', 'x86_64', 'debug'), TestConfiguration('trusty', 'x86_64', 'debug'), TestConfiguration('precise', 'x86_64', 'debug'), ]) self.assertEqual(converter.to_specifiers_list(configs_to_match), [set(['release', 'win7']), set(['debug', 'linux'])]) configs_to_match = set([ TestConfiguration('win7', 'x86', 'release'), TestConfiguration('snowleopard', 'x86', 'release'), TestConfiguration('vista', 'x86', 'release'), TestConfiguration('precise', 'x86_64', 'release'), TestConfiguration('trusty', 'x86_64', 'release'), ]) self.assertEqual(converter.to_specifiers_list(configs_to_match), [set(['release'])]) configs_to_match = set([ TestConfiguration('win7', 'x86', 'release'), TestConfiguration('snowleopard', 'x86', 'release'), ]) self.assertEqual(converter.to_specifiers_list(configs_to_match), [set(['win7', 'mac', 'release'])]) configs_to_match = set([ TestConfiguration('snowleopard', 'x86', 'release'), TestConfiguration('win7', 'x86', 'release'), TestConfiguration('win7', 'x86', 'debug'), TestConfiguration('trusty', 'x86_64', 'release'), ]) self.assertEqual( converter.to_specifiers_list(configs_to_match), [set(['win7']), set(['release', 'mac', 'trusty'])])
def test_to_config_set(self): converter = TestConfigurationConverter(self._all_test_configurations) self.assertEqual(converter.to_config_set(set()), self._all_test_configurations) self.assertEqual(converter.to_config_set(set(['foo'])), set()) self.assertEqual(converter.to_config_set(set(['win7', 'foo'])), set()) errors = [] self.assertEqual(converter.to_config_set(set(['win7', 'foo']), errors), set()) self.assertEqual(errors, ["Unrecognized specifier 'foo'"]) self.assertEqual(converter.to_config_set(set(['win7', 'x86_64'])), set()) configs_to_match = set([ TestConfiguration('win7', 'x86', 'release'), ]) self.assertEqual(converter.to_config_set(set(['win7', 'release'])), configs_to_match) configs_to_match = set([ TestConfiguration('snowleopard', 'x86', 'release'), TestConfiguration('vista', 'x86', 'release'), TestConfiguration('win7', 'x86', 'release'), TestConfiguration('precise', 'x86_64', 'release'), TestConfiguration('trusty', 'x86_64', 'release'), ]) self.assertEqual(converter.to_config_set(set(['release'])), configs_to_match) configs_to_match = set([ TestConfiguration('precise', 'x86_64', 'release'), TestConfiguration('precise', 'x86_64', 'debug'), TestConfiguration('trusty', 'x86_64', 'release'), TestConfiguration('trusty', 'x86_64', 'debug'), ]) self.assertEqual(converter.to_config_set(set(['x86_64'])), configs_to_match) configs_to_match = set([ TestConfiguration('trusty', 'x86_64', 'release'), TestConfiguration('trusty', 'x86_64', 'debug'), TestConfiguration('precise', 'x86_64', 'release'), TestConfiguration('precise', 'x86_64', 'debug'), TestConfiguration('snowleopard', 'x86', 'release'), TestConfiguration('snowleopard', 'x86', 'debug'), ]) self.assertEqual( converter.to_config_set(set(['trusty', 'precise', 'snowleopard'])), configs_to_match) configs_to_match = set([ TestConfiguration('snowleopard', 'x86', 'release'), TestConfiguration('snowleopard', 'x86', 'debug'), ]) self.assertEqual(converter.to_config_set(set(['snowleopard', 'x86'])), configs_to_match) configs_to_match = set([ TestConfiguration('trusty', 'x86_64', 'release'), TestConfiguration('snowleopard', 'x86', 'release'), ]) self.assertEqual( converter.to_config_set(set(['trusty', 'snowleopard', 'release'])), configs_to_match)