Beispiel #1
0
    def update_manifest(self,
                        manifest_path,
                        tests_path,
                        url_base="/",
                        recreate=False):
        self.logger.info("Updating test manifest %s" % manifest_path)

        json_data = None
        if not recreate:
            try:
                with open(manifest_path) as f:
                    json_data = json.load(f)
            except IOError:
                #If the existing file doesn't exist just create one from scratch
                pass

        if not json_data:
            manifest_file = manifest.Manifest(None, url_base)
        else:
            try:
                manifest_file = manifest.Manifest.from_json(
                    tests_path, json_data)
            except manifest.ManifestVersionMismatch:
                manifest_file = manifest.Manifest(None, url_base)

            manifest_update.update(tests_path, url_base, manifest_file)

        manifest.write(manifest_file, manifest_path)
    def update_manifest(self,
                        manifest_path,
                        tests_path,
                        url_base="/",
                        recreate=False,
                        download=False):
        self.logger.info("Updating test manifest %s" % manifest_path)
        manifest_log.setup()

        json_data = None
        if download:
            # TODO: make this not github-specific
            download_from_github(manifest_path, tests_path)

        if not recreate:
            try:
                with open(manifest_path) as f:
                    json_data = json.load(f)
            except IOError:
                #If the existing file doesn't exist just create one from scratch
                pass

        if not json_data:
            manifest_file = manifest.Manifest(url_base)
        else:
            try:
                manifest_file = manifest.Manifest.from_json(
                    tests_path, json_data)
            except manifest.ManifestVersionMismatch:
                manifest_file = manifest.Manifest(url_base)

        manifest_update.update(tests_path, manifest_file, True)

        manifest.write(manifest_file, manifest_path)
Beispiel #3
0
    def update_manifest(self, manifest_path, tests_path, url_base="/",
                        recreate=False, download=False):
        self.logger.info("Updating test manifest %s" % manifest_path)
        manifest_log.setup()

        json_data = None
        if download:
            # TODO: make this not github-specific
            download_from_github(manifest_path, tests_path)

        if not recreate:
            try:
                with open(manifest_path) as f:
                    json_data = json.load(f)
            except IOError:
                self.logger.info("Unable to find test manifest")
            except ValueError:
                self.logger.info("Unable to parse test manifest")

        if not json_data:
            self.logger.info("Creating test manifest")
            manifest_file = manifest.Manifest(url_base)
        else:
            try:
                manifest_file = manifest.Manifest.from_json(tests_path, json_data)
            except manifest.ManifestVersionMismatch:
                manifest_file = manifest.Manifest(url_base)

        manifest_update.update(tests_path, manifest_file, True)

        manifest.write(manifest_file, manifest_path)
Beispiel #4
0
def test_metadata_fuzzy():
    item = RefTest(".",
                   "a/fuzzy.html",
                   "/",
                   "a/fuzzy.html",
                   references=[["/a/fuzzy-ref.html", "=="]],
                   fuzzy=[[["/a/fuzzy.html", '/a/fuzzy-ref.html', '=='],
                           [[2, 3], [10, 15]]]])
    s = Mock(rel_path="a/fuzzy.html",
             rel_path_parts=("a", "fuzzy.html"),
             hash="0" * 40)
    s.manifest_items = Mock(return_value=(item.item_type, [item]))

    manifest = wptmanifest.Manifest()

    assert manifest.update([(s, True)]) is True

    test_metadata = manifestexpected.static.compile(
        BytesIO(test_fuzzy), {},
        data_cls_getter=manifestexpected.data_cls_getter,
        test_path="a/fuzzy.html",
        url_base="/")

    test = next(manifest.iterpath(to_os_path("a/fuzzy.html")))
    test_obj = wpttest.from_manifest(manifest, test, [],
                                     test_metadata.get_test(test.id))

    assert test_obj.fuzzy == {
        ('/a/fuzzy.html', '/a/fuzzy-ref.html', '=='): [[2, 3], [10, 15]]
    }
    assert test_obj.fuzzy_override == {
        '/a/fuzzy-ref.html': ((1, 1), (200, 200))
    }
