Ejemplo n.º 1
0
    def _delete_orphaned_baselines(self):
        _log.info('Deleting any orphaned baselines.')

        is_baseline_filter = lambda fs, dirname, basename: is_testharness_baseline(basename)

        baselines = self.fs.files_under(
            self.dest_path, file_filter=is_baseline_filter)

        # Note about possible refactoring:
        #  - the manifest path could be factored out to a common location, and
        #  - the logic for reading the manifest could be factored out from here
        # and the Port class.
        manifest_path = self.finder.path_from_web_tests(
            'external', 'wpt', 'MANIFEST.json')
        manifest = WPTManifest(self.fs.read_text_file(manifest_path))
        wpt_urls = manifest.all_urls()

        # Currently baselines for tests with query strings are merged,
        # so that the tests foo.html?r=1 and foo.html?r=2 both have the same
        # baseline, foo-expected.txt.
        # TODO(qyearsley): Remove this when this behavior is fixed.
        wpt_urls = [url.split('?')[0] for url in wpt_urls]

        wpt_dir = self.finder.path_from_web_tests('external', 'wpt')
        for full_path in baselines:
            rel_path = self.fs.relpath(full_path, wpt_dir)
            if not self._has_corresponding_test(rel_path, wpt_urls):
                self.fs.remove(full_path)
Ejemplo n.º 2
0
    def test_file_for_test(self):
        # Test that we can lookup a test's filename for various cases like
        # variants and multi-globals.
        manifest_json = '''
 {
    "items": {
        "manual": {},
        "reftest": {},
        "testharness": {
            "test.any.js": [
                "d23fbb8c66def47e31ad01aa7a311064ba8fddbd",
                ["test.any.html", {}],
                ["test.any.worker.html", {}]
            ]
        }
    }
}       '''
        host = MockHost()
        host.filesystem.write_text_file(
            WEB_TEST_DIR + '/external/wpt/MANIFEST.json', manifest_json)
        manifest = WPTManifest(host,
                               WEB_TEST_DIR + '/external/wpt/MANIFEST.json')
        self.assertEqual(
            manifest.all_url_items(), {
                u'test.any.html': [u'test.any.html', {}],
                u'test.any.worker.html': [u'test.any.worker.html', {}]
            })
        # Ensure that we can get back to `test.any.js` from both of the tests.
        self.assertEqual(manifest.file_path_for_test_url('test.any.html'),
                         'test.any.js')
        self.assertEqual(
            manifest.file_path_for_test_url('test.any.worker.html'),
            'test.any.js')
    def test_crash_tests(self):
        # Test that the manifest recognizes crash tests and that is_crash_test
        # correctly identifies only crash tests in the manifest.
        manifest_json = '''
{
    "items": {
        "manual": {},
        "reftest": {},
        "testharness": {
            "test.html": [
                "d23fbb8c66def47e31ad01aa7a311064ba8fddbd",
                [null, {}]
            ]
        },
        "crashtest": {
            "test-crash.html": [
                "d23fbb8c66def47e31ad01aa7a311064ba8fddbd",
                [null, {}]
            ]
        }
    }
}
        '''
        manifest = WPTManifest(manifest_json)
        self.assertEqual(
            manifest.all_url_items(), {
                u'test.html': [u'test.html', {}],
                u'test-crash.html': [u'test-crash.html', {}]
            })

        self.assertTrue(manifest.is_crash_test(u'test-crash.html'))
        self.assertFalse(manifest.is_crash_test(u'test.html'))
        self.assertFalse(manifest.is_crash_test(u'different-test-crash.html'))
Ejemplo n.º 4
0
    def test_file_for_test(self):
        # Test that we can lookup a test's filename for various cases like
        # variants and multi-globals.
        manifest_json = '''
 {
    "items": {
        "manual": {},
        "reftest": {},
        "testharness": {
            "test.any.js": [
                ["/test.any.html", {}],
                ["/test.any.worker.html", {}]
            ]
        }
    }
}       '''
        manifest = WPTManifest(manifest_json)
        self.assertEqual(
            manifest.all_url_items(), {
                u'/test.any.html': [u'/test.any.html', {}],
                u'/test.any.worker.html': [u'/test.any.worker.html', {}]
            })
        # Ensure that we can get back to `test.any.js` from both of the tests.
        self.assertEqual(manifest.file_path_for_test_url('/test.any.html'),
                         'test.any.js')
        self.assertEqual(
            manifest.file_path_for_test_url('/test.any.worker.html'),
            'test.any.js')
Ejemplo n.º 5
0
    def test_does_not_throw_when_missing_some_test_types(self):
        manifest_json = '''
{
    "items": {
        "testharness": {
            "test.any.js": [
                ["/test.any.html", {}]
            ]
        }
    }
}
        '''
        manifest = WPTManifest(manifest_json)
        self.assertTrue(manifest.is_test_file('test.any.js'))
        self.assertEqual(manifest.all_url_items(),
                         {u'/test.any.html': [u'/test.any.html', {}]})
        self.assertEqual(manifest.extract_reference_list('/foo/bar.html'), [])
