aboutsummaryrefslogtreecommitdiffstats
path: root/python/wpt/__init__.py
blob: a8276a506ce586c60e7fd860bc3688c8f5c0deb6 (plain) (blame)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Copyright 2023 The Servo Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

import os
import sys

import mozlog.commandline

SCRIPT_PATH = os.path.abspath(os.path.dirname(__file__))
SERVO_ROOT = os.path.abspath(os.path.join(SCRIPT_PATH, "..", ".."))
WPT_PATH = os.path.join(SERVO_ROOT, "tests", "wpt")
WPT_TOOLS_PATH = os.path.join(WPT_PATH, "web-platform-tests", "tools")
CERTS_PATH = os.path.join(WPT_TOOLS_PATH, "certs")

sys.path.insert(0, WPT_TOOLS_PATH)
import localpaths  # noqa: F401,E402
import wptrunner.wptcommandline  # noqa: E402


def create_parser():
    parser = wptrunner.wptcommandline.create_parser()
    parser.add_argument('--release', default=False, action="store_true",
                        help="Run with a release build of servo")
    parser.add_argument('--rr-chaos', default=False, action="store_true",
                        help="Run under chaos mode in rr until a failure is captured")
    parser.add_argument('--pref', default=[], action="append", dest="prefs",
                        help="Pass preferences to servo")
    parser.add_argument('--layout-2020', '--with-layout-2020', default=False,
                        action="store_true", help="Use expected results for the 2020 layout engine")
    parser.add_argument('--layout-2013', '--with-layout-2013', default=True,
                        action="store_true", help="Use expected results for the 2013 layout engine")
    parser.add_argument('--log-servojson', action="append", type=mozlog.commandline.log_file,
                        help="Servo's JSON logger of unexpected results")
    parser.add_argument('--always-succeed', default=False, action="store_true",
                        help="Always yield exit code of zero")
    parser.add_argument('--no-default-test-types', default=False, action="store_true",
                        help="Run all of the test types provided by wptrunner or specified explicitly by --test-types")
    parser.add_argument('--filter-intermittents', default=None, action="store",
                        help="Filter intermittents against known intermittents "
                             "and save the filtered output to the given file.")
    parser.add_argument('--log-raw-unexpected', default=None, action="store",
                        help="Raw structured log messages for unexpected results."
                             " '--log-raw' Must also be passed in order to use this.")
    return parser


def update_args_for_legacy_layout(kwargs: dict):
    if kwargs.pop("layout_2020"):
        return
    kwargs["test_paths"]["/"]["metadata_path"] = os.path.join(
        WPT_PATH, "meta-legacy-layout"
    )
    kwargs["test_paths"]["/_mozilla/"]["metadata_path"] = os.path.join(
        WPT_PATH, "mozilla", "meta-legacy-layout"
    )
    kwargs["include_manifest"] = os.path.join(
        WPT_PATH, "include-legacy-layout.ini"
    )