author Jared Wein <>
Tue, 12 May 2020 02:00:19 +0000
changeset 589278 cdf352f02ac4e034be96d14031fd6cc37dbe9ab9
parent 582437 fdfedcfa512d569456e52c409339dbc21e265ee0
permissions -rw-r--r--
Bug 1636511 - Disable the OS auth feature in about:logins on Release and Beta. r=MattN a=RyanVM Differential Revision:

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at

from __future__ import absolute_import, print_function, unicode_literals

import six.moves.cPickle as pickle
from collections import defaultdict
import six

import mozpack.path as mozpath

from mozbuild.backend.base import PartialBackend
from import TestManifest

class TestManifestBackend(PartialBackend):
    """Partial backend that generates test metadata files."""

    def _init(self):
        self.tests_by_path = defaultdict(list)
        self.installs_by_path = defaultdict(list)
        self.deferred_installs = set()
        self.manifest_defaults = {}

        # Add config.status so performing a build will invalidate this backend.
            self.environment.topobjdir, 'config.status'))

    def consume_object(self, obj):
        if not isinstance(obj, TestManifest):

        self.backend_input_files |= obj.context_all_paths
        for source in obj.source_relpaths:
            from reftest import ReftestManifest

            if isinstance(obj.manifest, ReftestManifest):
                # Mark included files as part of the build backend so changes
                # result in re-config.
                self.backend_input_files |= obj.manifest.manifests
        except ImportError:
            # Ignore errors caused by the reftest module not being present.
            # This can happen when building SpiderMonkey standalone, for example.

        for test in obj.tests:
            self.add(test, obj.flavor, obj.topsrcdir)
        self.add_installs(obj, obj.topsrcdir)

    def consume_finished(self):
        topobjdir = self.environment.topobjdir

        with self._write_file(mozpath.join(topobjdir, 'all-tests.pkl'), readmode='rb') as fh:
            pickle.dump(dict(self.tests_by_path), fh, protocol=2)

        with self._write_file(mozpath.join(topobjdir, 'test-defaults.pkl'), readmode='rb') as fh:
            pickle.dump(self.manifest_defaults, fh, protocol=2)

        path = mozpath.join(topobjdir, 'test-installs.pkl')
        with self._write_file(path, readmode='rb') as fh:
            pickle.dump({k: v for k, v in self.installs_by_path.items()
                         if k in self.deferred_installs},

    def add(self, t, flavor, topsrcdir):
        t = dict(t)
        t['flavor'] = flavor

        path = mozpath.normpath(t['path'])
        manifest = mozpath.normpath(t['manifest'])
        assert mozpath.basedir(path, [topsrcdir])
        assert mozpath.basedir(manifest, [topsrcdir])

        key = path[len(topsrcdir)+1:]
        t['file_relpath'] = key
        t['dir_relpath'] = mozpath.dirname(key)
        t['srcdir_relpath'] = key
        t['manifest_relpath'] = manifest[len(topsrcdir)+1:]


    def add_defaults(self, manifest):
        if not hasattr(manifest, 'manifest_defaults'):
        for sub_manifest, defaults in manifest.manifest_defaults.items():
            self.manifest_defaults[sub_manifest] = defaults

    def add_installs(self, obj, topsrcdir):
        for src, (dest, _) in six.iteritems(obj.installs):
            key = src[len(topsrcdir)+1:]
            self.installs_by_path[key].append((src, dest))
        for src, pat, dest in obj.pattern_installs:
            key = mozpath.join(src[len(topsrcdir)+1:], pat)
            self.installs_by_path[key].append((src, pat, dest))
        for path in obj.deferred_installs: