@@ -34,11 +34,14 @@ def _checkBaseSubstitutions(substitutions):
34
34
35
35
def _executeScriptInternal (test , litConfig , commands ):
36
36
"""
37
- Returns (stdout, stderr, exitCode, timeoutInfo, parsedCommands)
37
+ Returns (stdout, stderr, exitCode, timeoutInfo, parsedCommands), or an appropriate lit.Test.Result
38
+ in case of an error while parsing the script.
38
39
39
40
TODO: This really should be easier to access from Lit itself
40
41
"""
41
42
parsedCommands = parseScript (test , preamble = commands )
43
+ if isinstance (parsedCommands , lit .Test .Result ):
44
+ return parsedCommands
42
45
43
46
_ , tmpBase = _getTempPaths (test )
44
47
execDir = os .path .dirname (test .getExecPath ())
@@ -65,7 +68,8 @@ def parseScript(test, preamble):
65
68
"""
66
69
Extract the script from a test, with substitutions applied.
67
70
68
- Returns a list of commands ready to be executed.
71
+ Returns a list of commands ready to be executed, or an appropriate lit.Test.Result in case of error
72
+ while parsing the script (this includes the script being unsupported).
69
73
70
74
- test
71
75
The lit.Test to parse.
@@ -350,6 +354,8 @@ def execute(self, test, litConfig):
350
354
if "enable-benchmarks=run" in test .config .available_features :
351
355
steps += ["%dbg(EXECUTED AS) %{exec} %t.exe --benchmark_out=%T/benchmark-result.json --benchmark_out_format=json" ]
352
356
return self ._executeShTest (test , litConfig , steps )
357
+ elif re .search ('[.]gen[.][^.]+$' , filename ): # This only happens when a generator test is not supported
358
+ return self ._executeShTest (test , litConfig , [])
353
359
else :
354
360
return lit .Test .Result (
355
361
lit .Test .UNRESOLVED , "Unknown test suffix for '{}'" .format (filename )
@@ -381,11 +387,19 @@ def _generateGenTest(self, testSuite, pathInSuite, litConfig, localConfig):
381
387
generatorExecDir = os .path .dirname (testSuite .getExecPath (pathInSuite ))
382
388
os .makedirs (generatorExecDir , exist_ok = True )
383
389
384
- # Run the generator test
390
+ # Run the generator test. It's possible for this to fail for two reasons: the generator test
391
+ # is unsupported or the generator ran but failed at runtime -- handle both. In the first case,
392
+ # we return the generator test itself, since it should produce the same result when run after
393
+ # test suite generation. In the second case, it's a true error so we report it.
385
394
steps = [] # Steps must already be in the script
386
- (out , err , exitCode , _ , _ ) = _executeScriptInternal (generator , litConfig , steps )
395
+ result = _executeScriptInternal (generator , litConfig , steps )
396
+ if isinstance (result , lit .Test .Result ):
397
+ yield generator
398
+ return
399
+
400
+ (out , err , exitCode , _ , _ ) = result
387
401
if exitCode != 0 :
388
- raise RuntimeError (f"Error while trying to generate gen test\n stdout:\n { out } \n \n stderr:\n { err } " )
402
+ raise RuntimeError (f"Error while trying to generate gen test { '/' . join ( pathInSuite ) } \n stdout:\n { out } \n \n stderr:\n { err } " )
389
403
390
404
# Split the generated output into multiple files and generate one test for each file
391
405
for subfile , content in self ._splitFile (out ):
0 commit comments