diff --git a/lnt/tests/test_suite.py b/lnt/tests/test_suite.py index 7c93e5c6..2a842369 100644 --- a/lnt/tests/test_suite.py +++ b/lnt/tests/test_suite.py @@ -285,23 +285,30 @@ def run_test(self, opts): opts.only_test = opts.single_result if opts.only_test: - if not opts.exec_mode: - # Only validate against test_suite_root if we're not in exec mode - # --only-test can either point to a particular test or a directory. - # Therefore, test_suite_root + opts.only_test or - # test_suite_root + dirname(opts.only_test) must be a directory. - path = os.path.join(opts.test_suite_root, opts.only_test) - parent_path = os.path.dirname(path) - - if os.path.isdir(path): + # Convert --only-test to tuple format: (directory, test_name or None) + # In non-exec mode, validate against test_suite_root + # In exec mode, validate against build_dir if available + base_path = opts.build_dir if opts.exec_mode and opts.build_dir else opts.test_suite_root + + if base_path: + full_path = os.path.join(base_path, opts.only_test) + parent_path = os.path.dirname(full_path) + + if os.path.isdir(full_path): opts.only_test = (opts.only_test, None) elif os.path.isdir(parent_path): opts.only_test = (os.path.dirname(opts.only_test), os.path.basename(opts.only_test)) - else: + elif not opts.exec_mode: + # In normal mode, path must exist self._fatal("--only-test argument not understood (must be a " + - " test or directory name)") - # else: in exec mode, we'll use only_test as-is for filtering + "test or directory name)") + else: + # In exec mode, path may not exist yet, assume it's a directory + opts.only_test = (opts.only_test, None) + else: + # No base_path available (e.g., exec_interleaved_builds), assume directory + opts.only_test = (opts.only_test, None) if opts.single_result and not opts.only_test[1]: self._fatal("--single-result must be given a single test name, " diff --git a/tests/runtest/test_suite-build-dir.shtest b/tests/runtest/test_suite-build-dir.shtest index 4abd32bc..40075ac9 100644 --- a/tests/runtest/test_suite-build-dir.shtest +++ b/tests/runtest/test_suite-build-dir.shtest @@ -63,3 +63,16 @@ # RUN: > %t.err2.log 2> %t.err2.err # RUN: filecheck --check-prefix CHECK-ERR-UNCONFIGURED < %t.err2.err %s # CHECK-ERR-UNCONFIGURED: --build-dir is not a configured build + +# Test 5: --exec with --build-dir and --only-test (tuple conversion test) +# RUN: lnt runtest test-suite \ +# RUN: --sandbox %t.SANDBOX \ +# RUN: --no-timestamp \ +# RUN: --exec \ +# RUN: --build-dir %t.CUSTOM_BUILD/mybuild \ +# RUN: --only-test SingleSource \ +# RUN: --use-cmake %S/Inputs/test-suite-cmake/fake-cmake \ +# RUN: --use-lit %S/Inputs/test-suite-cmake/fake-lit \ +# RUN: > %t.exec-only.log 2> %t.exec-only.err +# RUN: filecheck --check-prefix CHECK-EXEC-ONLY < %t.exec-only.err %s +# CHECK-EXEC-ONLY: Testing