@@ -2445,7 +2445,7 @@ class LinuxTimer(TimerBase):
2445
2445
2446
2446
2447
2447
# Walk the given directory and return all test files.
2448
- def findTests (paths , expand_globs = False ):
2448
+ def findTests (paths , * , cwd = None , expand_globs = False ):
2449
2449
tests = []
2450
2450
2451
2451
ignore_files = getOption ("IgnoreFiles" , "" ).split ()
@@ -2454,14 +2454,20 @@ def findTests(paths, expand_globs=False):
2454
2454
expanded = set ()
2455
2455
2456
2456
for p in paths :
2457
- p = os .path .join (TestBase , p )
2457
+ anchored = os .path .join (TestBase , p )
2458
2458
2459
2459
if expand_globs :
2460
- for d in glob .glob (p ):
2460
+ for d in glob .glob (anchored ):
2461
2461
if os .path .isdir (d ):
2462
2462
expanded .add (d )
2463
2463
else :
2464
- expanded .add (p )
2464
+ # Allow relative directories if this one does not exist
2465
+ if cwd and not os .path .exists (anchored ):
2466
+ from_cwd = cwd / p
2467
+ if from_cwd .exists ():
2468
+ anchored = str (from_cwd )
2469
+
2470
+ expanded .add (anchored )
2465
2471
2466
2472
for path in expanded :
2467
2473
rpath = os .path .relpath (path , TestBase )
@@ -3081,6 +3087,7 @@ if __name__ == "__main__":
3081
3087
transform = lambda x : normalize_path (x ),
3082
3088
)
3083
3089
3090
+ orig_cwd = pathlib .Path .cwd ()
3084
3091
os .chdir (TestBase )
3085
3092
3086
3093
if Options .sphinx :
@@ -3216,13 +3223,13 @@ if __name__ == "__main__":
3216
3223
3217
3224
testdirs = getOption ("TestDirs" , "" ).split ()
3218
3225
if testdirs :
3219
- Config .configured_tests = findTests (testdirs , True )
3226
+ Config .configured_tests = findTests (testdirs , expand_globs = True )
3220
3227
3221
3228
if args :
3222
3229
if Options .tests_file :
3223
3230
error ("cannot specify tests both on command line and with --tests-file" )
3224
3231
3225
- tests = findTests (args )
3232
+ tests = findTests (args , cwd = orig_cwd )
3226
3233
3227
3234
else :
3228
3235
if Options .rerun :
0 commit comments