def test_url(self): chromium_commit = ChromiumCommit( MockHost(), sha='c881563d734a86f7d9cd57ac509653a61c45c240') self.assertEqual( chromium_commit.url(), 'https://chromium.googlesource.com/chromium/src/+/c881563d73')
def test_get_issue_number(self): host = MockHost() host.executive = MockExecutive( output='Foo\nIssue number: 12345 (http://crrev.com/12345)') git_cl = GitCL(host) self.assertEqual(git_cl.get_issue_number(), '12345')
def test_get_issue_number_nothing_in_output(self): host = MockHost() host.executive = MockExecutive(output='Bogus output') git_cl = GitCL(host) self.assertEqual(git_cl.get_issue_number(), 'None')
def setUp(self): host = MockHost() self.port = host.port_factory.get(port_name='test')
def test_skip_tests_idlharness(self): """Tests that idlharness tests are skipped on MSAN/ASAN runs. See https://crbug.com/856601 """ host = MockHost() port = host.port_factory.get('test-win-win7', None) non_idlharness_test = 'external/wpt/dir1/dir2/foo.html' idlharness_test_1 = 'external/wpt/dir1/dir2/idlharness.any.html' idlharness_test_2 = 'external/wpt/dir1/dir2/idlharness.any.worker.html' all_tests = [ non_idlharness_test, idlharness_test_1, idlharness_test_2, ] # Patch port.tests() to return our tests port.tests = lambda paths: paths or all_tests options = optparse.Values({ 'no_expectations': False, 'enable_sanitizer': False, 'skipped': 'default', 'skip_timeouts': False, 'skip_failing_tests': False, }) finder = web_test_finder.WebTestFinder(port, options) # Default case; not MSAN/ASAN so should not skip anything. expectations = test_expectations.TestExpectations(port) tests = finder.skip_tests([], all_tests, expectations) self.assertEqual(tests, set()) for test in all_tests: self.assertTrue( expectations.get_expectations(test).is_default_pass) # MSAN/ASAN, with no paths specified explicitly, so should skip both # idlharness tests. expectations = test_expectations.TestExpectations(port) finder._options.enable_sanitizer = True tests = finder.skip_tests([], all_tests, expectations) self.assertEqual(tests, set([idlharness_test_1, idlharness_test_2])) self.assertTrue( expectations.get_expectations(non_idlharness_test).is_default_pass) self.assertEquals( expectations.get_expectations(idlharness_test_1).results, {'SKIP'}) self.assertEquals( expectations.get_expectations(idlharness_test_2).results, {'SKIP'}) # Disable expectations entirely; we should still skip the idlharness # tests but shouldn't touch the expectations parameter. finder._options.no_expectations = True tests = finder.skip_tests([], all_tests, None) self.assertEqual(tests, set([idlharness_test_1, idlharness_test_2])) # MSAN/ASAN, with one of the tests specified explicitly (and # --skipped=default), so should skip only the unspecified test. expectations = test_expectations.TestExpectations(port) tests = finder.skip_tests([idlharness_test_1], all_tests, expectations) self.assertEqual(tests, set([idlharness_test_2])) # Although we will run the test because it was specified explicitly, it # is still *expected* to Skip. This is consistent with how entries in # TestExpectations work. self.assertTrue( expectations.get_expectations(non_idlharness_test).is_default_pass) self.assertEquals( expectations.get_expectations(idlharness_test_1).results, {'SKIP'}) self.assertEquals( expectations.get_expectations(idlharness_test_2).results, {'SKIP'})
def test_import_dir_with_no_tests(self): host = MockHost() host.executive = MockExecutive(exception=ScriptError('error')) host.filesystem = MockFileSystem(files=FAKE_FILES) copier = TestCopier(host, FAKE_SOURCE_REPO_DIR) copier.do_import() # No exception raised.
def test_invalid_action(self): host = MockHost() cmd = ['invalid', '--flag=--foo'] TryFlag(cmd, host, MockGitCL(host)).run() self.assertEqual(host.stderr.getvalue(), 'specify "trigger" or "update"\n')
def test_some_commands_not_run_with_auth(self): host = MockHost() host.executive = MockExecutive(output='mock-output') git_cl = GitCL(host, auth_refresh_token_json='token.json') git_cl.run(['issue']) self.assertEqual(host.executive.calls, [['git', 'cl', 'issue']])
def test_get_credentials_empty(self): host = MockHost() host.filesystem.write_text_file('/tmp/credentials.json', '{}') self.assertEqual(read_credentials(host, '/tmp/credentials.json'), {})
def _tokenize(self, line): host = MockHost() return TestExpectationLine.tokenize_line('path', line, 0, host.port_factory.get('test-win-win7', None))
def __init__(self, testFunc): host = MockHost() self._port = host.port_factory.get('test-win-win7', None) self._exp = None unittest.TestCase.__init__(self, testFunc)
def __init__(self, testFunc): host = MockHost() test_port = host.port_factory.get('test-win-win7', None) self._converter = TestConfigurationConverter(test_port.all_test_configurations(), test_port.configuration_specifier_macros()) unittest.TestCase.__init__(self, testFunc)
def test_cl_description_moves_noexport_tag(self): host = MockHost() host.executive = MockExecutive(output='Summary\n\nNo-Export: true\n\n') importer = TestImporter(host) description = importer._cl_description(directory_owners={}) self.assertIn('No-Export: true', description)
def test_commit_message(self): importer = TestImporter(MockHost()) self.assertEqual( importer._commit_message('aaaa', '1111'), 'Import 1111\n\n' 'Using wpt-import in Chromium aaaa.\n\n' 'No-Export: true')
def test_constructor(self): host = MockHost() LocalWPT(host, 'token') self.assertEqual(len(host.executive.calls), 0)
def test_get_credentials_none(self): self.assertEqual(read_credentials(MockHost(), None), {})
def test_run(self): host = MockHost() local_wpt = LocalWPT(host, 'token') local_wpt.run(['echo', 'rutabaga']) self.assertEqual(host.executive.calls, [['echo', 'rutabaga']])
def test_ensure_manifest_raises_exception(self): host = MockHost() host.executive = MockExecutive(should_throw=True) with self.assertRaises(ScriptError): WPTManifest.ensure_manifest(host)
def setUp(self): super(TestResultSinkTestBase, self).setUpClass() self.port = TestPort(MockHost())
def setUp(self): host = MockHost() self.port = host.port_factory.get(port_name='test') self._actual_output = DriverOutput(None, None, None, None) self._expected_output = DriverOutput(None, None, None, None)
def mock_host(self): """Returns a mock host with fake values set up for testing.""" host = MockHost() host.port_factory = MockPortFactory(host) # Set up a fake list of try builders. host.builders = BuilderList({ 'MOCK Try Mac10.10': { 'port_name': 'test-mac-mac10.10', 'specifiers': ['Mac10.10', 'Release'], 'is_try_builder': True, }, 'MOCK Try Mac10.11': { 'port_name': 'test-mac-mac10.11', 'specifiers': ['Mac10.11', 'Release'], 'is_try_builder': True, }, 'MOCK Try Trusty': { 'port_name': 'test-linux-trusty', 'specifiers': ['Trusty', 'Release'], 'master': 'tryserver.blink', 'has_webdriver_tests': True, 'is_try_builder': True, }, 'MOCK Try Precise': { 'port_name': 'test-linux-precise', 'specifiers': ['Precise', 'Release'], 'is_try_builder': True, }, 'MOCK Try Win10': { 'port_name': 'test-win-win10', 'specifiers': ['Win10', 'Release'], 'is_try_builder': True, }, 'MOCK Try Win7': { 'port_name': 'test-win-win7', 'specifiers': ['Win7', 'Release'], 'is_try_builder': True, }, }) # Write a dummy manifest file, describing what tests exist. host.filesystem.write_text_file( host.port_factory.get().web_tests_dir() + '/external/' + BASE_MANIFEST_NAME, json.dumps({ 'items': { 'reftest': { 'reftest.html': [ 'abcdef123', [None, [['/reftest-ref.html', '==']], {}] ] }, 'testharness': { 'test/path.html': ['abcdef123', [None, {}]], 'test/zzzz.html': ['ghijkl456', [None, {}]], }, 'manual': { 'x-manual.html': ['abcdef123', [None, {}]], }, }, })) return host
def setUp(self): self.wpt_github = WPTGitHub(MockHost(), user='******', token='decafbad')
def mock_host(self): host = MockHost() for path in PRODUCTS_TO_EXPECTATION_FILE_PATHS.values(): host.filesystem.write_text_file(path, '') return host
def test_constructor_throws_on_pr_history_window_too_large(self): with self.assertRaises(ValueError): self.wpt_github = WPTGitHub(MockHost(), user='******', token='decafbad', pr_history_window=MAX_PR_HISTORY_WINDOW + 1)
def test_skip_tests_expectations(self): """Tests that tests are skipped based on to expectations and options.""" host = MockHost() port = host.port_factory.get('test-win-win7', None) all_tests = [ 'fast/css/passes.html', 'fast/css/fails.html', 'fast/css/times_out.html', 'fast/css/skip.html', ] # Patch port.tests() to return our tests port.tests = lambda paths: paths or all_tests options = optparse.Values({ 'no_expectations': False, 'enable_sanitizer': False, 'skipped': 'default', 'skip_timeouts': False, 'skip_failing_tests': False, }) finder = web_test_finder.WebTestFinder(port, options) expectations = test_expectations.TestExpectations(port) expectations.merge_raw_expectations( ('# results: [ Failure Timeout Skip ]' '\nfast/css/fails.html [ Failure ]' '\nfast/css/times_out.html [ Timeout ]' '\nfast/css/skip.html [ Skip ]')) # When run with default settings, we only skip the tests marked Skip. tests = finder.skip_tests([], all_tests, expectations) self.assertEqual(tests, set(['fast/css/skip.html'])) # Specify test on the command line; by default should not skip. tests = finder.skip_tests(['fast/css/skip.html'], all_tests, expectations) self.assertEqual(tests, set()) # Specify test on the command line, but always skip. finder._options.skipped = 'always' tests = finder.skip_tests(['fast/css/skip.html'], all_tests, expectations) self.assertEqual(tests, set(['fast/css/skip.html'])) finder._options.skipped = 'default' # Only run skip tests, aka skip all non-skipped tests. finder._options.skipped = 'only' tests = finder.skip_tests([], all_tests, expectations) self.assertEqual( tests, set([ 'fast/css/passes.html', 'fast/css/fails.html', 'fast/css/times_out.html' ])) finder._options.skipped = 'default' # Ignore any skip entries, aka never skip anything. finder._options.skipped = 'ignore' tests = finder.skip_tests([], all_tests, expectations) self.assertEqual(tests, set()) finder._options.skipped = 'default' # Skip tests that are marked TIMEOUT. finder._options.skip_timeouts = True tests = finder.skip_tests([], all_tests, expectations) self.assertEqual( tests, set(['fast/css/times_out.html', 'fast/css/skip.html'])) finder._options.skip_timeouts = False # Skip tests that are marked FAILURE finder._options.skip_failing_tests = True tests = finder.skip_tests([], all_tests, expectations) self.assertEqual(tests, set(['fast/css/fails.html', 'fast/css/skip.html'])) finder._options.skip_failing_tests = False # Disable expectations entirely; nothing should be skipped by default. finder._options.no_expectations = True tests = finder.skip_tests([], all_tests, None) self.assertEqual(tests, set())
def test_commit_changes(self): host = MockHost() importer = TestImporter(host) importer._commit_changes('dummy message') self.assertEqual(importer.chromium_git.local_commits(), [['dummy message']])
def test_get_issue_number_none(self): host = MockHost() host.executive = MockExecutive(output='Issue number: None (None)') git_cl = GitCL(host) self.assertEqual(git_cl.get_issue_number(), 'None')
def test_tbr_reviewer_skips_non_committer(self): host = MockHost() importer = TestImporter(host) importer._fetch_ecosystem_infra_sheriff_username = lambda: 'kyleju' self.assertEqual(TBR_FALLBACK, importer.tbr_reviewer()) self.assertLog(['WARNING: Cannot TBR by kyleju: not a committer\n'])
def test_latest_try_jobs_cq_only(self): git_cl = GitCL(MockHost()) git_cl.fetch_raw_try_job_results = lambda **_: [ { 'builder_name': 'cq-a', 'experimental': False, 'result': None, 'status': 'SCHEDULED', 'tags': ['user_agent:cq'], 'url': None, }, { 'builder_name': 'cq-b', 'experimental': False, 'result': None, 'status': 'SCHEDULED', 'tags': ['cq_experimental:false', 'user_agent:cq'], 'url': None, }, { 'builder_name': 'cq-c', 'experimental': True, 'result': None, 'status': 'SCHEDULED', 'tags': ['cq_experimental:false', 'user_agent:cq'], 'url': None, }, { 'builder_name': 'cq-a-experimental', 'experimental': True, 'result': None, 'status': 'SCHEDULED', 'tags': ['cq_experimental:true', 'user_agent:cq'], 'url': None, }, { 'builder_name': 'cq-b-experimental', 'experimental': False, 'result': None, 'status': 'SCHEDULED', 'tags': ['cq_experimental:true', 'user_agent:cq'], 'url': None, }, { 'builder_name': 'other-a', 'experimental': False, 'status': 'SCHEDULED', 'result': None, 'tags': ['user_agent:git_cl_try'], 'url': None, }, { 'builder_name': 'other-b', 'experimental': False, 'status': 'SCHEDULED', 'result': None, 'tags': ['is_experimental:false', 'user_agent:git_cl_try'], 'url': None, }, ] self.assertEqual( git_cl.latest_try_jobs(cq_only=True), { Build('cq-a'): TryJobStatus('SCHEDULED'), Build('cq-b'): TryJobStatus('SCHEDULED'), Build('cq-c'): TryJobStatus('SCHEDULED'), })
def test_short_sha(self): chromium_commit = ChromiumCommit( MockHost(), sha='c881563d734a86f7d9cd57ac509653a61c45c240') self.assertEqual(chromium_commit.short_sha, 'c881563d73')