Source code

Revision control

Other Tools

1
# This Source Code Form is subject to the terms of the Mozilla Public↩
2
# License, v. 2.0. If a copy of the MPL was not distributed with this↩
3
# file, You can obtain one at http://mozilla.org/MPL/2.0/.↩
4
from __future__ import absolute_import, print_function, unicode_literals↩
5
6
import argparse↩
7
import os↩
8
import sys↩
9
10
from mach.decorators import CommandProvider, Command↩
11
12
from mozbuild.base import MachCommandBase, MachCommandConditions as conditions↩
13
14
15
def create_parser_tests():↩
16
from marionette_harness.runtests import MarionetteArguments↩
17
from mozlog.structured import commandline↩
18
19
parser = MarionetteArguments()↩
20
commandline.add_logging_group(parser)↩
21
return parser↩
22
23
24
def run_telemetry(tests, binary=None, topsrcdir=None, **kwargs):↩
25
from mozlog.structured import commandline↩
26
27
from telemetry_harness.runtests import TelemetryTestRunner↩
28
29
from marionette_harness.runtests import MarionetteHarness↩
30
31
parser = create_parser_tests()↩
32
33
if not tests:↩
34
tests = [↩
35
os.path.join(↩
36
topsrcdir,↩
37
"toolkit/components/telemetry/tests/marionette/tests/manifest.ini",↩
38
)↩
39
]↩
40
41
args = argparse.Namespace(tests=tests)↩
42
43
args.binary = binary↩
44
args.logger = kwargs.pop("log", None)↩
45
46
for k, v in kwargs.iteritems():↩
47
setattr(args, k, v)↩
48
49
parser.verify_usage(args)↩
50
51
if not args.logger:↩
52
args.logger = commandline.setup_logging(↩
53
"Telemetry Client Tests", args, {"mach": sys.stdout}↩
54
)↩
55
failed = MarionetteHarness(TelemetryTestRunner, args=vars(args)).run()↩
56
if failed > 0:↩
57
return 1↩
58
else:↩
59
return 0↩
60
61
62
@CommandProvider↩
63
class TelemetryTest(MachCommandBase):↩
64
@Command(↩
65
"telemetry-tests-client",↩
66
category="testing",↩
67
description="Run tests specifically for the Telemetry client",↩
68
conditions=[conditions.is_firefox_or_android],↩
69
parser=create_parser_tests,↩
70
)↩
71
def telemetry_test(self, tests, **kwargs):↩
72
if "test_objects" in kwargs:↩
73
tests = []↩
74
for obj in kwargs["test_objects"]:↩
75
tests.append(obj["file_relpath"])↩
76
del kwargs["test_objects"]↩
77
if not kwargs.get("binary") and conditions.is_firefox(self):↩
78
kwargs["binary"] = self.get_binary_path("app")↩
79
if not kwargs.get("server_root"):↩
80
kwargs["server_root"] = "toolkit/components/telemetry/tests/marionette/harness/www"
81
return run_telemetry(tests, topsrcdir=self.topsrcdir, **kwargs)↩