@@ -34,11 +34,14 @@ def _checkBaseSubstitutions(substitutions):
3434
3535def _executeScriptInternal (test , litConfig , commands ):
3636 """
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.
3839
3940 TODO: This really should be easier to access from Lit itself
4041 """
4142 parsedCommands = parseScript (test , preamble = commands )
43+ if isinstance (parsedCommands , lit .Test .Result ):
44+ return parsedCommands
4245
4346 _ , tmpBase = _getTempPaths (test )
4447 execDir = os .path .dirname (test .getExecPath ())
@@ -65,7 +68,8 @@ def parseScript(test, preamble):
6568 """
6669 Extract the script from a test, with substitutions applied.
6770
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).
6973
7074 - test
7175 The lit.Test to parse.
@@ -350,6 +354,8 @@ def execute(self, test, litConfig):
350354 if "enable-benchmarks=run" in test .config .available_features :
351355 steps += ["%dbg(EXECUTED AS) %{exec} %t.exe --benchmark_out=%T/benchmark-result.json --benchmark_out_format=json" ]
352356 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 , [])
353359 else :
354360 return lit .Test .Result (
355361 lit .Test .UNRESOLVED , "Unknown test suffix for '{}'" .format (filename )
@@ -381,11 +387,19 @@ def _generateGenTest(self, testSuite, pathInSuite, litConfig, localConfig):
381387 generatorExecDir = os .path .dirname (testSuite .getExecPath (pathInSuite ))
382388 os .makedirs (generatorExecDir , exist_ok = True )
383389
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.
385394 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
387401 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 } " )
389403
390404 # Split the generated output into multiple files and generate one test for each file
391405 for subfile , content in self ._splitFile (out ):
0 commit comments