Example #1
0
 def test_update_test_expectations(self):
     host = MockHost()
     host.filesystem.files[
         '/mock-checkout/third_party/WebKit/LayoutTests/TestExpectations'] = (
             'Bug(test) some/test/a.html [ Failure ]\n'
             'Bug(test) some/test/b.html [ Failure ]\n'
             'Bug(test) some/test/c.html [ Failure ]\n')
     host.filesystem.files[
         '/mock-checkout/third_party/WebKit/LayoutTests/VirtualTestSuites'] = '[]'
     host.filesystem.files[
         '/mock-checkout/third_party/WebKit/LayoutTests/new/a.html'] = ''
     host.filesystem.files[
         '/mock-checkout/third_party/WebKit/LayoutTests/new/b.html'] = ''
     updater = DepsUpdater(host)
     deleted_tests = ['some/test/b.html']
     renamed_test_pairs = {
         'some/test/a.html': 'new/a.html',
         'some/test/c.html': 'new/c.html',
     }
     updater.update_all_test_expectations_files(deleted_tests,
                                                renamed_test_pairs)
     self.assertMultiLineEqual(
         host.filesystem.read_text_file(
             '/mock-checkout/third_party/WebKit/LayoutTests/TestExpectations'
         ), ('Bug(test) new/a.html [ Failure ]\n'
             'Bug(test) new/c.html [ Failure ]\n'))
 def test_commit_changes(self):
     host = MockHost()
     updater = DepsUpdater(host)
     updater._has_changes = lambda: True
     updater._commit_changes('dummy message')
     self.assertEqual(host.executive.calls,
                      [['git', 'commit', '--all', '-F', '-']])
Example #3
0
 def test_is_manual_test_no_automation_file(self):
     updater = DepsUpdater(MockHost())
     fs = MockFileSystem()
     dirname = '/mock-checkout/third_party/WebKit/LayoutTests/imported/wpt/a'
     self.assertTrue(updater.is_manual_test(fs, dirname, 'test-manual.html'))
     self.assertTrue(updater.is_manual_test(fs, dirname, 'test-manual.htm'))
     self.assertTrue(updater.is_manual_test(fs, dirname, 'test-manual.xht'))
Example #4
0
 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"]])
Example #5
0
 def test_is_manual_test_with_corresponding_automation_file(self):
     updater = DepsUpdater(MockHost())
     imported_dir = '/mock-checkout/third_party/WebKit/LayoutTests/imported/'
     fs = MockFileSystem(files={
         imported_dir + 'wpt_automation/a/x-manual-input.js': '',
         imported_dir + 'wpt_automation/a/y-manual-automation.js': '',
     })
     self.assertTrue(updater.is_manual_test(fs, imported_dir + 'wpt/a', 'x-manual.html'))
     self.assertFalse(updater.is_manual_test(fs, imported_dir + 'wpt/a', 'y-manual.html'))
 def test_generate_manifest_command_not_found(self):
     # If we're updating csswg-test, then the manifest file won't be found.
     host = MockHost()
     host.filesystem.files = {}
     updater = DepsUpdater(host)
     updater._generate_manifest(
         '/mock-checkout/third_party/WebKit/LayoutTests/external/csswg-test'
     )
     self.assertEqual(host.executive.calls, [])
Example #7
0
 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]'))
     self.assertEqual(host.executive.calls,
                      [['git', 'log', '-1', '--format=%B']])
Example #8
0
 def test_parse_directory_owners(self):
     updater = DepsUpdater(MockHost())
     data_file = [
         {'notification-email': '*****@*****.**', 'directory': 'foo/bar'},
         {'notification-email': '*****@*****.**', 'directory': 'foo/baz'},
         {'notification-email': '', 'directory': 'gol/bat'},
     ]
     self.assertEqual(
         updater.parse_directory_owners(data_file),
         {'foo/bar': '*****@*****.**', 'foo/baz': '*****@*****.**'})
Example #9
0
 def test_parse_directory_owners(self):
     updater = DepsUpdater(MockHost())
     data_file = [
         {'notification-email': '*****@*****.**', 'directory': 'foo/bar'},
         {'notification-email': '*****@*****.**', 'directory': 'foo/baz'},
         {'notification-email': '', 'directory': 'gol/bat'},
     ]
     self.assertEqual(
         updater.parse_directory_owners(data_file),
         {'foo/bar': '*****@*****.**', 'foo/baz': '*****@*****.**'})
