Bug 1583353 - [moztest.resolve] Add ability to resolve manifest paths, r=gbrown
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Fri, 08 Nov 2019 16:01:28 +0000
changeset 501574 7ea00823df0a73594a8aa409ac450ea84a70dc4f
parent 501573 d741ca0e07b1ebc23654dd2f33ad51fdd10ebaae
child 501575 fec55267c096603f0862ff30b68b966c28045d79
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgbrown
bugs1583353
milestone72.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 1583353 - [moztest.resolve] Add ability to resolve manifest paths, r=gbrown While not strictly necessary for this series, this patch allows: ./mach test path/to/manifest.ini Which will be especially useful to have now that we are switching to running tasks by manifest. Depends on D52241 Differential Revision: https://phabricator.services.mozilla.com/D52242
testing/mozbase/moztest/moztest/resolve.py
testing/mozbase/moztest/tests/data/srcdir/apple/a11y.ini
testing/mozbase/moztest/tests/data/srcdir/apple/mochitest.ini
testing/mozbase/moztest/tests/data/srcdir/apple/moz.build
testing/mozbase/moztest/tests/test_resolve.py
--- a/testing/mozbase/moztest/moztest/resolve.py
+++ b/testing/mozbase/moztest/moztest/resolve.py
@@ -537,16 +537,23 @@ class TestResolver(MozbuildObject):
             # If the path is a directory, or the path is a prefix of a directory
             # containing tests, pull in all tests in that directory.
             if (path in self.test_dirs or
                 any(p.startswith(path) for p in self.tests_by_path)):
                 candidate_paths |= {p for p in self.tests_by_path
                                     if p.startswith(path)}
                 continue
 
+            # If the path is a manifest, add all tests defined in that manifest.
+            if any(path.endswith(e) for e in ('.ini', '.list')):
+                key = 'manifest' if os.path.isabs(path) else 'manifest_relpath'
+                candidate_paths |= {t['file_relpath'] for t in self.tests
+                                    if mozpath.normpath(t[key]) == path}
+                continue
+
             # If it's a test file, add just that file.
             candidate_paths |= {p for p in self.tests_by_path if path in p}
 
         for p in sorted(candidate_paths):
             tests = self.tests_by_path[p]
 
             for test in fltr(tests):
                 yield test
rename from testing/mozbase/moztest/tests/data/srcdir/apple/mochitest.ini
rename to testing/mozbase/moztest/tests/data/srcdir/apple/a11y.ini
--- a/testing/mozbase/moztest/tests/data/srcdir/apple/moz.build
+++ b/testing/mozbase/moztest/tests/data/srcdir/apple/moz.build
@@ -1,1 +1,1 @@
-A11Y_MANIFESTS += ["mochitest.ini"]
+A11Y_MANIFESTS += ["a11y.ini"]
--- a/testing/mozbase/moztest/tests/test_resolve.py
+++ b/testing/mozbase/moztest/tests/test_resolve.py
@@ -203,18 +203,28 @@ def test_resolve_support_files(resolver)
     for test in tests:
         if test['manifest'].endswith('xpcshell_updater.ini'):
             assert test['support-files'] == expected_support_files
         else:
             assert 'support-files' not in test
 
 
 def test_resolve_path_prefix(resolver):
-    result = list(resolver._resolve(paths=['juniper']))
-    assert len(result) == 1
+    tests = list(resolver._resolve(paths=['juniper']))
+    assert len(tests) == 1
+
+    # relative manifest
+    tests = list(resolver._resolve(paths=['apple/a11y.ini']))
+    assert len(tests) == 1
+    assert tests[0]['name'] == 'test_a11y.html'
+
+    # absolute manifest
+    tests = list(resolver._resolve(paths=[os.path.join(resolver.topsrcdir, 'apple/a11y.ini')]))
+    assert len(tests) == 1
+    assert tests[0]['name'] == 'test_a11y.html'
 
 
 def test_cwd_children_only(resolver):
     """If cwd is defined, only resolve tests under the specified cwd."""
     # Pretend we're under '/services' and ask for 'common'. This should
     # pick up all tests from '/services/common'
     tests = list(resolver.resolve_tests(paths=['currant'], cwd=os.path.join(resolver.topsrcdir,
         'banana')))