Bug 1535050 - [marionette] Unify marionette test mach command. r=ato
authorHenrik Skupin <mail@hskupin.info>
Wed, 13 Mar 2019 17:14:35 +0000
changeset 521751 6e4bbb916809
parent 521750 01cbcad8bb67
child 521752 19e13e0edc40
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1535050
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1535050 - [marionette] Unify marionette test mach command. r=ato Differential Revision: https://phabricator.services.mozilla.com/D23348
testing/marionette/doc/Debugging.md
testing/marionette/doc/Testing.md
testing/marionette/mach_commands.py
--- a/testing/marionette/doc/Debugging.md
+++ b/testing/marionette/doc/Debugging.md
@@ -4,23 +4,23 @@ Debugging
 Redirecting the Gecko output
 ----------------------------
 
 The most common way to debug Marionette, as well as chrome code in
 general, is to use `dump()` to print a string to stdout.  In Firefox,
 this log output normally ends up in the gecko.log file in your current
 working directory.  With Fennec it can be inspected using `adb logcat`.
 
-`mach marionette test` takes a `--gecko-log` option which lets
+`mach marionette-test` takes a `--gecko-log` option which lets
 you redirect this output stream.  This is convenient if you want to
 “merge” the test harness output with the stdout from the browser.
 Per Unix conventions you can use `-` (dash) to have Firefox write
 its log to stdout instead of file:
 
-	% ./mach marionette test --gecko-log -
+	% ./mach marionette-test --gecko-log -
 
 It is common to use this in conjunction with an option to increase
 the Marionette log level:
 
 	% ./mach test --gecko-log - -vv TEST
 
 A single `-v` enables debug logging, and a double `-vv` enables
 trace logging.
@@ -37,17 +37,17 @@ JavaScript debugger
 
 You can attach the [Browser Toolbox] JavaScript debugger to the
 Marionette server using the `--jsdebugger` flag.  This enables you
 to introspect and set breakpoints in Gecko chrome code, which is a
 more powerful debugging technique than using `dump()` or `console.log()`.
 
 To automatically open the JS debugger for `Mn` tests:
 
-	% ./mach marionette test --jsdebugger
+	% ./mach marionette-test --jsdebugger
 
 It will prompt you when to start to allow you time to set your
 breakpoints.  It will also prompt you between each test.
 
 You can also use the `debugger;` statement anywhere in chrome code
 to add a breakpoint.  In this example, a breakpoint will be added
 whenever the `WebDriver:GetPageSource` command is called:
 
@@ -57,17 +57,17 @@ whenever the `WebDriver:GetPageSource` c
 	  await this._handleUserPrompts();

 	}
 
 To not be prompted at the start of the test run or between tests,
 you can set the `marionette.debugging.clicktostart` preference to
 false this way:
 
-	% ./mach marionette test --pref 'marionette.debugging.clicktostart:false' --jsdebugger
+	% ./mach marionette-test --pref 'marionette.debugging.clicktostart:false' --jsdebugger
 
 For reference, below is the list of preferences that enables the
 chrome debugger for Marionette.  These are all set implicitly when
 `--jsdebugger` is passed to mach.  In non-official builds, which
 are the default when built using `./mach build`, you will find that
 the chrome debugger won’t prompt for connection and will allow
 remote connections.
 
--- a/testing/marionette/doc/Testing.md
+++ b/testing/marionette/doc/Testing.md
@@ -40,38 +40,38 @@ These unit tests run as part of the `X` 
 Marionette functional tests
 ---------------------------
 
 We also have a set of [functional tests] that make use of the Marionette
 Python client.  These start a Firefox process and tests the Marionette
 protocol input and output, and will appear as `Mn` on Treeherder.
 The following command will run all tests locally:
 
-	% ./mach marionette test
+	% ./mach marionette-test
 
 But you can also run individual tests:
 
-	% ./mach marionette test testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
+	% ./mach marionette-test testing/marionette/harness/marionette_harness/tests/unit/test_navigation.py
 
 In case you want to run the tests with another binary like [Firefox Nightly]:
 
-	% ./mach marionette test --binary /path/to/nightly/firefox TEST
+	% ./mach marionette-test --binary /path/to/nightly/firefox TEST
 
 When working on Marionette it is often useful to surface the stdout
 from Gecko, which can be achived using the `--gecko-log` option.
 See <Debugging.html> for usage instructions, but the gist is that
 you can redirect all Gecko output to stdout:
 
-    % ./mach marionette test --gecko-log - TEST
+    % ./mach marionette-test --gecko-log - TEST
 
 Our functional integration tests pop up Firefox windows sporadically,
 and a helpful tip is to suppress the window can be to use Firefox’
 [headless mode]:
 
-    % ./mach marionette test -z TEST
+    % ./mach marionette-test -z TEST
 
 `-z` is an alias for the `--headless` flag and equivalent to setting
 the `MOZ_HEADLESS` output variable.  In addition to `MOZ_HEADLESS`
 there is also `MOZ_HEADLESS_WIDTH` and `MOZ_HEADLESS_HEIGHT` for
 controlling the dimensions of the no-op virtual display.  This is
 similar to using Xvfb(1) which you may know from the X windowing system,
 but has the additional benefit of also working on macOS and Windows.
 