Example #10
0
 def test_parse_directory_owners(self):
     updater = DepsUpdater(MockHost())
     data_file = [
         {"notification-email": "*****@*****.**", "directory": "foo/bar"},
         {"notification-email": "*****@*****.**", "directory": "foo/baz"},
         {"notification-email": "", "directory": "gol/bat"},
     ]
     self.assertEqual(
         updater.parse_directory_owners(data_file),
         {"foo/bar": "*****@*****.**", "foo/baz": "*****@*****.**"},
     )
Example #11
0
 def test_generate_email_list(self):
     updater = DepsUpdater(MockHost())
     changed_files = [
         "third_party/WebKit/LayoutTests/foo/bar/file.html",
         "third_party/WebKit/LayoutTests/foo/bar/otherfile.html",
         "third_party/WebKit/LayoutTests/foo/baz/files.html",
         "some/non-test.file",
     ]
     directory_to_owner = {"foo/bar": "*****@*****.**", "foo/baz": "*****@*****.**", "foo/bat": "*****@*****.**"}
     self.assertEqual(
         updater.generate_email_list(changed_files, directory_to_owner), ["*****@*****.**", "*****@*****.**"]
     )
Example #12
0
 def test_cl_description_with_environ_variables(self):
     host = MockHost()
     host.executive = MockExecutive2(output='Last commit message\n')
     updater = DepsUpdater(host)
     updater.host.environ['BUILDBOT_MASTERNAME'] = 'my.master'
     updater.host.environ['BUILDBOT_BUILDERNAME'] = 'b'
     updater.host.environ['BUILDBOT_BUILDNUMBER'] = '123'
     description = updater._cl_description()
     self.assertEqual(description, (
         'Last commit message\n'
         'Build: https://build.chromium.org/p/my.master/builders/b/builds/123\n\n'
         '[email protected]'))
     self.assertEqual(host.executive.calls,
                      [['git', 'log', '-1', '--format=%B']])
Example #13
0
    def _has_expectations(self, chromium_commit):
        files = self.host.executive.run_command([
            'git', 'diff-tree', '--no-commit-id',
            '--name-only', '-r', chromium_commit
        ]).splitlines()

        return any(DepsUpdater.is_baseline(f) for f in files)
Example #14
0
 def test_generate_email_list(self):
     updater = DepsUpdater(MockHost())
     changed_files = [
         'third_party/WebKit/LayoutTests/foo/bar/file.html',
         'third_party/WebKit/LayoutTests/foo/bar/otherfile.html',
         'third_party/WebKit/LayoutTests/foo/baz/files.html',
         'some/non-test.file',
     ]
     directory_to_owner = {
         'foo/bar': '*****@*****.**',
         'foo/baz': '*****@*****.**',
         'foo/bat': '*****@*****.**',
     }
     self.assertEqual(
         updater.generate_email_list(changed_files, directory_to_owner),
         ['*****@*****.**', '*****@*****.**'])
Example #15
0
 def test_generate_email_list(self):
     updater = DepsUpdater(MockHost())
     changed_files = [
         'third_party/WebKit/LayoutTests/foo/bar/file.html',
         'third_party/WebKit/LayoutTests/foo/bar/otherfile.html',
         'third_party/WebKit/LayoutTests/foo/baz/files.html',
         'some/non-test.file',
     ]
     directory_to_owner = {
         'foo/bar': '*****@*****.**',
         'foo/baz': '*****@*****.**',
         'foo/bat': '*****@*****.**',
     }
     self.assertEqual(
         updater.generate_email_list(changed_files, directory_to_owner),
         ['*****@*****.**', '*****@*****.**'])
    def _has_expectations(self, chromium_commit):
        files = self.host.executive.run_command([
            'git', 'diff-tree', '--no-commit-id', '--name-only', '-r',
            chromium_commit
        ]).splitlines()

        return any(DepsUpdater.is_baseline(f) for f in files)
 def test_generate_manifest_successful_run(self):
     # This test doesn't test any aspect of the real manifest script, it just
     # asserts that DepsUpdater._generate_manifest would invoke the script.
     host = MockHost()
     updater = DepsUpdater(host)
     updater._generate_manifest(
         '/mock-checkout/third_party/WebKit/LayoutTests/external/wpt')
     self.assertEqual(host.executive.calls, [
         [
             '/mock-checkout/third_party/WebKit/Tools/Scripts/webkitpy/thirdparty/wpt/wpt/manifest',
             '--work', '--tests-root',
             '/mock-checkout/third_party/WebKit/LayoutTests/external/wpt'
         ],
         [
             'git', 'add',
             '/mock-checkout/third_party/WebKit/LayoutTests/external/wpt/MANIFEST.json'
         ]
     ])
