mirror of
https://github.com/servo/servo.git
synced 2025-06-25 01:24:37 +01:00
Auto merge of #6360 - fbau123:6315-tests-default-cpu-mode, r=Ms2ger
#6315 Set 'mach test-ref' default render mode to cpu and added a cli argument to 'mach test' to be able to select the render-mode, also renamed the 'kind' argument from 'test-ref' to '--render-mode' for coherence with reftest.rs <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6360) <!-- Reviewable:end -->
This commit is contained in:
commit
bedfa74b1f
1 changed files with 22 additions and 7 deletions
|
@ -32,6 +32,9 @@ import tidy
|
||||||
|
|
||||||
@CommandProvider
|
@CommandProvider
|
||||||
class MachCommands(CommandBase):
|
class MachCommands(CommandBase):
|
||||||
|
DEFAULT_RENDER_MODE = "cpu"
|
||||||
|
HELP_RENDER_MODE = "Value can be 'cpu', 'gpu' or 'both' (default " + DEFAULT_RENDER_MODE + ")"
|
||||||
|
|
||||||
def __init__(self, context):
|
def __init__(self, context):
|
||||||
CommandBase.__init__(self, context)
|
CommandBase.__init__(self, context)
|
||||||
if not hasattr(self.context, "built_tests"):
|
if not hasattr(self.context, "built_tests"):
|
||||||
|
@ -96,13 +99,24 @@ class MachCommands(CommandBase):
|
||||||
@CommandArgument('params', default=None, nargs="...",
|
@CommandArgument('params', default=None, nargs="...",
|
||||||
help="Optionally select test based on "
|
help="Optionally select test based on "
|
||||||
"test file directory")
|
"test file directory")
|
||||||
def test(self, params):
|
@CommandArgument('--render-mode', '-rm', default=DEFAULT_RENDER_MODE,
|
||||||
|
help="The render mode to be used on all tests. " +
|
||||||
|
HELP_RENDER_MODE)
|
||||||
|
def test(self, params, render_mode=DEFAULT_RENDER_MODE):
|
||||||
if params:
|
if params:
|
||||||
return self.infer_test_by_dir(params)
|
return self.infer_test_by_dir(params)
|
||||||
|
|
||||||
|
test_and_args = [
|
||||||
|
("tidy", {}),
|
||||||
|
("ref", {"kind": render_mode}),
|
||||||
|
("wpt", {}),
|
||||||
|
("css", {}),
|
||||||
|
("unit", {}),
|
||||||
|
]
|
||||||
test_start = time()
|
test_start = time()
|
||||||
for t in ["tidy", "ref", "wpt", "css", "unit"]:
|
for t, args in test_and_args:
|
||||||
Registrar.dispatch("test-%s" % t, context=self.context)
|
Registrar.dispatch("test-%s" % t, context=self.context, **args)
|
||||||
|
|
||||||
elapsed = time() - test_start
|
elapsed = time() - test_start
|
||||||
|
|
||||||
print("Tests completed in %0.2fs" % elapsed)
|
print("Tests completed in %0.2fs" % elapsed)
|
||||||
|
@ -134,8 +148,8 @@ class MachCommands(CommandBase):
|
||||||
@Command('test-ref',
|
@Command('test-ref',
|
||||||
description='Run the reference tests',
|
description='Run the reference tests',
|
||||||
category='testing')
|
category='testing')
|
||||||
@CommandArgument('--kind', '-k', default=None,
|
@CommandArgument('--kind', '-k', default=DEFAULT_RENDER_MODE,
|
||||||
help="'cpu' or 'gpu' (default both)")
|
help=HELP_RENDER_MODE)
|
||||||
@CommandArgument('--name', default=None,
|
@CommandArgument('--name', default=None,
|
||||||
help="Only run tests that match this pattern. If the "
|
help="Only run tests that match this pattern. If the "
|
||||||
"path to the ref test directory is included, it "
|
"path to the ref test directory is included, it "
|
||||||
|
@ -143,11 +157,12 @@ class MachCommands(CommandBase):
|
||||||
@CommandArgument(
|
@CommandArgument(
|
||||||
'servo_params', default=None, nargs=argparse.REMAINDER,
|
'servo_params', default=None, nargs=argparse.REMAINDER,
|
||||||
help="Command-line arguments to be passed through to Servo")
|
help="Command-line arguments to be passed through to Servo")
|
||||||
def test_ref(self, kind=None, name=None, servo_params=None):
|
def test_ref(self, kind=DEFAULT_RENDER_MODE, name=None, servo_params=None):
|
||||||
self.ensure_bootstrapped()
|
self.ensure_bootstrapped()
|
||||||
self.ensure_built_tests()
|
self.ensure_built_tests()
|
||||||
|
assert kind is not None, 'kind cannot be None, see help'
|
||||||
|
|
||||||
kinds = ["cpu", "gpu"] if kind is None else [kind]
|
kinds = ["cpu", "gpu"] if kind == 'both' else [kind]
|
||||||
test_path = path.join(self.context.topdir, "tests", "ref")
|
test_path = path.join(self.context.topdir, "tests", "ref")
|
||||||
error = False
|
error = False
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue