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/.
10 from mach
.decorators
import Command
11 from mozbuild
.base
import BinaryNotFoundException
12 from mozbuild
.base
import MachCommandConditions
as conditions
15 def setup_argument_parser_functional():
16 from firefox_ui_harness
.arguments
.base
import FirefoxUIArguments
17 from mozlog
.structured
import commandline
19 parser
= FirefoxUIArguments()
20 commandline
.add_logging_group(parser
)
24 def run_firefox_ui_test(topsrcdir
=None, **kwargs
):
25 from argparse
import Namespace
27 import firefox_ui_harness
28 from mozlog
.structured
import commandline
30 parser
= setup_argument_parser_functional()
32 fxui_dir
= os
.path
.join(topsrcdir
, "testing", "firefox-ui")
34 # Set the resources path which is used to serve test data via wptserve
35 if not kwargs
["server_root"]:
36 kwargs
["server_root"] = os
.path
.join(fxui_dir
, "resources")
38 # If called via "mach test" a dictionary of tests is passed in
39 if "test_objects" in kwargs
:
41 for obj
in kwargs
["test_objects"]:
42 tests
.append(obj
["file_relpath"])
43 kwargs
["tests"] = tests
44 elif not kwargs
.get("tests"):
45 # If no tests have been selected, set default ones
46 kwargs
["tests"] = os
.path
.join(fxui_dir
, "tests", "functional", "manifest.ini")
48 kwargs
["logger"] = kwargs
.pop("log", None)
49 if not kwargs
["logger"]:
50 kwargs
["logger"] = commandline
.setup_logging(
51 "Firefox UI - Functional Tests", {"mach": sys
.stdout
}
56 for k
, v
in six
.iteritems(kwargs
):
59 parser
.verify_usage(args
)
61 failed
= firefox_ui_harness
.cli_functional
.cli(args
=vars(args
))
70 "firefox-ui-functional",
72 conditions
=[conditions
.is_firefox
],
73 description
="Run the functional test suite of Firefox UI tests.",
74 parser
=setup_argument_parser_functional
,
76 def run_firefox_ui_functional(command_context
, **kwargs
):
78 kwargs
["binary"] = kwargs
["binary"] or command_context
.get_binary_path("app")
79 except BinaryNotFoundException
as e
:
82 "firefox-ui-functional",
87 logging
.INFO
, "firefox-ui-functional", {"help": e
.help()}, "{help}"
91 return run_firefox_ui_test(topsrcdir
=command_context
.topsrcdir
, **kwargs
)