Bug 920184 - Have mach xpcshell-test and mochitest-* update test files automatically; r=ted
authorGregory Szorc <gps@mozilla.com>
Tue, 01 Oct 2013 18:36:44 +0200
changeset 149463 c689b1d342c73c11081f1fba4e48ce33c3534cf8
parent 149462 19045a3843db16ad9d02f6267864a68ee69a1b04
child 149464 f90880fb52481b016d19844b28b574227edf7bdb
push id34568
push usergszorc@mozilla.com
push dateTue, 01 Oct 2013 16:37:24 +0000
treeherdermozilla-inbound@c689b1d342c7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs920184
milestone27.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 920184 - Have mach xpcshell-test and mochitest-* update test files automatically; r=ted
python/mozbuild/mozbuild/controller/building.py
testing/mochitest/mach_commands.py
testing/xpcshell/mach_commands.py
--- a/python/mozbuild/mozbuild/controller/building.py
+++ b/python/mozbuild/mozbuild/controller/building.py
@@ -527,8 +527,22 @@ class BuildMonitor(MozbuildObject):
         params.update(extra_params)
 
         message = prefix + ' - Wall time: {duration:.0f}s; ' \
             'CPU: {cpu_percent:.0f}%; ' \
             'Read bytes: {io_read_bytes}; Write bytes: {io_write_bytes}; ' \
             'Read time: {io_read_time}; Write time: {io_write_time}'
 
         self.log(logging.WARNING, m_type, params, message)
+
+
+class BuildDriver(MozbuildObject):
+    """Provides a high-level API for build actions."""
+
+    def install_tests(self, remove=True):
+        """Install test files (through manifest)."""
+
+        env = {}
+        if not remove:
+            env[b'NO_REMOVE'] = b'1'
+
+        self._run_make(target='install-tests', append_env=env, pass_thru=True,
+            print_directory=False)
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -516,18 +516,23 @@ class MachCommands(MachCommandBase):
     @Command('webapprt-test-content', category='testing',
         conditions=[conditions.is_firefox],
         description='Run a webapprt content mochitest.')
     @MochitestCommand
     def run_mochitest_webapprt_content(self, test_file, **kwargs):
         return self.run_mochitest(test_file, 'webapprt-content', **kwargs)
 
     def run_mochitest(self, test_file, flavor, **kwargs):
+        from mozbuild.controller.building import BuildDriver
+
         self._ensure_state_subdir_exists('.')
 
+        driver = self._spawn(BuildDriver)
+        driver.install_tests(remove=False)
+
         mochitest = self._spawn(MochitestRunner)
 
         return mochitest.run_desktop_test(test_file=test_file, suite=flavor,
             **kwargs)
 
 
 # TODO For now b2g commands will only work with the emulator,
 # they should be modified to work with all devices.
@@ -548,24 +553,33 @@ class B2GCommands(MachCommandBase):
         for attr in ('b2g_home', 'xre_path', 'device_name'):
             setattr(self, attr, getattr(context, attr, None))
 
     @Command('mochitest-remote', category='testing',
         description='Run a remote mochitest.',
         conditions=[conditions.is_b2g, is_emulator])
     @B2GCommand
     def run_mochitest_remote(self, test_file, **kwargs):
+        from mozbuild.controller.building import BuildDriver
+
         self._ensure_state_subdir_exists('.')
 
+        driver = self._spawn(BuildDriver)
+        driver.install_tests(remove=False)
+
         mochitest = self._spawn(MochitestRunner)
         return mochitest.run_b2g_test(b2g_home=self.b2g_home,
                 xre_path=self.xre_path, test_file=test_file, **kwargs)
 
     @Command('mochitest-b2g-desktop', category='testing',
         conditions=[conditions.is_b2g_desktop],
         description='Run a b2g desktop mochitest.')
     @B2GCommand
     def run_mochitest_b2g_desktop(self, test_file, **kwargs):
+        from mozbuild.controller.building import BuildDriver
+
         self._ensure_state_subdir_exists('.')
 
+        driver = self._spawn(BuildDriver)
+        driver.install_tests(remove=False)
+
         mochitest = self._spawn(MochitestRunner)
         return mochitest.run_b2g_test(test_file=test_file, **kwargs)
-
--- a/testing/xpcshell/mach_commands.py
+++ b/testing/xpcshell/mach_commands.py
@@ -221,20 +221,25 @@ class MachCommands(MachCommandBase):
         help='Continue running tests after a SIGINT is received.')
     @CommandArgument('--sequential', action='store_true',
         help='Run the tests sequentially.')
     @CommandArgument('--shuffle', '-s', action='store_true',
         help='Randomize the execution order of tests.')
     @CommandArgument('--rerun-failures', action='store_true',
         help='Reruns failures from last time.')
     def run_xpcshell_test(self, **params):
+        from mozbuild.controller.building import BuildDriver
+
         # We should probably have a utility function to ensure the tree is
         # ready to run tests. Until then, we just create the state dir (in
         # case the tree wasn't built with mach).
         self._ensure_state_subdir_exists('.')
 
+        driver = self._spawn(BuildDriver)
+        driver.install_tests(remove=False)
+
         xpcshell = self._spawn(XPCShellRunner)
 
         try:
             return xpcshell.run_test(**params)
         except InvalidTestPathError as e:
             print(e.message)
             return 1