Beispiel #5
0
def create_test_manifest(tests, url_base="/"):
    source_files = []
    for i, (test, _, test_type, _) in enumerate(tests):
        if test_type:
            source_files.append((SourceFileWithTest(test, str(i) * 40, item_classes[test_type]), True))
    m = manifest.Manifest()
    m.update(source_files)
    return m
Beispiel #6
0
 def create(self, state):
     from manifest import manifest
     state.manifest_path = os.path.join(state.metadata_path,
                                        "MANIFEST.json")
     # Conservatively always rebuild the manifest when doing a sync
     state.old_manifest = manifest.load(state.tests_path,
                                        state.manifest_path)
     state.test_manifest = manifest.Manifest(None, "/")
Beispiel #7
0
def main(request, response):
    path = os.path.join(root, "MANIFEST.json")

    manifest_file = None
    try:
        manifest_file = manifest.load(root, path)
    except manifest.ManifestVersionMismatch:
        pass
    if manifest_file is None:
        manifest_file = manifest.Manifest("/")

    update.update(root, manifest_file)

    manifest.write(manifest_file, path)

    return [("Content-Type", "application/json")
            ], json.dumps({"url": "/MANIFEST.json"})
Beispiel #8
0
    def load_manifest(self, tests_path, manifest_path, url_base="/", **kwargs):
        if (not os.path.exists(manifest_path) or self.force_manifest_update):
            self.update_manifest(manifest_path,
                                 tests_path,
                                 url_base,
                                 download=self.manifest_download)
        try:
            manifest_file = manifest.load(tests_path,
                                          manifest_path,
                                          types=self.types,
                                          meta_filters=self.meta_filters)
        except manifest.ManifestVersionMismatch:
            manifest_file = manifest.Manifest(url_base)
        if manifest_file.url_base != url_base:
            self.logger.info("Updating url_base in manifest from %s to %s" %
                             (manifest_file.url_base, url_base))
            manifest_file.url_base = url_base
            manifest.write(manifest_file, manifest_path)

        return manifest_file
Beispiel #9
0
def test_metadata_fuzzy():
    item = RefTest(tests_root=".",
                   path="a/fuzzy.html",
                   url_base="/",
                   url="a/fuzzy.html",
                   references=[["/a/fuzzy-ref.html", "=="]],
                   fuzzy=[[["/a/fuzzy.html", '/a/fuzzy-ref.html', '=='],
                           [[2, 3], [10, 15]]]])
    s = mock.Mock(rel_path="a/fuzzy.html",
                  rel_path_parts=("a", "fuzzy.html"),
                  hash="0" * 40)
    s.manifest_items = mock.Mock(return_value=(item.item_type, [item]))

    manifest = wptmanifest.Manifest("")

    tree, sourcefile_mock = tree_and_sourcefile_mocks([(s, None, True)])
    with mock.patch("manifest.manifest.SourceFile",
                    side_effect=sourcefile_mock):
        assert manifest.update(tree) is True

    test_metadata = manifestexpected.static.compile(
        BytesIO(test_fuzzy), {},
        data_cls_getter=manifestexpected.data_cls_getter,
        test_path="a/fuzzy.html",
        url_base="/")

    test = next(manifest.iterpath(to_os_path("a/fuzzy.html")))
    test_obj = wpttest.from_manifest(manifest, test, [],
                                     test_metadata.get_test(test.id))

    assert test_obj.fuzzy == {
        ('/a/fuzzy.html', '/a/fuzzy-ref.html', '=='): [[2, 3], [10, 15]]
    }
    assert test_obj.fuzzy_override == {
        '/a/fuzzy-ref.html': ((1, 1), (200, 200))
    }
Beispiel #10
0
 def create(self, state):
     from manifest import manifest
     state.manifest_path = os.path.join(state.metadata_path,
                                        "MANIFEST.json")
     state.test_manifest = manifest.Manifest("/")