Skip to content

Commit 575348e

Browse files
authored
Fix --exec with --only-test by converting to tuple format (#130)
1 parent dad2c2b commit 575348e

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

lnt/tests/test_suite.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -285,23 +285,30 @@ def run_test(self, opts):
285285
opts.only_test = opts.single_result
286286

287287
if opts.only_test:
288-
if not opts.exec_mode:
289-
# Only validate against test_suite_root if we're not in exec mode
290-
# --only-test can either point to a particular test or a directory.
291-
# Therefore, test_suite_root + opts.only_test or
292-
# test_suite_root + dirname(opts.only_test) must be a directory.
293-
path = os.path.join(opts.test_suite_root, opts.only_test)
294-
parent_path = os.path.dirname(path)
295-
296-
if os.path.isdir(path):
288+
# Convert --only-test to tuple format: (directory, test_name or None)
289+
# In non-exec mode, validate against test_suite_root
290+
# In exec mode, validate against build_dir if available
291+
base_path = opts.build_dir if opts.exec_mode and opts.build_dir else opts.test_suite_root
292+
293+
if base_path:
294+
full_path = os.path.join(base_path, opts.only_test)
295+
parent_path = os.path.dirname(full_path)
296+
297+
if os.path.isdir(full_path):
297298
opts.only_test = (opts.only_test, None)
298299
elif os.path.isdir(parent_path):
299300
opts.only_test = (os.path.dirname(opts.only_test),
300301
os.path.basename(opts.only_test))
301-
else:
302+
elif not opts.exec_mode:
303+
# In normal mode, path must exist
302304
self._fatal("--only-test argument not understood (must be a " +
303-
" test or directory name)")
304-
# else: in exec mode, we'll use only_test as-is for filtering
305+
"test or directory name)")
306+
else:
307+
# In exec mode, path may not exist yet, assume it's a directory
308+
opts.only_test = (opts.only_test, None)
309+
else:
310+
# No base_path available (e.g., exec_interleaved_builds), assume directory
311+
opts.only_test = (opts.only_test, None)
305312

306313
if opts.single_result and not opts.only_test[1]:
307314
self._fatal("--single-result must be given a single test name, "

tests/runtest/test_suite-build-dir.shtest

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,16 @@
6363
# RUN: > %t.err2.log 2> %t.err2.err
6464
# RUN: filecheck --check-prefix CHECK-ERR-UNCONFIGURED < %t.err2.err %s
6565
# CHECK-ERR-UNCONFIGURED: --build-dir is not a configured build
66+
67+
# Test 5: --exec with --build-dir and --only-test (tuple conversion test)
68+
# RUN: lnt runtest test-suite \
69+
# RUN: --sandbox %t.SANDBOX \
70+
# RUN: --no-timestamp \
71+
# RUN: --exec \
72+
# RUN: --build-dir %t.CUSTOM_BUILD/mybuild \
73+
# RUN: --only-test SingleSource \
74+
# RUN: --use-cmake %S/Inputs/test-suite-cmake/fake-cmake \
75+
# RUN: --use-lit %S/Inputs/test-suite-cmake/fake-lit \
76+
# RUN: > %t.exec-only.log 2> %t.exec-only.err
77+
# RUN: filecheck --check-prefix CHECK-EXEC-ONLY < %t.exec-only.err %s
78+
# CHECK-EXEC-ONLY: Testing

0 commit comments

Comments
 (0)