def test_start_cmd(self): # Fails on win - see https://bugs.webkit.org/show_bug.cgi?id=84726 if sys.platform in ("cygwin", "win32"): return def fake_pid(_): host.filesystem.write_text_file("/tmp/WebKit/httpd.pid", "42") return True host = MockHost() host.executive = MockExecutive(should_log=True) test_port = test.TestPort(host) host.filesystem.write_text_file(test_port._path_to_apache_config_file(), "") server = LayoutTestApacheHttpd(test_port, "/mock/output_dir", number_of_servers=4) server._check_that_all_ports_are_available = lambda: True server._is_server_running_on_all_ports = lambda: True server._wait_for_action = fake_pid oc = OutputCapture() try: oc.capture_output() server.start() server.stop() finally: _, _, logs = oc.restore_output() self.assertIn("StartServers 4", logs) self.assertIn("MinSpareServers 4", logs) self.assertIn("MaxSpareServers 4", logs) self.assertTrue(host.filesystem.exists("/mock/output_dir/httpd.conf"))
def get_test_config(test_files=[], result_files=[]): # We could grab this from port.layout_tests_dir(), but instantiating a fully mocked port is a pain. layout_tests_directory = "/mock-checkout/LayoutTests" results_directory = '/WebKitBuild/Debug/layout-test-results' host = MockHost() for file in test_files: file_path = host.filesystem.join(layout_tests_directory, file) host.filesystem.files[file_path] = '' for file in result_files: file_path = host.filesystem.join(results_directory, file) host.filesystem.files[file_path] = '' class TestMacPort(WebKitPort): port_name = "mac" def __init__(self, host): WebKitPort.__init__(self, host, port_name=self.port_name) return TestConfig( TestMacPort(host), layout_tests_directory, results_directory, ('mac', 'mac-leopard', 'win', 'linux'), host.filesystem, host.scm())
def __init__(self, *args, **kwargs): MockHost.__init__(self, *args, **kwargs) self._deprecated_port = MockPort() self.status_server = MockStatusServer() self.wakeup_event = threading.Event()
def test_cl_description_with_empty_environ(self): host = MockHost() host.executive = MockExecutive2(output="Last commit message\n") updater = DepsUpdater(host) description = updater._cl_description() self.assertEqual(description, ("Last commit message\n" "[email protected]\n" "NOEXPORT=true")) self.assertEqual(host.executive.calls, [["git", "log", "-1", "--format=%B"]])
def test_harness_no_expectations(self): """Tests behavior when TestExpectations file doesn't exist. Tests that a warning is outputted if the TestExpectations file doesn't exist. """ # Set up the mock host and port. host = MockHost() host.port_factory = FakePortFactory(host) # Write the test file but not the TestExpectations file. test_expectation_path = ( host.port_factory.get().path_to_generic_test_expectations_file()) host.filesystem = MockFileSystem() self._write_tests_into_filesystem(host.filesystem) # Write out the fake builder bot results. expectation_factory = FakeBotTestExpectationsFactory() expectation_factory._all_results_by_builder = {} self.assertFalse(host.filesystem.isfile(test_expectation_path)) return_code = main(host, expectation_factory, []) self.assertEqual(return_code, 1) self.assertLog([ "WARNING: Didn't find generic expectations file at: %s\n" % test_expectation_path ]) self.assertFalse(host.filesystem.isfile(test_expectation_path))
def test_creates_pull_request_for_earliest_commit(self): host = MockHost() def mock_command(args): git_command = args[1] if git_command == 'rev-list': return 'facebeef\ncafedad5' elif git_command == 'footers': return 'fake-cr-position' elif git_command == 'show': if 'cafedad5' in args: return 'newer fake text' elif 'facebeef' in args: return 'older fake text' else: return '' host.executive = MockExecutive2(run_command_fn=mock_command) wpt_github = MockWPTGitHub(pull_requests=[]) TestExporter(host, wpt_github).run() self.assertEqual(wpt_github.calls, ['in_flight_pull_requests', 'create_pr']) self.assertEqual(wpt_github.pull_requests_created, [('chromium-export-try', 'older fake text', 'older fake text')])
def test_dry_run_stops_before_creating_pr(self): host = MockHost() host.executive = MockExecutive2(output='beefcafe') wpt_github = MockWPTGitHub(pull_requests=[{'number': 1, 'title': 'abc'}]) TestExporter(host, wpt_github, dry_run=True).run() self.assertEqual(wpt_github.calls, ['in_flight_pull_requests'])
def test_import_dir_with_no_tests(self): host = MockHost() host.executive = MockExecutive2(exception=ScriptError( "abort: no repository found in '/Volumes/Source/src/wk/Tools/Scripts/webkitpy/w3c'")) host.filesystem = MockFileSystem(files=FAKE_FILES) importer = TestImporter(host, FAKE_SOURCE_REPO_DIR, self.options()) importer.do_import() # No exception raised.
def test_run(self): host = MockHost() host.executive = MockExecutive2(output='mock-output') git_cl = GitCL(host) output = git_cl.run(['command']) self.assertEqual(output, 'mock-output') self.assertEqual(host.executive.calls, [['git', 'cl', 'command']])
def test_ref_test_with_ref_is_copied(self): host = MockHost() host.filesystem = MockFileSystem(files={ '/blink/w3c/dir1/my-ref-test.html': '<html><head><link rel="match" href="ref-file.html" />test</head></html>', '/blink/w3c/dir1/ref-file.html': '<html><head>test</head></html>', '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations': '', '/mock-checkout/third_party/WebKit/Source/core/css/CSSProperties.in': '', }) importer = TestImporter(host, FAKE_SOURCE_REPO_DIR, self.options()) importer.find_importable_tests() self.assertEqual( importer.import_list, [ { 'copy_list': [ {'src': '/blink/w3c/dir1/ref-file.html', 'dest': 'ref-file.html'}, {'src': '/blink/w3c/dir1/ref-file.html', 'dest': 'my-ref-test-expected.html', 'reference_support_info': {}}, {'src': '/blink/w3c/dir1/my-ref-test.html', 'dest': 'my-ref-test.html'} ], 'dirname': '/blink/w3c/dir1', 'jstests': 0, 'reftests': 1, 'total_tests': 1 } ])
def test_add_skipped_tests(self): port = MockHost().port_factory.get('qt') port._filesystem.files[port._filesystem.join(port.layout_tests_dir(), 'platform/qt/Skipped')] = 'failures/expected/text.html' port._filesystem.files[port._filesystem.join(port.layout_tests_dir(), 'failures/expected/text.html')] = 'foo' expectations = TestExpectations(port, tests=['failures/expected/text.html'], expectations='', test_config=port.test_configuration()) self.assertEquals(expectations.get_modifiers('failures/expected/text.html'), [TestExpectationParser.DUMMY_BUG_MODIFIER, TestExpectationParser.SKIP_MODIFIER]) self.assertEquals(expectations.get_expectations('failures/expected/text.html'), set([FAIL]))
def test_create_branch_with_patch(self): host = MockHost() host.filesystem = MockFileSystem() local_wpt = LocalWPT(host) local_wpt.create_branch_with_patch('branch-name', 'message', 'patch') self.assertEqual(len(host.executive.calls), 9)
def test_files_with_shebang_are_made_executable(self): host = MockHost() host.filesystem = MockFileSystem(files=FAKE_FILES) importer = TestImporter(host, FAKE_SOURCE_REPO_DIR, self.options()) importer.do_import() self.assertEqual( host.filesystem.executable_files, set(['/mock-checkout/third_party/WebKit/LayoutTests/w3c/blink/w3c/dir/has_shebang.txt']))
def test_last_wpt_exported_commit_not_found(self): host = MockHost() host.executive = MockExecutive2(run_command_fn=lambda _: None) host.filesystem = MockFileSystem() local_wpt = LocalWPT(host) commit = local_wpt.most_recent_chromium_commit() self.assertEqual(commit, (None, None))
def test_run_with_auth(self): host = MockHost() host.executive = MockExecutive2(output='mock-output') git_cl = GitCL(host, auth_refresh_token_json='token.json') git_cl.run(['upload']) self.assertEqual( host.executive.calls, [['git', 'cl', 'upload', '--auth-refresh-token-json', 'token.json']])
def test_derives_sha_from_position(self): host = MockHost() host.executive = MockExecutive2(output="deadbeefcafe") pos = "Cr-Commit-Position: refs/heads/master@{#789}" chromium_commit = ChromiumCommit(host, position=pos) self.assertEqual(chromium_commit.position, "refs/heads/master@{#789}") self.assertEqual(chromium_commit.sha, "deadbeefcafe")
def test_clones_if_wpt_does_not_exist(self): host = MockHost() host.filesystem = MockFileSystem() LocalWPT(host) self.assertEqual(len(host.executive.calls), 1) self.assertEqual(host.executive.calls[0][1], 'clone')
def touched_files(self, touched_files, fs=None): host = MockHost() if fs: host.filesystem = fs else: fs = host.filesystem port = MockPort(host) return (fs, LayoutTestFinder(port, optparse.Values({'skipped': 'always', 'skip_failing_tests': False, 'http': True})).find_touched_tests(touched_files))
def test_all_configurations(self): class FakePort(object): def __init__(self, host, name, path): self.host = host self.name = name self.path = path def path_to_test_expectations_file(self): return self.path def test_configuration(self): return None def expectations_dict(self): self.host.ports_parsed.append(self.name) return {self.path: ''} def skipped_layout_tests(self, tests): return set([]) def all_test_configurations(self): return [] def configuration_specifier_macros(self): return [] def path_from_webkit_base(self): return '' def get_option(self, name, val): return val class FakeFactory(object): def __init__(self, host, ports): self.host = host self.ports = {} for port in ports: self.ports[port.name] = port def get(self, port_name, *args, **kwargs): return self.ports[port_name] def all_port_names(self): return sorted(self.ports.keys()) host = MockHost() host.ports_parsed = [] host.port_factory = FakeFactory(host, (FakePort(host, 'a', 'path-to-a'), FakePort(host, 'b', 'path-to-b'), FakePort(host, 'b-win', 'path-to-b'))) self.assertEquals(run_webkit_tests.lint(host.port_factory.ports['a'], MockOptions(platform=None)), 0) self.assertEquals(host.ports_parsed, ['a', 'b']) host.ports_parsed = [] self.assertEquals(run_webkit_tests.lint(host.port_factory.ports['a'], MockOptions(platform='a')), 0) self.assertEquals(host.ports_parsed, ['a'])
def test_filesystem_walk(self): mock_dir = 'foo' mock_files = {'foo/bar/baz': '', 'foo/a': '', 'foo/b': '', 'foo/c': ''} host = MockHost() host.filesystem = MockFileSystem(files=mock_files) self.assertEquals(host.filesystem.walk(mock_dir), [('foo', ['bar'], ['a', 'b', 'c']), ('foo/bar', [], ['baz'])])
def test_check_is_functional_cdb_not_found(self): host = MockHost() host.executive = MockExecutive(should_throw=True) build_dir = "/mock-checkout/out/Debug" host.filesystem.maybe_make_directory(build_dir) dump_reader = DumpReaderWin(host, build_dir) self.assertFalse(dump_reader.check_is_functional())
def test_no_fetch_flag(self): host = MockHost() host.filesystem = MockFileSystem(files={ '/tmp/wpt': '' }) LocalWPT(host, no_fetch=True) self.assertEqual(len(host.executive.calls), 0)
def test_run(self): host = MockHost() host.filesystem = MockFileSystem() local_wpt = LocalWPT(host) local_wpt.run(['echo', 'rutabaga']) self.assertEqual(len(host.executive.calls), 2) self.assertEqual(host.executive.calls[1], ['echo', 'rutabaga'])
def __init__(self, *args, **kwargs): MockHost.__init__(self, *args, **kwargs) self._deprecated_port = MockPort() self.status_server = MockStatusServer() self._irc = None self.irc_password = "******" self.wakeup_event = threading.Event()
def test_create_branch_with_patch(self): host = MockHost() host.filesystem = MockFileSystem() local_wpt = LocalWPT(host) local_branch_name = local_wpt.create_branch_with_patch('message', 'patch') self.assertEqual(len(host.executive.calls), 9) self.assertEqual(local_branch_name, 'chromium-export-try')
def test_ref_test_without_ref_is_skipped(self): host = MockHost() host.filesystem = MockFileSystem(files={ '/blink/w3c/dir1/my-ref-test.html': '<html><head><link rel="match" href="not-here.html" /></head></html>', '/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations': '', '/mock-checkout/third_party/WebKit/Source/core/css/CSSProperties.in': '', }) importer = TestImporter(host, FAKE_SOURCE_REPO_DIR, self.options()) importer.find_importable_tests() self.assertEqual(importer.import_list, [])
def __init__(self, *args, **kwargs): MockHost.__init__(self, *args, **kwargs) self._port = TestPort(self) self._port.name = lambda: "MockPort" self.status_server = MockStatusServer() self._irc = None self.irc_password = "******" self.wakeup_event = threading.Event()
def test_skipped_entry_dont_exist(self): port = MockHost().port_factory.get('qt') expectations_dict = OrderedDict() expectations_dict['expectations'] = '' port.expectations_dict = lambda: expectations_dict port.skipped_layout_tests = lambda tests: set(['foo/bar/baz.html']) capture = OutputCapture() capture.capture_output() exp = TestExpectations(port) _, _, logs = capture.restore_output() self.assertEqual('The following test foo/bar/baz.html from the Skipped list doesn\'t exist\n', logs)
def test_has_changes_in_wpt_looks_at_start_of_string(self): host = MockHost() def run_command_fn(_): return ("something/something.html\n" "something/third_party/WebKit/LayoutTests/imported/wpt/something.html\n") host.executive = MockExecutive2(run_command_fn=run_command_fn) chromium_wpt = ChromiumWPT(host) self.assertFalse(chromium_wpt.has_changes_in_wpt('sha'))
def test_skipped_entry_dont_exist(self): port = MockHost().port_factory.get("test-win-xp") expectations_dict = OrderedDict() expectations_dict["expectations"] = "" port.expectations_dict = lambda: expectations_dict port.skipped_layout_tests = lambda tests: set(["foo/bar/baz.html"]) capture = OutputCapture() capture.capture_output() exp = TestExpectations(port) _, _, logs = capture.restore_output() self.assertEqual("The following test foo/bar/baz.html from the Skipped list doesn't exist\n", logs)
def test_no_svn_revision(self): host = MockHost() port = host.port_factory.get('test') expected_results, unexpected_results = self.summarized_results( port, expected=False, passing=False, flaky=False) self.assertTrue('revision' not in unexpected_results)
def test_harness_updates_file(self): """Tests that the call harness updates the TestExpectations file.""" self._define_builders({ 'WebKit Linux Trusty': { 'port_name': 'linux-trusty', 'specifiers': ['Trusty', 'Release'] }, 'WebKit Linux Trusty (dbg)': { 'port_name': 'linux-trusty', 'specifiers': ['Trusty', 'Debug'] }, }) # Setup the mock host and port. host = MockHost() host.port_factory = FakePortFactory(host, all_build_types=('release', 'debug'), all_systems=(('trusty', 'x86_64'), )) # Write out a fake TestExpectations file. test_expectation_path = ( host.port_factory.get().path_to_generic_test_expectations_file()) test_expectations = """ # Remove since passing on both bots. Bug(test) [ Linux ] test/a.html [ Failure Pass ] # Keep since there's a failure on release bot. Bug(test) [ Linux Release ] test/b.html [ Failure Pass ] # Remove since it's passing on both builders. Bug(test) test/c.html [ Failure Pass ] # Keep since there's a failure on debug bot. Bug(test) [ Linux ] test/d.html [ Failure ]""" files = {test_expectation_path: test_expectations} host.filesystem = MockFileSystem(files) self._write_tests_into_filesystem(host.filesystem) # Write out the fake builder bot results. expectation_factory = FakeBotTestExpectationsFactory() expectation_factory.all_results_by_builder = { 'WebKit Linux Trusty': { 'test/a.html': ['PASS', 'PASS', 'PASS'], 'test/b.html': ['PASS', 'IMAGE', 'PASS'], 'test/c.html': ['PASS', 'PASS', 'PASS'], 'test/d.html': ['PASS', 'PASS', 'PASS'], }, 'WebKit Linux Trusty (dbg)': { 'test/a.html': ['PASS', 'PASS', 'PASS'], 'test/b.html': ['PASS', 'PASS', 'PASS'], 'test/c.html': ['PASS', 'PASS', 'PASS'], 'test/d.html': ['IMAGE', 'PASS', 'PASS'], }, } main(host, expectation_factory, []) self.assertEqual( host.filesystem.files[test_expectation_path], (""" # Keep since there's a failure on release bot. Bug(test) [ Linux Release ] test/b.html [ Failure Pass ] # Keep since there's a failure on debug bot. Bug(test) [ Linux ] test/d.html [ Failure ]"""))
def test_invalid_action(self): host = MockHost() TryFlag(['invalid'], host, MockGitCL(host)).run() self.assertEqual(host.stderr.getvalue(), 'specify "trigger" or "update"\n')
def test_analyze_one_changelog(self): host = MockHost() host.filesystem.files[ 'mock-checkout/foo/ChangeLog'] = u"""2011-11-17 Mark Rowe <*****@*****.**> <http://webkit.org/b/72646> Disable deprecation warnings around code where we cannot easily switch away from the deprecated APIs. Reviewed by Sam Weinig. * platform/mac/WebCoreNSStringExtras.mm: * platform/network/cf/SocketStreamHandleCFNet.cpp: (WebCore::SocketStreamHandle::reportErrorToClient): 2011-11-19 Kevin Ollivier <*****@*****.**> [wx] C++ bindings build fix for move of array classes to WTF. * bindings/scripts/CodeGeneratorCPP.pm: (GetCPPTypeGetter): (GetNamespaceForClass): (GenerateHeader): (GenerateImplementation): 2011-10-27 Philippe Normand <*****@*****.**> and Zan Dobersek <*****@*****.**> [GStreamer] WebAudio AudioFileReader implementation https://bugs.webkit.org/show_bug.cgi?id=69834 Reviewed by Martin Robinson. Basic FileReader implementation, supporting one or 2 audio channels. An empty AudioDestination is also provided, its complete implementation is handled in bug 69835. * GNUmakefile.am: * GNUmakefile.list.am: * platform/audio/gstreamer/AudioDestinationGStreamer.cpp: Added. (WebCore::AudioDestination::create): (WebCore::AudioDestination::hardwareSampleRate): (WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer): (WebCore::AudioDestinationGStreamer::~AudioDestinationGStreamer): (WebCore::AudioDestinationGStreamer::start): (WebCore::AudioDestinationGStreamer::stop): * platform/audio/gstreamer/AudioDestinationGStreamer.h: Added. (WebCore::AudioDestinationGStreamer::isPlaying): (WebCore::AudioDestinationGStreamer::sampleRate): (WebCore::AudioDestinationGStreamer::sourceProvider): * platform/audio/gstreamer/AudioFileReaderGStreamer.cpp: Added. (WebCore::getGStreamerAudioCaps): (WebCore::getFloatFromByteReader): (WebCore::copyGstreamerBuffersToAudioChannel): (WebCore::onAppsinkNewBufferCallback): (WebCore::messageCallback): (WebCore::onGStreamerDeinterleavePadAddedCallback): (WebCore::onGStreamerDeinterleaveReadyCallback): (WebCore::onGStreamerDecodebinPadAddedCallback): (WebCore::AudioFileReader::AudioFileReader): (WebCore::AudioFileReader::~AudioFileReader): (WebCore::AudioFileReader::handleBuffer): (WebCore::AudioFileReader::handleMessage): (WebCore::AudioFileReader::handleNewDeinterleavePad): (WebCore::AudioFileReader::deinterleavePadsConfigured): (WebCore::AudioFileReader::plugDeinterleave): (WebCore::AudioFileReader::createBus): (WebCore::createBusFromAudioFile): (WebCore::createBusFromInMemoryAudioFile): * platform/audio/gtk/AudioBusGtk.cpp: Added. (WebCore::AudioBus::loadPlatformResource): """ capture = OutputCapture() capture.capture_output() analyzer = ChangeLogAnalyzer(host, ['mock-checkout/foo/ChangeLog']) analyzer.analyze() capture.restore_output() self.assertEqual( analyzer.summary(), { 'reviewed': 2, 'unreviewed': 1, 'contributors': 6, 'contributors_with_reviews': 2, 'contributors_without_reviews': 4 }) self.assertEqual( set(analyzer.contributors_statistics().keys()), set([ 'Sam Weinig', u'Mark Rowe', u'Kevin Ollivier', 'Martin Robinson', u'Philippe Normand', u'Zan Dobersek' ])) self.assertEqual( analyzer.contributors_statistics()['Sam Weinig'], { 'reviews': { 'files': { u'foo/platform/mac/WebCoreNSStringExtras.mm': 1, u'foo/platform/network/cf/SocketStreamHandleCFNet.cpp': 1 }, 'total': 1, 'areas': { 'Network': 1 } }, 'patches': { 'files': {}, 'areas': {}, 'unreviewed': 0, 'reviewed': 0 } }) self.assertEqual( analyzer.contributors_statistics()[u'Mark Rowe'], { 'reviews': { 'files': {}, 'total': 0, 'areas': {} }, 'patches': { 'files': { u'foo/platform/mac/WebCoreNSStringExtras.mm': 1, u'foo/platform/network/cf/SocketStreamHandleCFNet.cpp': 1 }, 'areas': { 'Network': 1 }, 'unreviewed': 0, 'reviewed': 1 } }) self.assertEqual( analyzer.contributors_statistics()[u'Kevin Ollivier'], { 'reviews': { 'files': {}, 'total': 0, 'areas': {} }, 'patches': { 'files': { u'foo/bindings/scripts/CodeGeneratorCPP.pm': 1 }, 'areas': { 'Bindings': 1 }, 'unreviewed': 1, 'reviewed': 0 } }) files_for_audio_patch = { u'foo/GNUmakefile.am': 1, u'foo/GNUmakefile.list.am': 1, 'foo/platform/audio/gstreamer/AudioDestinationGStreamer.cpp': 1, 'foo/platform/audio/gstreamer/AudioDestinationGStreamer.h': 1, 'foo/platform/audio/gstreamer/AudioFileReaderGStreamer.cpp': 1, 'foo/platform/audio/gtk/AudioBusGtk.cpp': 1 } author_expectation_for_audio_patch = { 'reviews': { 'files': {}, 'total': 0, 'areas': {} }, 'patches': { 'files': files_for_audio_patch, 'areas': { 'The WebKitGTK+ Port': 1 }, 'unreviewed': 0, 'reviewed': 1 } } self.assertEqual( analyzer.contributors_statistics()[u'Martin Robinson'], { 'reviews': { 'files': files_for_audio_patch, 'total': 1, 'areas': { 'The WebKitGTK+ Port': 1 } }, 'patches': { 'files': {}, 'areas': {}, 'unreviewed': 0, 'reviewed': 0 } }) self.assertEqual( analyzer.contributors_statistics()[u'Philippe Normand'], author_expectation_for_audio_patch) self.assertEqual(analyzer.contributors_statistics()[u'Zan Dobersek'], author_expectation_for_audio_patch) areas_statistics = analyzer.areas_statistics() areas_with_patches = [ area for area in areas_statistics if areas_statistics[area]['reviewed'] or areas_statistics[area]['unreviewed'] ] self.assertEqual(set(areas_with_patches), set(['Bindings', 'Network', 'The WebKitGTK+ Port'])) self.assertEqual( areas_statistics['Bindings'], { 'unreviewed': 1, 'reviewed': 0, 'contributors': { u'Kevin Ollivier': { 'reviews': 0, 'unreviewed': 1, 'reviewed': 0 } } }) self.assertEqual( areas_statistics['Network'], { 'unreviewed': 0, 'reviewed': 1, 'contributors': { 'Sam Weinig': { 'reviews': 1, 'unreviewed': 0, 'reviewed': 0 }, u'Mark Rowe': { 'reviews': 0, 'unreviewed': 0, 'reviewed': 1 } } })
def __init__(self, options=None): options = options or MockOptions() chromium_mac.ChromiumMacPort.__init__(self, MockHost(), options=options)
def __init__(self): MockHost.__init__(self) self.executive = MockExecutive2(exception=OSError()) self.filesystem = MockFileSystem() self._mockSCM = TestExporterTest.MockGit(None, None, None, None)
def get_manager(): host = MockHost() port = host.port_factory.get('test-mac-leopard') manager = Manager(port, options=MockOptions(http=True, max_locked_shards=1), printer=FakePrinter()) return manager
def test_unknown_specified(self): with self.assertRaises(NotImplementedError): factory.PortFactory(MockHost()).get(port_name='unknown')
def test_unknown_default(self): with self.assertRaises(NotImplementedError): factory.PortFactory(MockHost(os_name='vms')).get()
def setUp(self): host = MockHost(initialize_scm_by_default=False) self.port = host.port_factory.get(port_name='test')
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 __init__(self): AbstractPatchQueue.__init__(self, host=MockHost())
def test_get_from_builder_name(self): self.assertEqual( factory.PortFactory( MockHost()).get_from_builder_name('WebKit Mac10.11').name(), 'mac-mac10.11')
def __init__(self, testFunc): host = MockHost() test_port = host.port_factory.get('test-win-xp', None) self._converter = TestConfigurationConverter(test_port.all_test_configurations(), test_port.configuration_specifier_macros()) unittest.TestCase.__init__(self, testFunc)
def test_url(self): chromium_commit = ChromiumCommit( MockHost(), sha='c881563d734a86f7d9cd57ac509653a61c45c240') self.assertEqual( chromium_commit.url(), 'https://chromium.googlesource.com/chromium/src/+/c881563d73')
def test_init(self): wpt_github = WPTGitHub(MockHost(), user='******', token='deadbeefcafe') self.assertEqual(wpt_github.user, 'rutabaga') self.assertEqual(wpt_github.token, 'deadbeefcafe')
def test_short_sha(self): chromium_commit = ChromiumCommit( MockHost(), sha='c881563d734a86f7d9cd57ac509653a61c45c240') self.assertEqual(chromium_commit.short_sha, 'c881563d73')
def test_servers_started(self): def start_http_server(): self.http_started = True def start_websocket_server(): self.websocket_started = True def start_web_platform_test_server(): self.web_platform_test_server_started = True def stop_http_server(): self.http_stopped = True def stop_websocket_server(): self.websocket_stopped = True def stop_web_platform_test_server(): self.web_platform_test_server_stopped = True def is_http_server_running(): return self.http_started and not self.http_stopped def is_websocket_server_running(): return self.websocket_started and not self.websocket_stopped def is_wpt_server_running(): return self.websocket_started and not self.web_platform_test_server_stopped host = MockHost() port = host.port_factory.get('test-mac-leopard') port.start_http_server = start_http_server port.start_websocket_server = start_websocket_server port.start_web_platform_test_server = start_web_platform_test_server port.stop_http_server = stop_http_server port.stop_websocket_server = stop_websocket_server port.stop_web_platform_test_server = stop_web_platform_test_server port.is_http_server_running = is_http_server_running port.is_websocket_server_running = is_websocket_server_running port.is_wpt_server_running = is_wpt_server_running self.http_started = self.http_stopped = self.websocket_started = self.websocket_stopped = False self.web_platform_test_server_started = self.web_platform_test_server_stopped = False runner = self._runner(port=port) runner._needs_http = True runner._needs_websockets = False runner._needs_web_platform_test_server = False runner.start_servers() self.assertEqual(self.http_started, True) self.assertEqual(self.websocket_started, False) self.assertEqual(self.web_platform_test_server_started, False) runner.stop_servers() self.assertEqual(self.http_stopped, True) self.assertEqual(self.websocket_stopped, False) self.assertEqual(self.web_platform_test_server_stopped, False) self.http_started = self.http_stopped = self.websocket_started = self.websocket_stopped = False self.web_platform_test_server_started = self.web_platform_test_server_stopped = False runner._needs_http = True runner._needs_websockets = True runner._needs_web_platform_test_server = False runner.start_servers() self.assertEqual(self.http_started, True) self.assertEqual(self.websocket_started, True) self.assertEqual(self.web_platform_test_server_started, False) runner.stop_servers() self.assertEqual(self.http_stopped, True) self.assertEqual(self.websocket_stopped, True) self.assertEqual(self.web_platform_test_server_stopped, False) self.http_started = self.http_stopped = self.websocket_started = self.websocket_stopped = False self.web_platform_test_server_started = self.web_platform_test_server_stopped = False runner._needs_http = False runner._needs_websockets = False runner._needs_web_platform_test_server = True runner.start_servers() self.assertEqual(self.http_started, False) self.assertEqual(self.websocket_started, False) self.assertEqual(self.web_platform_test_server_started, True) runner.stop_servers() self.assertEqual(self.http_stopped, False) self.assertEqual(self.websocket_stopped, False) self.assertEqual(self.web_platform_test_server_stopped, True) self.http_started = self.http_stopped = self.websocket_started = self.websocket_stopped = False self.web_platform_test_server_started = self.web_platform_test_server_stopped = False runner._needs_http = False runner._needs_websockets = False runner._needs_web_platform_test_server = False runner.start_servers() self.assertEqual(self.http_started, False) self.assertEqual(self.websocket_started, False) self.assertEqual(self.web_platform_test_server_started, False) runner.stop_servers() self.assertEqual(self.http_stopped, False) self.assertEqual(self.websocket_stopped, False) self.assertEqual(self.web_platform_test_server_stopped, False)
def test_ensure_manifest_raises_exception(self): host = MockHost() host.executive = MockExecutive(should_throw=True) with self.assertRaises(ScriptError): WPTManifest.ensure_manifest(host)
def __init__(self): FeederQueue.__init__(self, host=MockHost())
def __init__(self, testFunc): host = MockHost() self._port = host.port_factory.get('test-win-xp', None) self._exp = None unittest.TestCase.__init__(self, testFunc)
def __init__(self, custom_run_test=None): super(MockPort, self).__init__(host=MockHost(), custom_run_test=custom_run_test)
def test_auth_token(self): wpt_github = wpt_github = WPTGitHub(MockHost(), user='******', token='deadbeefcafe') self.assertEqual( wpt_github.auth_token(), base64.encodestring('rutabaga:deadbeefcafe').strip())
def setUp(self): """ Set up method for SimulatorTest """ self._host = MockHost()
def setUp(self): host = MockHost() self.port = host.port_factory.get(port_name='test')
def test_validates_sha(self): with self.assertRaises(AssertionError): ChromiumCommit(MockHost(), sha='rutabaga')
def test_update_test_expectations(self): host = MockHost() host.executive = MockExecutive2(exception=OSError()) host.filesystem = MockFileSystem(files={ '/mock-checkout/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-expected.txt': 'e-wk1', '/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/dom/events/EventTarget-dispatchEvent-expected.txt': "g", '/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/open-features-tokenization-001-expected.txt': "h", '/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/html/browsers/windows/browsing-context-expected.txt': "i", '/mock-checkout/LayoutTests/imported/w3c/web-platform-tests/url/interfaces-expected.txt': "j-mac-wk2"}) class MockAttachment(Attachment): def __init__(self, attachment_dictionary, contents): Attachment.__init__(self, attachment_dictionary, self) self._contents = contents def contents(self): return self._contents class MockBugzilla(): def fetch_bug(self, id): return self def attachments(self): attachment_mac_wk2 = MockAttachment({"id": 1, "name": "Archive of layout-test-results from ews103 for mac-elcapitan-wk2"}, "mac-wk2") attachment_mac_wk1a = MockAttachment({"id": 2, "name": "Archive of layout-test-results from ews103 for mac-elcapitan"}, "mac-wk1a") attachment_mac_wk1b = MockAttachment({"id": 3, "name": "Archive of layout-test-results from ews104 for mac-elcapitan"}, "mac-wk1b") attachment_ios_sim = MockAttachment({"id": 4, "name": "Archive of layout-test-results from ews122 for ios-simulator-wk2"}, "ios-sim") return [attachment_ios_sim, attachment_mac_wk1a, attachment_mac_wk2, attachment_mac_wk1b] class MockZip(): def __init__(self): self.content = None mac_wk2_files = { "full_results.json": 'ADD_RESULTS({"tests":{"http":{"tests":{"media":{"hls":{"video-controls-live-stream.html":{"report":"FLAKY","expected":"PASS","actual":"TEXT PASS"},"video-duration-accessibility.html":{"report":"FLAKY","expected":"PASS","actual":"TEXT PASS"}}}}},"imported":{"w3c":{"web-platform-tests":{"html":{"browsers":{"windows":{"browsing-context.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"}}}},"fetch":{"api":{"redirect":{"redirect-count.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"},"redirect-location.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"},"redirect-count-worker.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"},"redirect-count-cross-origin.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"},"redirect-location-worker.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"}}}}}}},"media":{"track":{"track-in-band-style.html":{"report":"FLAKY","expected":"PASS","actual":"TEXT PASS"}}}},"skipped":3348,"num_regressions":6,"other_crashes":{},"interrupted":false,"num_missing":0,"layout_tests_dir":"/Volumes/Data/EWS/WebKit/LayoutTests","version":4,"num_passes":44738,"pixel_tests_enabled":false,"date":"07:18PM on April 08, 2017","has_pretty_patch":true,"fixable":3357,"num_flaky":3,"uses_expectations_file":true});', "imported/w3c/web-platform-tests/fetch/api/redirect/redirect-count-cross-origin-actual.txt": "a", "imported/w3c/web-platform-tests/fetch/api/redirect/redirect-count-worker-actual.txt": "b", "imported/w3c/web-platform-tests/fetch/api/redirect/redirect-count-actual.txt": "c", "imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-worker-actual.txt": "d", "imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-actual.txt": "e", "imported/w3c/web-platform-tests/html/browsers/windows/browsing-context-actual.txt": "f"} mac_wk1a_files = {"full_results.json": 'ADD_RESULTS({"tests":{"http":{"tests":{"loading":{"resourceLoadStatistics":{"non-prevalent-resource-without-user-interaction.html":{"report":"FLAKY","expected":"PASS","actual":"TIMEOUT PASS","has_stderr":true}}}}},"imported":{"w3c":{"web-platform-tests":{"IndexedDB":{"abort-in-initial-upgradeneeded.html":{"report":"FLAKY","expected":"PASS","actual":"TEXT PASS"}},"html":{"browsers":{"windows":{"browsing-context.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"}}}},"fetch":{"api":{"redirect":{"redirect-count.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"},"redirect-location.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"},"redirect-count-worker.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"},"redirect-count-cross-origin.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"},"redirect-location-worker.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"}}}}},"IndexedDB-private-browsing":{"idbfactory_open9.html":{"report":"FLAKY","expected":"PASS","actual":"TIMEOUT PASS","has_stderr":true}}},"blink":{"storage":{"indexeddb":{"blob-delete-objectstore-db.html":{"report":"FLAKY","expected":"PASS","actual":"TIMEOUT PASS","has_stderr":true}}}}}},"skipped":3537,"num_regressions":6,"other_crashes":{},"interrupted":false,"num_missing":0,"layout_tests_dir":"/Volumes/Data/EWS/WebKit/LayoutTests","version":4,"num_passes":44561,"pixel_tests_enabled":false,"date":"07:18PM on April 08, 2017","has_pretty_patch":true,"fixable":3547,"num_flaky":4,"uses_expectations_file":true});', "imported/w3c/web-platform-tests/fetch/api/redirect/redirect-count-cross-origin-actual.txt": "a", "imported/w3c/web-platform-tests/fetch/api/redirect/redirect-count-worker-actual.txt": "b", "imported/w3c/web-platform-tests/fetch/api/redirect/redirect-count-actual.txt": "c", "imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-worker-actual.txt": "d", "imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-actual.txt": "e", "imported/w3c/web-platform-tests/html/browsers/windows/browsing-context-actual.txt": "f-wk1a"} mac_wk1b_files = {"full_results.json": 'ADD_RESULTS({"tests":{"http":{"tests":{"loading":{"resourceLoadStatistics":{"non-prevalent-resource-without-user-interaction.html":{"report":"FLAKY","expected":"PASS","actual":"TIMEOUT PASS","has_stderr":true}}}}},"imported":{"w3c":{"web-platform-tests":{"IndexedDB":{"abort-in-initial-upgradeneeded.html":{"report":"FLAKY","expected":"PASS","actual":"TEXT PASS"}},"html":{"browsers":{"windows":{"browsing-context.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"}}}},"fetch":{"api":{"redirect":{"redirect-count.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"},"redirect-location.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"},"redirect-count-worker.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"},"redirect-count-cross-origin.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"},"redirect-location-worker.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"}}}}},"IndexedDB-private-browsing":{"idbfactory_open9.html":{"report":"FLAKY","expected":"PASS","actual":"TIMEOUT PASS","has_stderr":true}}},"blink":{"storage":{"indexeddb":{"blob-delete-objectstore-db.html":{"report":"FLAKY","expected":"PASS","actual":"TIMEOUT PASS","has_stderr":true}}}}}},"skipped":3537,"num_regressions":6,"other_crashes":{},"interrupted":false,"num_missing":0,"layout_tests_dir":"/Volumes/Data/EWS/WebKit/LayoutTests","version":4,"num_passes":44561,"pixel_tests_enabled":false,"date":"07:18PM on April 08, 2017","has_pretty_patch":true,"fixable":3547,"num_flaky":4,"uses_expectations_file":true});', "imported/w3c/web-platform-tests/fetch/api/redirect/redirect-count-cross-origin-actual.txt": "a", "imported/w3c/web-platform-tests/fetch/api/redirect/redirect-count-worker-actual.txt": "b", "imported/w3c/web-platform-tests/fetch/api/redirect/redirect-count-actual.txt": "c", "imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-worker-actual.txt": "d", "imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-actual.txt": "e", "imported/w3c/web-platform-tests/html/browsers/windows/browsing-context-actual.txt": "f-wk1b"} ios_sim_files = {"full_results.json": 'ADD_RESULTS({"tests":{"imported":{"w3c":{"web-platform-tests":{"url":{"interfaces.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"}},"html":{"browsers":{"windows":{"browsing-context.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"}},"the-window-object":{"apis-for-creating-and-navigating-browsing-contexts-by-name":{"open-features-tokenization-001.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"}}}}},"dom":{"events":{"EventTarget-dispatchEvent.html":{"report":"REGRESSION","expected":"PASS","actual":"TEXT"}}}}}},"animations":{"trigger-container-scroll-empty.html":{"report":"FLAKY","expected":"PASS","actual":"TEXT PASS"}}},"skipped":9881,"num_regressions":4,"other_crashes":{},"interrupted":false,"num_missing":0,"layout_tests_dir":"/Volumes/Data/EWS/WebKit/LayoutTests","version":4,"num_passes":38225,"pixel_tests_enabled":false,"date":"07:33PM on April 08, 2017","has_pretty_patch":true,"fixable":48110,"num_flaky":1,"uses_expectations_file":true});', "imported/w3c/web-platform-tests/dom/events/EventTarget-dispatchEvent-actual.txt": "g", "imported/w3c/web-platform-tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/open-features-tokenization-001-actual.txt": "h", "imported/w3c/web-platform-tests/html/browsers/windows/browsing-context-actual.txt": "i", "imported/w3c/web-platform-tests/url/interfaces-actual.txt": "j"} self.files = {"mac-wk2": mac_wk2_files, "mac-wk1a": mac_wk1a_files, "mac-wk1b": mac_wk1b_files, "ios-sim": ios_sim_files} def unzip(self, content): self.content = content return self def read(self, filename): return self.files[self.content][filename] mock_zip = MockZip() updater = TestExpectationUpdater(host, "123456", True, False, MockBugzilla(), lambda content: mock_zip.unzip(content)) updater.do_update() # mac-wk2 expectation self.assertTrue(self._is_matching(host, "imported/w3c/web-platform-tests/fetch/api/redirect/redirect-count-cross-origin-expected.txt", "a")) # no need to add mac-wk1 specific expectation self.assertFalse(self._exists(host, "platform/mac-wk1/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-count-cross-origin-expected.txt")) # mac-wk1/ios-simulator-wk2 specific expectation self.assertTrue(self._is_matching(host, "platform/mac-wk1/imported/w3c/web-platform-tests/html/browsers/windows/browsing-context-expected.txt", "f-wk1b")) self.assertTrue(self._is_matching(host, "platform/ios-wk2/imported/w3c/web-platform-tests/url/interfaces-expected.txt", "j")) # removal of mac-wk1 expectation since no longer different self.assertFalse(self._exists(host, "platform/mac-wk1/imported/w3c/web-platform-tests/fetch/api/redirect/redirect-location-expected.txt"))
def __init__(self): AbstractReviewQueue.__init__(self, host=MockHost())
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_issue_number(self): host = MockHost() host.executive = MockExecutive(output='Issue number: 12345 (http://crrev.com/12345)') git_cl = GitCL(host) self.assertEqual(git_cl.get_issue_number(), '12345')