def __init__(self, log_executive=False, executive_throws_when_run=None, initialize_scm_by_default=True, web=None, scm=None, os_name=None, os_version=None): MockSystemHost.__init__(self, log_executive, executive_throws_when_run, os_name=os_name, os_version=os_version) add_unit_tests_to_mock_filesystem(self.filesystem) self.web = web or MockWeb() self._scm = scm # FIXME: we should never initialize the SCM by default, since the real # object doesn't either. This has caused at least one bug (see bug 89498). if initialize_scm_by_default: self.initialize_scm() self.buildbot = MockBuildBot() # Note: We're using a real PortFactory here. Tests which don't wish to depend # on the list of known ports should override this with a MockPortFactory. self.port_factory = PortFactory(self) self.builders = Builders()
def setUp(self): BaseTestCase.setUp(self) LoggingTestCase.setUp(self) web = MockWeb(urls={ 'https://codereview.chromium.org/api/11112222': json.dumps({ 'patchsets': [1, 2], }), 'https://codereview.chromium.org/api/11112222/2': json.dumps({ 'try_job_results': [ { 'builder': 'MOCK Try Win', 'buildnumber': 5000, 'result': 0, }, { 'builder': 'MOCK Try Mac', 'buildnumber': 4000, 'result': 0, }, ], 'files': { 'third_party/WebKit/LayoutTests/fast/dom/prototype-inheritance.html': {'status': 'M'}, 'third_party/WebKit/LayoutTests/fast/dom/prototype-taco.html': {'status': 'M'}, }, }), }) 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-mac-mac10.10", "specifiers": ["Mac10.10", "Release"], "is_try_builder": True, }, }) self.command.rietveld = Rietveld(web) self.tool.buildbot.set_retry_sumary_json(Build('MOCK Try Win', 5000), json.dumps({ 'failures': [ 'fast/dom/prototype-newtest.html', 'fast/dom/prototype-taco.html', 'fast/dom/prototype-inheritance.html', 'svg/dynamic-updates/SVGFEDropShadowElement-dom-stdDeviation-attr.html', ], 'ignored': [], })) # Write to the mock filesystem so that these tests are considered to exist. port = self.mac_port 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(port.host.filesystem.join(port.layout_tests_dir(), test), 'contents')
def __init__(self, log_executive=False, initialize_scm_by_default=True, web=None, scm=None, os_name=None, os_version=None, time_return_val=123): super(MockHost, self).__init__(log_executive=log_executive, os_name=os_name, os_version=os_version, time_return_val=time_return_val) add_unit_tests_to_mock_filesystem(self.filesystem) self.web = web or MockWeb() self._scm = scm # TODO(qyearsley): we should never initialize the SCM by default, since # the real object doesn't either. This has caused at least one bug # (see bug 89498). if initialize_scm_by_default: self.initialize_scm() self.buildbot = MockBuildBot() # Note: We're using a real PortFactory here. Tests which don't wish to depend # on the list of known ports should override this with a MockPortFactory. self.port_factory = PortFactory(self) self.builders = BuilderList(BUILDERS)
def __init__(self, log_executive=False, executive_throws_when_run=None, initialize_scm_by_default=True, web=None, create_stub_repository_files=False): MockSystemHost.__init__(self, log_executive, executive_throws_when_run) add_unit_tests_to_mock_filesystem(self.filesystem) if create_stub_repository_files: add_checkout_information_json_to_mock_filesystem(self.filesystem) self.web = web or MockWeb() self._checkout = MockCheckout() self._scm = None # FIXME: we should never initialize the SCM by default, since the real # object doesn't either. This has caused at least one bug (see bug 89498). if initialize_scm_by_default: self.initialize_scm() self.bugs = MockBugzilla() self.buildbot = MockBuildBot() # Note: We're using a real PortFactory here. Tests which don't wish to depend # on the list of known ports should override this with a MockPortFactory. self.port_factory = PortFactory(self) self._watch_list = MockWatchList()
def mock_web(self): return MockWeb( urls={ 'https://codereview.chromium.org/api/11112222': json.dumps({ 'patchsets': [1, 2, 3], }), 'https://codereview.chromium.org/api/11112222/2': json.dumps({ 'try_job_results': [ { 'builder': 'foo-builder', 'buildnumber': None, 'result': -1 }, { 'builder': 'bar-builder', 'buildnumber': 50, 'result': 0 }, ], }), 'https://codereview.chromium.org/api/11112222/3': json.dumps({ 'try_job_results': [ { 'builder': 'foo-builder', 'buildnumber': 20, 'result': 1 }, { 'builder': 'bar-builder', 'buildnumber': 60, 'result': 0 }, ], 'files': { 'some/path/foo.cc': { 'status': 'M' }, 'some/path/bar.html': { 'status': 'M' }, 'some/path/deleted.html': { 'status': 'D' }, } }), 'https://codereview.chromium.org/api/11113333': 'my non-JSON contents', })
def __init__(self, log_executive=False, web=None, git=None, os_name=None, os_version=None, time_return_val=123): super(MockHost, self).__init__(log_executive=log_executive, os_name=os_name, os_version=os_version, time_return_val=time_return_val) add_unit_tests_to_mock_filesystem(self.filesystem) self._add_base_manifest_to_mock_filesystem(self.filesystem) self.web = web or MockWeb() self._git = git self.buildbot = MockBuildBot() # Note: We're using a real PortFactory here. Tests which don't wish to depend # on the list of known ports should override this with a MockPortFactory. self.port_factory = PortFactory(self) self.builders = BuilderList({ 'Fake Test Win10': { 'port_name': 'win-win10', 'specifiers': ['Win10', 'Release'] }, 'Fake Test Linux': { 'port_name': 'linux-trusty', 'specifiers': ['Trusty', 'Release'] }, 'Fake Test Linux (dbg)': { 'port_name': 'linux-trusty', 'specifiers': ['Trusty', 'Debug'] }, 'Fake Test Mac10.12': { 'port_name': 'mac-mac10.12', 'specifiers': ['Mac10.12', 'Release'] }, 'Fake Test Linux Try Bot': { 'port_name': 'linux-trusty', 'specifiers': ['Trusty', 'Release'], 'is_try_builder': True, }, })
def test_run_no_try_results(self): self.host.web = MockWeb( urls={ 'https://codereview.chromium.org/api/11112222': json.dumps({ 'patchsets': [1], }), 'https://codereview.chromium.org/api/11112222/1': json.dumps({'try_job_results': []}) }) line_adder = W3CExpectationsLineAdder(self.host) line_adder.get_issue_number = lambda: '11112222' line_adder.get_try_bots = lambda: ['test-builder-name'] self.assertEqual(1, line_adder.run(args=[])) self.assertEqual(self.host.web.urls_fetched, [ 'https://codereview.chromium.org/api/11112222', 'https://codereview.chromium.org/api/11112222/1' ]) self.assertLog(['ERROR: No try job information was collected.\n'])
def setUp(self): super(RebaselineFromTryJobsTest, self).setUp() self.command.web = MockWeb( urls={ 'https://codereview.chromium.org/api/11112222': json.dumps({ 'patchsets': [1, 2], }), 'https://codereview.chromium.org/api/11112222/2': json.dumps({ 'try_job_results': [ { 'builder': 'win_chromium_rel_ng', 'master': 'tryserver.chromium.win', 'buildnumber': 5000, }, ], }), })
def __init__(self, log_executive=False, executive_throws_when_run=None): MockSystemHost.__init__(self, log_executive, executive_throws_when_run) add_unit_tests_to_mock_filesystem(self.filesystem) self.web = MockWeb() self._checkout = MockCheckout() self._scm = MockSCM(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._scm.checkout_root) self.bugs = MockBugzilla() self.buildbot = MockBuildBot() self._chromium_buildbot = MockBuildBot() # Note: We're using a real PortFactory here. Tests which don't wish to depend # on the list of known ports should override this with a MockPortFactory. self.port_factory = PortFactory(self) self._watch_list = MockWatchList()
def test_sheriffs(self): sheriffs = Sheriffs() tool = MockTool(web=MockWeb({ "test_0": "document.write('');", "test_1": "document.write('test_user');", "test_2": "document.write('test_user_1, test_user_2');", "test_malformed": "malformed", })) self.assertEqual( "tom: There are no Chromium Webkit sheriffs currently assigned.", sheriffs.execute("tom", ["test_0"], tool, None)) self.assertEqual( "tom: The current Chromium Webkit sheriff is: test_user", sheriffs.execute("tom", ["test_1"], tool, None)) self.assertEqual( "tom: The current Chromium Webkit sheriffs are: test_user_1, test_user_2", sheriffs.execute("tom", ["test_2"], tool, None)) self.assertEqual( "tom: Failed to parse URL: test_malformed", sheriffs.execute("tom", ["test_malformed"], tool, None)) self.assertEqual("tom: Failed to parse URL: invalid", sheriffs.execute("tom", ["invalid"], tool, None))
def setUp(self): self.web = MockWeb(urls={ 'https://codereview.chromium.org/api/11112222': json.dumps({ 'patchsets': [1, 2, 3], }), 'https://codereview.chromium.org/api/11112222/2': json.dumps({ 'try_job_results': [ { 'builder': 'foo-builder', 'master': 'master.tryserver.foo', 'buildnumber': 10, 'result': -1 }, { 'builder': 'bar-builder', 'master': 'master.tryserver.bar', 'buildnumber': 50, 'results': 0 }, ], }), 'https://codereview.chromium.org/api/11112222/3': json.dumps({ 'try_job_results': [ { 'builder': 'foo-builder', 'master': 'master.tryserver.foo', 'buildnumber': 20, 'result': 1 }, { 'builder': 'bar-builder', 'master': 'master.tryserver.bar', 'buildnumber': 60, 'result': 0 }, ], }), 'https://codereview.chromium.org/api/11113333': 'my non-JSON contents', })
def __init__(self, log_executive=False, web=None, git=None, os_name=None, os_version=None, time_return_val=123): super(MockHost, self).__init__(log_executive=log_executive, os_name=os_name, os_version=os_version, time_return_val=time_return_val) add_unit_tests_to_mock_filesystem(self.filesystem) self._add_base_manifest_to_mock_filesystem(self.filesystem) self.web = web or MockWeb() self._git = git self.buildbot = MockBuildBot() # Note: We're using a real PortFactory here. Tests which don't wish to depend # on the list of known ports should override this with a MockPortFactory. self.port_factory = PortFactory(self) self.builders = BuilderList(BUILDERS)
def setUp(self): BaseTestCase.setUp(self) LoggingTestCase.setUp(self) web = MockWeb(urls={ 'https://codereview.chromium.org/api/11112222': json.dumps({ 'patchsets': [1, 2], }), 'https://codereview.chromium.org/api/11112222/2': json.dumps({ 'try_job_results': [ { 'builder': 'MOCK Try Win', 'buildnumber': 5000, 'result': 0, }, { 'builder': 'MOCK Try Mac', 'buildnumber': 4000, 'result': 0, }, ], 'files': { 'third_party/WebKit/LayoutTests/fast/dom/prototype-inheritance.html': {'status': 'M'}, 'third_party/WebKit/LayoutTests/fast/dom/prototype-taco.html': {'status': 'M'}, }, }), }) 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, }, }) self.command.rietveld = Rietveld(web) 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 [Build('MOCK Try Win', 5000), Build('MOCK Try Mac', 4000)]: self.tool.buildbot.set_results(build, layout_test_results) self.tool.buildbot.set_retry_sumary_json(Build('MOCK Try Win', 5000), 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. port = self.mac_port 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(port.host.filesystem.join(port.layout_tests_dir(), test), 'contents')