summaryrefslogtreecommitdiffstats
path: root/python/mozperftest/mozperftest/metadata.py
blob: 95864e14e28125d54023faf89348673d0554e949 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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 http://mozilla.org/MPL/2.0/.
from collections import defaultdict

from mozperftest.utils import MachLogger


class Metadata(MachLogger):
    def __init__(self, mach_cmd, env, flavor, script):
        MachLogger.__init__(self, mach_cmd)
        self._mach_cmd = mach_cmd
        self.flavor = flavor
        self.options = defaultdict(dict)
        self._results = []
        self._output = None
        self._env = env
        self.script = script

    def run_hook(self, name, *args, **kw):
        # this bypasses layer restrictions on args,
        # which is fine since it's a user script
        return self._env.hooks.run(name, *args, **kw)

    def set_output(self, output):
        self._output = output

    def get_output(self):
        return self._output

    def add_result(self, result):
        self._results.append(result)

    def get_results(self):
        return self._results

    def clear_results(self):
        self._results = []

    def update_options(self, name, options):
        self.options[name].update(options)

    def get_options(self, name):
        return self.options[name]