示例#1
0
    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_ref_test_with_ref_is_copied(self):
     host = MockHost()
     host.filesystem = MockFileSystem(
         files={
             '/blink/w3c/dir1/my-ref-test.html':
             b'<html><head><link rel="match" href="ref-file.html" />test</head></html>',
             '/blink/w3c/dir1/ref-file.html':
             b'<html><head>test</head></html>',
             MOCK_WEB_TESTS + 'W3CImportExpectations': b'',
         })
     copier = TestCopier(host, FAKE_SOURCE_REPO_DIR)
     copier.find_importable_tests()
     self.assertEqual(len(copier.import_list), 1)
     # The order of copy_list depends on the implementation of
     # filesystem.walk, so don't check the order
     if six.PY3:
         self.assertCountEqual(
             copier.import_list[0]['copy_list'], [{
                 'src': '/blink/w3c/dir1/ref-file.html',
                 'dest': 'ref-file.html'
             }, {
                 'src': '/blink/w3c/dir1/my-ref-test.html',
                 'dest': 'my-ref-test.html'
             }])
     else:
         self.assertItemsEqual(
             copier.import_list[0]['copy_list'], [{
                 'src': '/blink/w3c/dir1/ref-file.html',
                 'dest': 'ref-file.html'
             }, {
                 'src': '/blink/w3c/dir1/my-ref-test.html',
                 'dest': 'my-ref-test.html'
             }])
     self.assertEqual(copier.import_list[0]['dirname'], '/blink/w3c/dir1')
 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_WEB_TESTS + 'W3CImportExpectations':
             '',
         })
     copier = TestCopier(host, FAKE_SOURCE_REPO_DIR)
     copier.find_importable_tests()
     self.assertEqual(copier.import_list, [{
         'copy_list': [{
             'src': '/blink/w3c/dir1/ref-file.html',
             'dest': 'ref-file.html'
         },
                       {
                           'src': '/blink/w3c/dir1/my-ref-test.html',
                           'dest': 'my-ref-test.html'
                       }],
         'dirname':
         '/blink/w3c/dir1',
     }])
 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_files_with_shebang_are_made_executable(self):
     host = MockHost()
     host.filesystem = MockFileSystem(files=FAKE_FILES)
     copier = TestCopier(host, FAKE_SOURCE_REPO_DIR)
     copier.do_import()
     self.assertEqual(
         host.filesystem.executable_files,
         set([MOCK_WEB_TESTS + 'external/blink/w3c/dir/has_shebang.txt']))
示例#6
0
 def test_files_with_shebang_are_made_executable(self):
     host = MockHost()
     host.filesystem = MockFileSystem(files=FAKE_FILES)
     copier = TestCopier(host, FAKE_SOURCE_REPO_DIR)
     copier.do_import()
     self.assertEqual(
         host.filesystem.executable_files,
         set([
             '/mock-checkout/third_party/WebKit/LayoutTests/external/blink/w3c/dir/has_shebang.txt'
         ]))
 def test_executable_files(self):
     # Files with shebangs or .bat files need to be made executable.
     host = MockHost()
     host.filesystem = MockFileSystem(files=FAKE_FILES)
     copier = TestCopier(host, FAKE_SOURCE_REPO_DIR)
     copier.do_import()
     self.assertEqual(
         host.filesystem.executable_files, {
             MOCK_WEB_TESTS + 'external/blink/w3c/dir/run.bat',
             MOCK_WEB_TESTS + 'external/blink/w3c/dir/has_shebang.txt'
         })
示例#8
0
    def test_fetch_when_wpt_dir_exists(self):
        host = MockHost()
        host.filesystem = MockFileSystem(files={'/tmp/wpt': ''})

        local_wpt = LocalWPT(host, 'token')
        local_wpt.fetch()

        self.assertEqual(host.executive.calls, [
            ['git', 'fetch', 'origin'],
            ['git', 'reset', '--hard', 'origin/master'],
        ])
示例#9
0
 def test_does_not_import_reftestlist_file(self):
     host = MockHost()
     host.filesystem = MockFileSystem(files=FAKE_FILES)
     copier = TestCopier(host, FAKE_SOURCE_REPO_DIR)
     copier.find_importable_tests()
     self.assertEqual(copier.import_list, [{
         'copy_list': [{
             'dest': 'has_shebang.txt',
             'src': '/blink/w3c/dir/has_shebang.txt'
         }, {
             'dest': 'README.txt',
             'src': '/blink/w3c/dir/README.txt'
         }],
         'dirname':
         '/blink/w3c/dir',
     }])
 def test_filesystem_walk_deeply_nested(self):
     mock_dir = 'foo'
     mock_files = {
         'foo/bar/baz': '',
         'foo/bar/quux': '',
         'foo/a/x': '',
         'foo/a/y': '',
         'foo/a/z/lyrics': '',
         'foo/b': '',
         'foo/c': ''
     }
     host = MockHost()
     host.filesystem = MockFileSystem(files=mock_files)
     self.assertEquals(host.filesystem.walk(mock_dir),
                       [('foo', ['a', 'bar'], ['c', 'b']),
                        ('foo/a', ['z'], ['x', 'y']),
                        ('foo/a/z', [], ['lyrics']),
                        ('foo/bar', [], ['quux', 'baz'])])
 def test_filesystem_walk_deeply_nested(self):
     mock_dir = 'foo'
     mock_files = {
         'foo/bar/baz': '',
         'foo/bar/quux': '',
         'foo/a/x': '',
         'foo/a/y': '',
         'foo/a/z/lyrics': '',
         'foo/b': '',
         'foo/c': ''
     }
     mock_files_ordered = OrderedDict(sorted(mock_files.items()))
     host = MockHost()
     host.filesystem = MockFileSystem(files=mock_files_ordered)
     self.assertEquals(host.filesystem.walk(mock_dir),
                       [('foo', ['a', 'bar'], ['b', 'c']),
                        ('foo/a', ['z'], ['x', 'y']),
                        ('foo/a/z', [], ['lyrics']),
                        ('foo/bar', [], ['baz', 'quux'])])
示例#12
0
 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.