Bug 1017292 - Make jstests.py start much faster when running only a few tests. r=terrence.
authorJason Orendorff <jorendorff@mozilla.com>
Thu, 05 Jun 2014 13:18:52 -0400
changeset 206441 056fd938efc7344a4cb266974505aa1eeae79699
parent 206440 6775154c5cf22a6fbea4be62b576516e67f9fb82
child 206442 ad465c247417bfb14250ad59f3a10e7616a190d7
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs1017292
milestone32.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 1017292 - Make jstests.py start much faster when running only a few tests. r=terrence.
js/src/tests/jstests.py
js/src/tests/lib/manifest.py
--- a/js/src/tests/jstests.py
+++ b/js/src/tests/jstests.py
@@ -224,17 +224,17 @@ def load_tests(options, requested_paths,
             xul_info = manifest.XULInfo.create(options.js_shell)
         else:
             xul_abi, xul_os, xul_debug = options.xul_info_src.split(r':')
             xul_debug = xul_debug.lower() is 'true'
             xul_info = manifest.XULInfo(xul_abi, xul_os, xul_debug)
         xul_tester = manifest.XULInfoTester(xul_info, options.js_shell)
 
     test_dir = dirname(abspath(__file__))
-    test_list = manifest.load(test_dir, xul_tester)
+    test_list = manifest.load(test_dir, requested_paths, excluded_paths, xul_tester)
     skip_list = []
 
     if options.make_manifests:
         manifest.make_manifests(options.make_manifests, test_list)
         sys.exit()
 
     # Create a new test list. Apply each TBPL configuration to every test.
     if options.tbpl:
@@ -252,27 +252,16 @@ def load_tests(options, requested_paths,
         print("Warning: the --jitflags option is obsolete and does nothing now.")
 
     if options.test_file:
         paths = set()
         for test_file in options.test_file:
             paths |= set([ line.strip() for line in open(test_file).readlines()])
         test_list = [ _ for _ in test_list if _.path in paths ]
 
-    if requested_paths:
-        def p(path):
-            for arg in requested_paths:
-                if path.find(arg) != -1:
-                    return True
-            return False
-        test_list = [ _ for _ in test_list if p(_.path) ]
-
-    if options.exclude_file:
-        test_list = [_ for _ in test_list if _.path not in excluded_paths]
-
     if options.no_extensions:
         pattern = os.sep + 'extensions' + os.sep
         test_list = [_ for _ in test_list if pattern not in _.path]
 
     if not options.random:
         test_list = [ _ for _ in test_list if not _.random ]
 
     if options.run_only_skipped:
--- a/js/src/tests/lib/manifest.py
+++ b/js/src/tests/lib/manifest.py
@@ -327,17 +327,17 @@ def _apply_external_manifests(filename, 
             # conditions.
             # At this point, we use external manifests only for test cases
             # that can't have their own failure type comments, so we simply
             # use the terms for the most specific path.
             testcase.terms = entry["terms"]
             testcase.comment = entry["comment"]
             _parse_one(testcase, xul_tester)
 
-def load(location, xul_tester, reldir = ''):
+def load(location, requested_paths, excluded_paths, xul_tester, reldir = ''):
     """
     Locates all tests by walking the filesystem starting at |location|.
     Uses xul_tester to evaluate any test conditions in the test header.
     Failure type and comment for a test case can come from
     - an external manifest entry for the test case,
     - an external manifest entry for a containing directory,
     - most commonly: the header of the test case itself.
     """
@@ -363,16 +363,24 @@ def load(location, xul_tester, reldir = 
         # Skip files that we know are not tests.
         if basename in EXCLUDED:
             continue
 
         # Get the full path and relative location of the file.
         filename = os.path.join(root, basename)
         fullpath = os.path.join(location, filename)
 
+        # If any tests are requested by name, skip tests that do not match.
+        if requested_paths and not any(req in filename for req in requested_paths):
+            continue
+
+        # Skip excluded tests.
+        if filename in excluded_paths:
+            continue
+
         # Skip empty files.
         statbuf = os.stat(fullpath)
         if statbuf.st_size == 0:
             continue
 
         testcase = TestCase(os.path.join(reldir, filename))
         _apply_external_manifests(filename, testcase, externalManifestEntries, xul_tester)
         _parse_test_header(fullpath, testcase, xul_tester)