@@ -86,46 +86,46 @@ Prerequisites:
 *   You have [built Fennec](https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions/Simple_Firefox_for_Android_build) with
     `ac_add_options --enable-marionette` in your mozconfig.
 *   You can run an Android [emulator](https://wiki.mozilla.org/Mobile/Fennec/Android/Testing#Running_tests_on_the_Android_emulator),
     which means you have the AVD you need.
 
 When running tests on Fennec, you can have Marionette runner take care of
 starting Fennec and an emulator, as shown below.
 
-	% ./mach marionette test --emulator --app fennec
+	% ./mach marionette-test --emulator --app fennec
     --avd-home /path/to/.mozbuild/android-device/avd
     --emulator-binary /path/to/.mozbuild/android-sdk/emulator/emulator
     --avd=mozemulator-x86
 
-For Fennec tests, if the appropriate `emulator` command is in your `PATH`, you may omit the `--emulator-binary` argument.  See `./mach marionette test -h`
+For Fennec tests, if the appropriate `emulator` command is in your `PATH`, you may omit the `--emulator-binary` argument.  See `./mach marionette-test -h`
 for additional options.
 
 Alternately, you can start an emulator yourself and have the Marionette runner
 start Fennec for you:
 
-    % ./mach marionette test --emulator --app='fennec' --address=127.0.0.1:2828 --disable-e10s
+    % ./mach marionette-test --emulator --app='fennec' --address=127.0.0.1:2828 --disable-e10s
 
 To connect to an already-running Fennec in an already running emulator or on a device, you will need to enable Marionette manually by setting the browser preference
 `marionette.enabled` set to true in the Fennec profile.
 
 Make sure port 2828 is forwarded:
 
 	% adb forward tcp:2828 tcp:2828
 
 If Fennec is already started:
 
-    % ./mach marionette test --app='fennec' --address=127.0.0.1:2828 --disable-e10s
+    % ./mach marionette-test --app='fennec' --address=127.0.0.1:2828 --disable-e10s
 
 If Fennec is not already started on the emulator/device, add the `--emulator`
 option. Marionette Test Runner will take care of forwarding the port and
 starting Fennec with the correct prefs. (You may need to run
 `adb forward --remove-all` to allow the runner to start.)
 
-    % ./mach marionette test --emulator --app='fennec' --address=127.0.0.1:2828 --disable-e10s
+    % ./mach marionette-test --emulator --app='fennec' --address=127.0.0.1:2828 --disable-e10s
     --startup-timeout=300
 
 If you need to troubleshoot the Marionette connection, the most basic check is
 to start Fennec, make sure the `marionette.enabled` browser preference is
 true and port 2828 is forwarded, then see if you get any response from
 Marionette when you connect manually:
 
     % telnet 127.0.0.1:2828
--- a/testing/marionette/mach_commands.py
+++ b/testing/marionette/mach_commands.py
@@ -4,20 +4,18 @@
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 import argparse
 import os
 import sys
 
 from mach.decorators import (
-    CommandArgument,
     CommandProvider,
     Command,
-    SubCommand,
 )
 
 from mozbuild.base import (
     MachCommandBase,
     MachCommandConditions as conditions,
 )
 
 
@@ -64,56 +62,22 @@ def run_marionette(tests, binary=None, t
     else:
         return 0
 
 
 @CommandProvider
 class MarionetteTest(MachCommandBase):
     @Command("marionette-test",
              category="testing",
-             description="Remote control protocol to Gecko, used for functional UI tests and browser automation.",
+             description="Remote control protocol to Gecko, used for browser automation.",
              conditions=[conditions.is_firefox_or_android],
              parser=create_parser_tests,
              )
-
     def marionette_test(self, tests, **kwargs):
         if "test_objects" in kwargs:
             tests = []
             for obj in kwargs["test_objects"]:
                 tests.append(obj["file_relpath"])
             del kwargs["test_objects"]
 
         if not kwargs.get("binary") and conditions.is_firefox(self):
             kwargs["binary"] = self.get_binary_path("app")
         return run_marionette(tests, topsrcdir=self.topsrcdir, **kwargs)
-
-
-@CommandProvider
-class Marionette(MachCommandBase):
-
-    @property
-    def srcdir(self):
-        return os.path.join(self.topsrcdir, "testing/marionette")
-
-    @Command("marionette",
-             category="misc",
-             description="Remote control protocol to Gecko, used for functional UI tests and browser automation.",
-             conditions=[conditions.is_firefox_or_android],
-             )
-    def marionette(self):
-        self.parser.print_usage()
-        return 1
-
-    @SubCommand("marionette", "test",
-                description="Run browser automation tests based on Marionette harness.",
-                parser=create_parser_tests,
-                )
-    def marionette_test(self, tests, **kwargs):
-        if "test_objects" in kwargs:
-            tests = []
-            for obj in kwargs["test_objects"]:
-                tests.append(obj["file_relpath"])
-            del kwargs["test_objects"]
-
-        if not kwargs.get("binary") and conditions.is_firefox(self):
-            kwargs["binary"] = self.get_binary_path("app")
-        return run_marionette(tests, topsrcdir=self.topsrcdir, **kwargs)
-