Ejemplo n.º 6
0
    def test_all_url_items_skips_jsshell_tests(self):
        manifest_json = '''
{
    "items": {
        "manual": {},
        "reftest": {},
        "testharness": {
            "test.any.js": [
                ["/test.any.html", {}],
                ["/test.any.js", {"jsshell": true}]
            ]
        }
    }
}
        '''
        manifest = WPTManifest(manifest_json)
        self.assertEqual(manifest.all_url_items(),
                         {u'/test.any.html': [u'/test.any.html', {}]})
    def test_all_url_items_skips_jsshell_tests(self):
        manifest_json = '''
{
    "items": {
        "manual": {},
        "reftest": {},
        "testharness": {
            "test.any.js": [
                "d23fbb8c66def47e31ad01aa7a311064ba8fddbd",
                ["test.any.html", {}],
                [null, {"jsshell": true}]
            ]
        }
    }
}
        '''
        manifest = WPTManifest(manifest_json)
        self.assertEqual(manifest.all_url_items(),
                         {u'test.any.html': [u'test.any.html', {}]})
    def test_file_path_to_url_paths(self):
        manifest_json = '''
{
    "items": {
        "manual": {},
        "reftest": {},
        "testharness": {
            "test.any.js": [
                ["/test.any.html", {}],
                ["/test.any.js", {"jsshell": true}]
            ]
        }
    }
}
        '''
        manifest = WPTManifest(manifest_json)
        # Leading slashes should be stripped; and jsshell tests shouldn't be
        # included.
        self.assertEqual(manifest.file_path_to_url_paths('test.any.js'),
                         [u'test.any.html'])
Ejemplo n.º 9
0
    def test_does_not_throw_when_missing_some_test_types(self):
        manifest_json = '''
{
    "items": {
        "testharness": {
            "test.any.js": [
                "8d4b9a583f484741f4cd4e4940833a890c612656",
                ["test.any.html", {}]
            ]
        }
    }
}
        '''
        host = MockHost()
        host.filesystem.write_text_file(
            WEB_TEST_DIR + '/external/wpt/MANIFEST.json', manifest_json)
        manifest = WPTManifest(host,
                               WEB_TEST_DIR + '/external/wpt/MANIFEST.json')
        self.assertTrue(manifest.is_test_file('test.any.js'))
        self.assertEqual(manifest.all_url_items(),
                         {u'test.any.html': [u'test.any.html', {}]})
        self.assertEqual(manifest.extract_reference_list('/foo/bar.html'), [])
Ejemplo n.º 10
0
    def test_all_url_items_skips_jsshell_tests(self):
        manifest_json = '''
{
    "items": {
        "manual": {},
        "reftest": {},
        "testharness": {
            "test.any.js": [
                "d23fbb8c66def47e31ad01aa7a311064ba8fddbd",
                ["test.any.html", {}],
                [null, {"jsshell": true}]
            ]
        }
    }
}
        '''
        host = MockHost()
        host.filesystem.write_text_file(
            WEB_TEST_DIR + '/external/wpt/MANIFEST.json', manifest_json)
        manifest = WPTManifest(host,
                               WEB_TEST_DIR + '/external/wpt/MANIFEST.json')
        self.assertEqual(manifest.all_url_items(),
                         {u'test.any.html': [u'test.any.html', {}]})
Ejemplo n.º 11
0
    def test_crash_tests(self):
        # Test that the manifest recognizes crash tests and that is_crash_test
        # correctly identifies only crash tests in the manifest.
        manifest_json = '''
{
    "items": {
        "manual": {},
        "reftest": {},
        "testharness": {
            "test.html": [
                "d23fbb8c66def47e31ad01aa7a311064ba8fddbd",
                [null, {}]
            ]
        },
        "crashtest": {
            "test-crash.html": [
                "d23fbb8c66def47e31ad01aa7a311064ba8fddbd",
                [null, {}]
            ]
        }
    }
}
        '''
        host = MockHost()
        host.filesystem.write_text_file(
            WEB_TEST_DIR + '/external/wpt/MANIFEST.json', manifest_json)
        manifest = WPTManifest(host,
                               WEB_TEST_DIR + '/external/wpt/MANIFEST.json')
        self.assertEqual(
            manifest.all_url_items(), {
                u'test.html': [u'test.html', {}],
                u'test-crash.html': [u'test-crash.html', {}]
            })

        self.assertTrue(manifest.is_crash_test(u'test-crash.html'))
        self.assertFalse(manifest.is_crash_test(u'test.html'))
        self.assertFalse(manifest.is_crash_test(u'different-test-crash.html'))
Ejemplo n.º 12
0
    def test_extract_fuzzy_metadata(self):
        manifest_json = '''
{
    "items": {
        "reftest": {
            "not_fuzzy.html": [
                "d23fbb8c66def47e31ad01aa7a311064ba8fddbd",
                [
                    null,
                    [
                        [
                            "not_fuzzy-ref.html",
                            "=="
                        ]
                    ],
                    {}
                ]
            ],
            "fuzzy.html": [
                "d23fbb8c66def47e31ad01aa7a311064ba8fddbd",
                [
                    null,
                    [
                        [
                            "fuzzy-ref.html",
                            "=="
                        ]
                    ],
                    {
                        "fuzzy": [
                            [
                                null,
                                [
                                    [2, 2],
                                    [40, 40]
                                ]
                            ]
                        ]
                    }
                ]
            ]
        },
        "testharness": {
            "not_a_reftest.html": [
                "d23fbb8c66def47e31ad01aa7a311064ba8fddbd",
                [null, {}]
            ]
        }
    }
}
        '''

        host = MockHost()
        host.filesystem.write_text_file(
            WEB_TEST_DIR + '/external/wpt/MANIFEST.json', manifest_json)
        manifest = WPTManifest(host,
                               WEB_TEST_DIR + '/external/wpt/MANIFEST.json')

        self.assertEqual(
            manifest.extract_fuzzy_metadata('fuzzy.html'),
            [[2, 2], [40, 40]],
        )

        self.assertEqual(manifest.extract_fuzzy_metadata('not_fuzzy.html'),
                         (None, None))
        self.assertEqual(manifest.extract_fuzzy_metadata('not_a_reftest.html'),
                         (None, None))