Bug 1222603 - talos --print-tests and --print-suites are broken. r=jmaher, a=test-only
authorJulien Pagès <j.parkouss@gmail.com>
Sat, 21 Nov 2015 12:47:30 +0100
changeset 305759 1336d8c3418f5d0158ed7badbbf3318fa8767a5d
parent 305758 333e0792b3e2104707489f601360c29353febc0c
child 305760 87aa3bcf4e4c9906985f6bcf1e23c307b8400bd3
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher, test-only
bugs1222603
milestone44.0a2
Bug 1222603 - talos --print-tests and --print-suites are broken. r=jmaher, a=test-only
testing/talos/mach_commands.py
--- a/testing/talos/mach_commands.py
+++ b/testing/talos/mach_commands.py
@@ -4,33 +4,22 @@
 
 # Integrates Talos mozharness with mach
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 import os
 import sys
 import json
-import which
 import socket
 
-from mozbuild.base import (
-    MozbuildObject,
-    MachCommandBase
-)
-
-from mach.decorators import (
-    CommandArgument,
-    CommandProvider,
-    Command,
-)
+from mozbuild.base import MozbuildObject, MachCommandBase
+from mach.decorators import CommandProvider, Command
 
 HERE = os.path.dirname(os.path.realpath(__file__))
-sys.path.append(os.path.join(HERE, 'talos'))
-from cmdline import create_parser
 
 
 class TalosRunner(MozbuildObject):
     def run_test(self, talos_args):
         """
         We want to do couple of things before running Talos
         1. Clone mozharness
         2. Make config for Talos Mozharness
@@ -80,17 +69,17 @@ class TalosRunner(MozbuildObject):
             ],
             'talos_extra_options': ['--develop'] + self.talos_args,
         }
 
     def make_args(self):
         self.args = {
             'config': {},
             'initial_config_file': self.config_file_path,
-       }
+        }
 
     def write_config(self):
         try:
             config_file = open(self.config_file_path, 'wb')
             config_file.write(json.dumps(self.config))
         except IOError as e:
             err_str = "Error writing to Talos Mozharness config file {0}:{1}"
             print(err_str.format(self.config_file_path, str(e)))
@@ -98,21 +87,28 @@ class TalosRunner(MozbuildObject):
 
     def run_mozharness(self):
         sys.path.insert(0, self.mozharness_dir)
         from mozharness.mozilla.testing.talos import Talos
         talos_mh = Talos(config=self.args['config'],
                          initial_config_file=self.args['initial_config_file'])
         return talos_mh.run()
 
+
+def create_parser():
+    sys.path.insert(0, HERE)  # allow to import the talos package
+    from talos.cmdline import create_parser
+    return create_parser(mach_interface=True)
+
+
 @CommandProvider
 class MachCommands(MachCommandBase):
     @Command('talos-test', category='testing',
              description='Run talos tests (performance testing).',
-             parser=lambda: create_parser(mach_interface=True))
+             parser=create_parser)
     def run_talos_test(self, **kwargs):
         talos = self._spawn(TalosRunner)
 
         try:
             return talos.run_test(sys.argv[2:])
         except Exception as e:
             print(str(e))
             return 1