@@ -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, "
0 commit comments