Example #18
0
 def test_update_test_expectations(self):
     host = MockHost()
     host.filesystem.files["/mock-checkout/third_party/WebKit/LayoutTests/TestExpectations"] = (
         "Bug(test) some/test/a.html [ Failure ]\n"
         "Bug(test) some/test/b.html [ Failure ]\n"
         "Bug(test) some/test/c.html [ Failure ]\n"
     )
     host.filesystem.files["/mock-checkout/third_party/WebKit/LayoutTests/VirtualTestSuites"] = "[]"
     host.filesystem.files["/mock-checkout/third_party/WebKit/LayoutTests/new/a.html"] = ""
     host.filesystem.files["/mock-checkout/third_party/WebKit/LayoutTests/new/b.html"] = ""
     updater = DepsUpdater(host)
     deleted_tests = ["some/test/b.html"]
     renamed_test_pairs = {"some/test/a.html": "new/a.html", "some/test/c.html": "new/c.html"}
     updater.update_all_test_expectations_files(deleted_tests, renamed_test_pairs)
     self.assertMultiLineEqual(
         host.filesystem.read_text_file("/mock-checkout/third_party/WebKit/LayoutTests/TestExpectations"),
         ("Bug(test) new/a.html [ Failure ]\n" "Bug(test) new/c.html [ Failure ]\n"),
     )
Example #19
0
 def test_cl_description_with_environ_variables(self):
     host = MockHost()
     host.executive = MockExecutive2(output="Last commit message\n")
     updater = DepsUpdater(host)
     updater.host.environ["BUILDBOT_MASTERNAME"] = "my.master"
     updater.host.environ["BUILDBOT_BUILDERNAME"] = "b"
     updater.host.environ["BUILDBOT_BUILDNUMBER"] = "123"
     description = updater._cl_description()
     self.assertEqual(
         description,
         (
             "Last commit message\n"
             "Build: https://build.chromium.org/p/my.master/builders/b/builds/123\n\n"
             "[email protected]\n"
             "NOEXPORT=true"
         ),
     )
     self.assertEqual(host.executive.calls, [["git", "log", "-1", "--format=%B"]])
Example #20
0
 def test_update_test_expectations(self):
     host = MockHost()
     host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/TestExpectations'] = (
         'Bug(test) some/test/a.html [ Failure ]\n'
         'Bug(test) some/test/b.html [ Failure ]\n'
         'Bug(test) some/test/c.html [ Failure ]\n')
     host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/VirtualTestSuites'] = '[]'
     host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/new/a.html'] = ''
     host.filesystem.files['/mock-checkout/third_party/WebKit/LayoutTests/new/b.html'] = ''
     updater = DepsUpdater(host)
     deleted_tests = ['some/test/b.html']
     renamed_test_pairs = {
         'some/test/a.html': 'new/a.html',
         'some/test/c.html': 'new/c.html',
     }
     updater.update_all_test_expectations_files(deleted_tests, renamed_test_pairs)
     self.assertMultiLineEqual(
         host.filesystem.read_text_file('/mock-checkout/third_party/WebKit/LayoutTests/TestExpectations'),
         ('Bug(test) new/a.html [ Failure ]\n'
          'Bug(test) new/c.html [ Failure ]\n'))
Example #21
0
 def test_is_manual_test_regular_test(self):
     # TODO(qyearsley): Refactor these tests to re-use the MockFileSystem from the MockHost.
     updater = DepsUpdater(MockHost())
     fs = MockFileSystem()
     dirname = '/mock-checkout/third_party/WebKit/LayoutTests/imported/wpt/a'
     self.assertFalse(updater.is_manual_test(fs, dirname, 'test.html'))
     self.assertFalse(updater.is_manual_test(fs, dirname, 'manual-foo.htm'))
     self.assertFalse(updater.is_manual_test(fs, dirname, 'script.js'))
     self.assertFalse(updater.is_manual_test(fs, dirname, 'foo'))
 def test_commit_message(self):
     updater = DepsUpdater(MockHost())
     self.assertEqual(
         updater._commit_message('aaaa', '1111'),
         'Import 1111\n\nUsing update-w3c-deps in Chromium aaaa.\n\n')