From fe9e88dcf7b11155009fffe4caa7b3482d3f62e3 Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Mon, 22 Feb 2021 20:32:26 +0000 Subject: [PATCH] Bug 1642709 - Make a relative path from topsrcdir work in jstestbrowser. r=jmaher jsreftest tests are staged into objdir, and specifying a path inside it isn't user friendly. Made it automatically try resolving the relative path from staged area, if the relative path doesn't find any test. Differential Revision: https://phabricator.services.mozilla.com/D106010 --- layout/tools/reftest/reftestcommandline.py | 5 ++++- layout/tools/reftest/runreftest.py | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/layout/tools/reftest/reftestcommandline.py b/layout/tools/reftest/reftestcommandline.py index b6fe7fa3d32c..ed0f862cfb5f 100644 --- a/layout/tools/reftest/reftestcommandline.py +++ b/layout/tools/reftest/reftestcommandline.py @@ -308,7 +308,10 @@ class ReftestArgumentsParser(argparse.ArgumentParser): "tests", metavar="TEST_PATH", nargs="*", - help="Path to test file, manifest file, or directory containing tests", + help="Path to test file, manifest file, or directory containing " + "tests. For jstestbrowser, the relative path can be either from " + "topsrcdir or the staged area " + "($OBJDIR/dist/test-stage/jsreftest/tests)", ) self.add_argument( diff --git a/layout/tools/reftest/runreftest.py b/layout/tools/reftest/runreftest.py index 9cb6b2e742ab..c0696df1b7cc 100644 --- a/layout/tools/reftest/runreftest.py +++ b/layout/tools/reftest/runreftest.py @@ -216,7 +216,9 @@ class ReftestResolver(object): """ rv = [] default_manifest = self.defaultManifest(suite) + relative_path = None if not os.path.isabs(test_file): + relative_path = test_file test_file = self.absManifestPath(test_file) if os.path.isdir(test_file): @@ -227,6 +229,18 @@ class ReftestResolver(object): # of include directives we get the same manifest multiple times. # However reftest.js will only read each manifest once + if ( + len(rv) == 0 + and relative_path + and suite == "jstestbrowser" + and build_obj + ): + # The relative path can be from staging area. + staged_js_dir = os.path.join( + build_obj.topobjdir, "dist", "test-stage", "jsreftest" + ) + staged_file = os.path.join(staged_js_dir, "tests", relative_path) + return self.findManifest(suite, staged_file, subdirs) elif test_file.endswith(".list"): if os.path.exists(test_file): rv = [(test_file, None)]