def test_get_directory_owners(self): host = MockHost() host.filesystem.write_text_file('/mock-checkout/third_party/WebKit/LayoutTests/W3CImportExpectations', '') host.filesystem.write_text_file('/mock-checkout/third_party/WebKit/LayoutTests/external/wpt/foo/OWNERS', '[email protected]\n') git = MockGit(filesystem=host.filesystem, executive=host.executive, platform=host.platform) git.changed_files = lambda: ['third_party/WebKit/LayoutTests/external/wpt/foo/x.html'] host.git = lambda: git importer = TestImporter(host) self.assertEqual(importer.get_directory_owners(), {('*****@*****.**',): ['external/wpt/foo']})
def git(self, path=None): if path: return MockGit(cwd=path, filesystem=self.filesystem, executive=self.executive) if not self._git: self._git = MockGit(filesystem=self.filesystem, executive=self.executive) # Various pieces of code (wrongly) call filesystem.chdir(checkout_root). # Making the checkout_root exist in the mock filesystem makes that chdir not raise. self.filesystem.maybe_make_directory(self._git.checkout_root) return self._git
def test_more_failures_in_baseline_same_fails(self): executive = mock_git_commands({ 'diff': ('diff --git a/foo-expected.txt b/foo-expected.txt\n' '--- a/foo-expected.txt\n' '+++ b/foo-expected.txt\n' '-FAIL an old failure\n' '+FAIL a new failure\n') }) self.notifier.git = MockGit(executive=executive) self.assertFalse( self.notifier.more_failures_in_baseline('foo-expected.txt'))
def test_more_failures_in_baseline_more_fails(self): # Replacing self.host.executive won't work here, because ImportNotifier # has been instantiated with a MockGit backed by an empty MockExecutive. executive = mock_git_commands({ 'diff': ('diff --git a/foo-expected.txt b/foo-expected.txt\n' '--- a/foo-expected.txt\n' '+++ b/foo-expected.txt\n' '-FAIL an old failure\n' '+FAIL new failure 1\n' '+FAIL new failure 2\n') }) self.notifier.git = MockGit(executive=executive) self.assertTrue( self.notifier.more_failures_in_baseline('foo-expected.txt')) self.assertEqual( executive.calls, [['git', 'diff', '-U0', 'origin/master', '--', 'foo-expected.txt'] ])
def test_apply_exportable_commits_locally(self): # TODO(robertma): Consider using MockLocalWPT. host = MockHost() importer = TestImporter(host, wpt_github=MockWPTGitHub(pull_requests=[])) importer.wpt_git = MockGit(cwd='/tmp/wpt', executive=host.executive) fake_commit = MockChromiumCommit( host, subject='My fake commit', patch= ('Fake patch contents...\n' '--- a/third_party/WebKit/LayoutTests/external/wpt/css/css-ui-3/outline-004.html\n' '+++ b/third_party/WebKit/LayoutTests/external/wpt/css/css-ui-3/outline-004.html\n' '@@ -20,7 +20,7 @@\n' '...')) importer.exportable_but_not_exported_commits = lambda _: [fake_commit] applied = importer.apply_exportable_commits_locally(LocalWPT(host)) self.assertEqual(applied, [fake_commit]) # This assertion is implementation details of LocalWPT.apply_patch. # TODO(robertma): Move this to local_wpt_unittest.py. self.assertEqual(host.executive.full_calls, [ MockCall( ['git', 'apply', '-'], { 'input': ('Fake patch contents...\n' '--- a/css/css-ui-3/outline-004.html\n' '+++ b/css/css-ui-3/outline-004.html\n' '@@ -20,7 +20,7 @@\n' '...'), 'cwd': '/tmp/wpt', 'env': None }), MockCall(['git', 'add', '.'], kwargs={ 'input': None, 'cwd': '/tmp/wpt', 'env': None }) ]) self.assertEqual( importer.wpt_git.local_commits(), [['Applying patch 14fd77e88e42147c57935c49d9e3b2412b8491b7']])
def setUp(self): BaseTestCase.setUp(self) LoggingTestCase.setUp(self) builds = [ Build('MOCK Try Win', 5000), Build('MOCK Try Mac', 4000), Build('MOCK Try Linux', 6000), ] git_cl = GitCL(self.tool) git_cl.get_issue_number = lambda: '11112222' git_cl.latest_try_jobs = lambda _: builds self.command.git_cl = lambda: git_cl git = MockGit(filesystem=self.tool.filesystem, executive=self.tool.executive) git.changed_files = lambda **_: [ 'third_party/WebKit/LayoutTests/fast/dom/prototype-inheritance.html', 'third_party/WebKit/LayoutTests/fast/dom/prototype-taco.html', ] self.tool.git = lambda: git self.tool.builders = BuilderList({ 'MOCK Try Win': { 'port_name': 'test-win-win7', 'specifiers': ['Win7', 'Release'], 'is_try_builder': True, }, 'MOCK Try Linux': { 'port_name': 'test-linux-trusty', 'specifiers': ['Trusty', 'Release'], 'is_try_builder': True, }, 'MOCK Try Mac': { 'port_name': 'test-mac-mac10.11', 'specifiers': ['Mac10.11', 'Release'], 'is_try_builder': True, }, }) layout_test_results = LayoutTestResults({ 'tests': { 'fast': { 'dom': { 'prototype-inheritance.html': { 'expected': 'PASS', 'actual': 'TEXT', 'is_unexpected': True, }, 'prototype-banana.html': { 'expected': 'FAIL', 'actual': 'PASS', 'is_unexpected': True, }, 'prototype-taco.html': { 'expected': 'PASS', 'actual': 'PASS TEXT', 'is_unexpected': True, }, 'prototype-chocolate.html': { 'expected': 'FAIL', 'actual': 'IMAGE+TEXT' }, 'prototype-crashy.html': { 'expected': 'PASS', 'actual': 'CRASH', 'is_unexpected': True, }, 'prototype-newtest.html': { 'expected': 'PASS', 'actual': 'MISSING', 'is_unexpected': True, 'is_missing_text': True, }, 'prototype-slowtest.html': { 'expected': 'SLOW', 'actual': 'TEXT', 'is_unexpected': True, }, } }, 'svg': { 'dynamic-updates': { 'SVGFEDropShadowElement-dom-stdDeviation-attr.html': { 'expected': 'PASS', 'actual': 'IMAGE', 'has_stderr': True, 'is_unexpected': True, } } } } }) for build in builds: self.tool.buildbot.set_results(build, layout_test_results) self.tool.buildbot.set_retry_sumary_json( build, json.dumps({ 'failures': [ 'fast/dom/prototype-inheritance.html', 'fast/dom/prototype-newtest.html', 'fast/dom/prototype-slowtest.html', 'fast/dom/prototype-taco.html', 'svg/dynamic-updates/SVGFEDropShadowElement-dom-stdDeviation-attr.html', ], 'ignored': [], })) # Write to the mock filesystem so that these tests are considered to exist. tests = [ 'fast/dom/prototype-taco.html', 'fast/dom/prototype-inheritance.html', 'fast/dom/prototype-newtest.html', 'svg/dynamic-updates/SVGFEDropShadowElement-dom-stdDeviation-attr.html', ] for test in tests: self._write( self.mac_port.host.filesystem.join( self.mac_port.layout_tests_dir(), test), 'contents')
def setUp(self): BaseTestCase.setUp(self) LoggingTestCase.setUp(self) builds = { Build('MOCK Try Win', 5000): TryJobStatus('COMPLETED', 'FAILURE'), Build('MOCK Try Mac', 4000): TryJobStatus('COMPLETED', 'FAILURE'), Build('MOCK Try Linux', 6000): TryJobStatus('COMPLETED', 'FAILURE'), } self.command.git_cl = MockGitCL(self.tool, builds) git = MockGit(filesystem=self.tool.filesystem, executive=self.tool.executive) git.changed_files = lambda **_: [ 'third_party/WebKit/LayoutTests/one/text-fail.html', 'third_party/WebKit/LayoutTests/one/flaky-fail.html', ] self.tool.git = lambda: git self.tool.builders = BuilderList({ 'MOCK Try Win': { 'port_name': 'test-win-win7', 'specifiers': ['Win7', 'Release'], 'is_try_builder': True, }, 'MOCK Try Linux': { 'port_name': 'test-linux-trusty', 'specifiers': ['Trusty', 'Release'], 'is_try_builder': True, }, 'MOCK Try Mac': { 'port_name': 'test-mac-mac10.11', 'specifiers': ['Mac10.11', 'Release'], 'is_try_builder': True, }, }) layout_test_results = LayoutTestResults({ 'tests': { 'one': { 'crash.html': { 'expected': 'PASS', 'actual': 'CRASH', 'is_unexpected': True }, 'expected-fail.html': { 'expected': 'FAIL', 'actual': 'IMAGE+TEXT' }, 'flaky-fail.html': { 'expected': 'PASS', 'actual': 'PASS TEXT', 'is_unexpected': True }, 'missing.html': { 'expected': 'PASS', 'actual': 'MISSING', 'is_unexpected': True }, 'slow-fail.html': { 'expected': 'SLOW', 'actual': 'TEXT', 'is_unexpected': True }, 'text-fail.html': { 'expected': 'PASS', 'actual': 'TEXT', 'is_unexpected': True }, 'unexpected-pass.html': { 'expected': 'FAIL', 'actual': 'PASS', 'is_unexpected': True }, }, 'two': { 'image-fail.html': { 'expected': 'PASS', 'actual': 'IMAGE', 'is_unexpected': True } }, }, }) for build in builds: self.tool.buildbot.set_results(build, layout_test_results) self.tool.buildbot.set_retry_sumary_json( build, json.dumps({ 'failures': [ 'one/flaky-fail.html', 'one/missing.html', 'one/slow-fail.html', 'one/text-fail.html', 'two/image-fail.html', ], 'ignored': [], })) # Write to the mock filesystem so that these tests are considered to exist. tests = [ 'one/flaky-fail.html', 'one/missing.html', 'one/slow-fail.html', 'one/text-fail.html', 'two/image-fail.html', ] for test in tests: path = self.mac_port.host.filesystem.join( self.mac_port.layout_tests_dir(), test) self._write(path, 'contents') self.mac_port.host.filesystem.write_text_file( '/test.checkout/LayoutTests/external/wpt/MANIFEST.json', '{}')