зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1395933 - Expand geckodriver mach command with test and build targets. r=maja_zf,rillian
The current "./mach geckodriver" commands runs the geckodriver binary, but this patch introduces a geckodriver namespace to mach and renames that command to "./mach geckodriver run". It also introduces two new commands to build geckodriver and run its Rust unit tests through "./mach geckodriver build" and "./mach geckodriver test", respectively. MozReview-Commit-ID: 5iO9FVkbch2 --HG-- extra : rebase_source : 6395a65526d48e4af5f63f3b23dd3a52801e03a3
This commit is contained in:
Родитель
f7a04dd989
Коммит
044df93d69
|
@ -0,0 +1,10 @@
|
|||
var Uint32Array = TypedObject.float32.array(3);
|
||||
const ONE_MINUS_EPSILON = 1 - Math.pow(2, -53);
|
||||
const f = new Float64Array([0, 0]);
|
||||
const u = new Uint32Array(f.buffer);
|
||||
const diff = function(a, b) {
|
||||
f[1] = b;
|
||||
u[3 - ENDIAN];
|
||||
};
|
||||
ENDIAN = 1;
|
||||
diff(1, ONE_MINUS_EPSILON)
|
|
@ -124,12 +124,12 @@ you put this in your [mozconfig]:
|
|||
|
||||
When you have, you are ready to start off your first build:
|
||||
|
||||
% ./mach build testing/geckodriver
|
||||
% ./mach geckodriver build
|
||||
|
||||
The geckodriver executable will appear in `${objdir}/dist/bin/geckodriver`
|
||||
alongside firefox-bin. To run it you can use mach:
|
||||
|
||||
% ./mach geckodriver -- --version
|
||||
% ./mach geckodriver run -- --version
|
||||
0:00.27 /home/ato/src/gecko/obj-x86_64-pc-linux-gnu/dist/bin/geckodriver --version --binary /home/ato/src/gecko/obj-x86_64-pc-linux-gnu/dist/bin/firefox
|
||||
geckodriver 0.19.0 (f3e939a81ee1169f9501ad96eb43bbf4bf4a1bde 2017-10-11)
|
||||
|
||||
|
@ -154,18 +154,17 @@ a set of conformance tests with other browser vendors through the
|
|||
compatibility between _different_ WebDriver implementations for
|
||||
different browsers.
|
||||
|
||||
In addition to the WPT tests, geckodriver and libwebdriver has
|
||||
unit tests. At the moment there is no way to run Rust unit tests
|
||||
through mach, although this is being worked on. For the moment
|
||||
you need to kick off a separate build using [cargo]:
|
||||
In addition to the WPT tests, geckodriver and webdriver have unit tests.
|
||||
You can also use the mach geckodriver command to run geckodriver tests:
|
||||
|
||||
% cd testing/geckodriver
|
||||
Compiling geckodriver v0.19.0 (file:///home/ato/src/gecko/testing/geckodriver)
|
||||
…
|
||||
test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
|
||||
% ./mach geckodriver test
|
||||
|
||||
Because the unit tests _are not_ currently run in the [Firefox CI],
|
||||
hopefully you will find that they all pass. (-:
|
||||
The webdriver crate tests are unfortunately not yet runnable through mach.
|
||||
Work to make this possible is tracked in [[https://bugzil.la/1424369]].
|
||||
For the moment you must run them manually through `cargo`:
|
||||
|
||||
% cd testing/webdriver
|
||||
% cargo test
|
||||
|
||||
To run the more extensive WPT tests you can use mach, but first
|
||||
make sure you have a build of Firefox:
|
||||
|
|
|
@ -578,6 +578,12 @@ ensure you put this in your [mozconfig]:
|
|||
The _geckodriver_ binary will appear in `${objdir}/dist/bin/geckodriver`
|
||||
alongside _firefox-bin_.
|
||||
|
||||
The following self-explanatory targets are available through mach:
|
||||
|
||||
* `./mach geckodriver build`
|
||||
* `./mach geckodriver test`
|
||||
* `./mach geckodriver run`
|
||||
|
||||
[Rust]: https://www.rust-lang.org/
|
||||
[Mozilla]: https://www.mozilla.org/en-US/
|
||||
[webdriver crate]: https://github.com/mozilla/webdriver-rust
|
||||
|
|
|
@ -1,40 +1,53 @@
|
|||
# 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 __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import argparse
|
||||
import os
|
||||
|
||||
from mozbuild.base import (
|
||||
MachCommandBase
|
||||
)
|
||||
|
||||
from mach.decorators import (
|
||||
Command,
|
||||
CommandArgument,
|
||||
CommandArgumentGroup,
|
||||
CommandProvider,
|
||||
Command,
|
||||
SubCommand,
|
||||
)
|
||||
|
||||
from mozbuild.base import (
|
||||
MachCommandBase,
|
||||
MachCommandConditions as conditions,
|
||||
)
|
||||
|
||||
|
||||
@CommandProvider
|
||||
class RunGeckodriver(MachCommandBase):
|
||||
"""Run the compiled program."""
|
||||
class GeckoDriver(MachCommandBase):
|
||||
|
||||
@Command('geckodriver', category='post-build',
|
||||
description='Run the geckodriver WebDriver implementation')
|
||||
@CommandArgument('--binary', type=str,
|
||||
help='Firefox binary (defaults to the local build).')
|
||||
@CommandArgument('params', nargs='...',
|
||||
help='Command-line arguments to be passed through to the program.')
|
||||
@Command("geckodriver",
|
||||
category="post-build",
|
||||
description="WebDriver implementation for Gecko",
|
||||
conditions=[conditions.is_firefox])
|
||||
def geckodriver(self):
|
||||
pass
|
||||
|
||||
@CommandArgumentGroup('debugging')
|
||||
@CommandArgument('--debug', action='store_true', group='debugging',
|
||||
help='Enable the debugger. Not specifying a --debugger option will result in the default debugger being used.')
|
||||
@CommandArgument('--debugger', default=None, type=str, group='debugging',
|
||||
help='Name of debugger to use.')
|
||||
@CommandArgument('--debugger-args', default=None, metavar='params', type=str,
|
||||
group='debugging',
|
||||
help='Command-line arguments to pass to the debugger itself; split as the Bourne shell would.')
|
||||
@SubCommand("geckodriver", "run",
|
||||
description="Run geckodriver.")
|
||||
@CommandArgument("--binary", type=str,
|
||||
help="Firefox binary (defaults to the local build).")
|
||||
@CommandArgument("params", nargs="...",
|
||||
help="Flags to be passed through to geckodriver.")
|
||||
@CommandArgumentGroup("debugging")
|
||||
@CommandArgument("--debug", action="store_true", group="debugging",
|
||||
help="Enable the debugger. Not specifying a --debugger option will result in the default debugger being used.")
|
||||
@CommandArgument("--debugger", default=None, type=str, group="debugging",
|
||||
help="Name of debugger to use.")
|
||||
@CommandArgument("--debugger-args", default=None, metavar="params", type=str,
|
||||
group="debugging",
|
||||
help="Flags to pass to the debugger itself; split as the Bourne shell would.")
|
||||
def run(self, binary, params, debug, debugger, debugger_args):
|
||||
try:
|
||||
binpath = self.get_binary_path('geckodriver')
|
||||
binpath = self.get_binary_path("geckodriver")
|
||||
except Exception as e:
|
||||
print("It looks like geckodriver isn't built. "
|
||||
"Add ac_add_options --enable-geckodrver to your mozconfig ",
|
||||
|
@ -48,12 +61,12 @@ class RunGeckodriver(MachCommandBase):
|
|||
args.extend(params)
|
||||
|
||||
if binary is None:
|
||||
binary = self.get_binary_path('app')
|
||||
binary = self.get_binary_path("app")
|
||||
|
||||
args.extend(["--binary", binary])
|
||||
|
||||
if debug or debugger or debugger_args:
|
||||
if 'INSIDE_EMACS' in os.environ:
|
||||
if "INSIDE_EMACS" in os.environ:
|
||||
self.log_manager.terminal_handler.setLevel(logging.WARNING)
|
||||
|
||||
import mozdebug
|
||||
|
@ -84,3 +97,33 @@ class RunGeckodriver(MachCommandBase):
|
|||
|
||||
return self.run_process(args=args, ensure_exit_code=False,
|
||||
pass_thru=True)
|
||||
|
||||
@SubCommand("geckodriver", "build",
|
||||
description="Build geckodriver.")
|
||||
@CommandArgument("-v", "--verbose", action="store_true",
|
||||
help="Verbose output for what commands the build is running.")
|
||||
def build(self, verbose=False):
|
||||
from mozbuild.controller.building import BuildDriver
|
||||
|
||||
self.log_manager.enable_all_structured_loggers()
|
||||
|
||||
driver = self._spawn(BuildDriver)
|
||||
return driver.build(
|
||||
what=["testing/geckodriver"],
|
||||
verbose=verbose,
|
||||
mach_context=self._mach_context)
|
||||
|
||||
@SubCommand("geckodriver", "test",
|
||||
description="Run geckodriver unit tests.")
|
||||
@CommandArgument("-v", "--verbose", action="store_true",
|
||||
help="Verbose output for what commands the build is running.")
|
||||
def test(self, verbose=False):
|
||||
from mozbuild.controller.building import BuildDriver
|
||||
|
||||
self.log_manager.enable_all_structured_loggers()
|
||||
|
||||
driver = self._spawn(BuildDriver)
|
||||
return driver.build(
|
||||
what=["testing/geckodriver/check"],
|
||||
verbose=verbose,
|
||||
mach_context=self._mach_context)
|
||||
|
|
Загрузка…
Ссылка в новой задаче