diff --git a/.ci/JSONCDecoder.py b/.ci/JSONCDecoder.py new file mode 100644 index 0000000..dbf746b --- /dev/null +++ b/.ci/JSONCDecoder.py @@ -0,0 +1,12 @@ +# https://stackoverflow.com/a/72168909 +import json +from typing import Any +class JSONCDecoder( json.JSONDecoder ): + def __init__( self, **kw ) : + super().__init__( **kw ) + + def decode( self, s : str ) -> Any : + # Sanitize the input string for leading // comments ONLY and replace with + # blank line so that line numbers are preserved + s = '\n'.join( l if not l.lstrip().startswith( "//" ) else "" for l in s.split( '\n' ) ) + return super().decode( s ) diff --git a/.ci/runner.py b/.ci/runner.py index 99257d8..42a638a 100755 --- a/.ci/runner.py +++ b/.ci/runner.py @@ -12,7 +12,7 @@ from contextlib import redirect_stdout from datetime import timedelta - +import JSONCDecoder import SubmitCommon as sc from SubmitAction import SubmitAction @@ -518,7 +518,7 @@ def runSuite( options ) : with redirect_stdout( redirect ) : testSuite = Suite( basename, - json.load( fp ), + json.load( fp, cls=JSONCDecoder.JSONCDecoder ), opts, options, parent=options.globalPrefix, @@ -529,13 +529,13 @@ def runSuite( options ) : # print( options.message ) else : testSuite = Suite( - basename, - json.load( fp ), - opts, - options, - parent=options.globalPrefix, - rootDir=root - ) + basename, + json.load( fp, cls=JSONCDecoder.JSONCDecoder ), + opts, + options, + parent=options.globalPrefix, + rootDir=root + ) success, logs = testSuite.run( options.tests ) # if success and options.message : # print( options.message )