diff --git a/python/integration-tests/testIntegration.py b/python/integration-tests/testIntegration.py index d59cf9d4..634e7427 100644 --- a/python/integration-tests/testIntegration.py +++ b/python/integration-tests/testIntegration.py @@ -1,6 +1,7 @@ import shell import unittest import os +import re def run(path, input='', tycheck=True, ecode=0): flags = ['--quiet', '--no-clear'] @@ -30,6 +31,11 @@ def stripTrailingWs(s): s = s.strip() return '\n'.join([l.rstrip() for l in s.split('\n')]) +def removeFilePaths(s): + s = re.sub(r"declared at: .*", '', s) + s = re.sub(r"caused by: .*", '', s) + return s + LOG_FILE = shell.mkTempFile(prefix="wypp-tests", suffix=".log", deleteAtExit='ifSuccess') print(f'Output of integration tests goes to {LOG_FILE}') LOG_REDIR = f'>> {LOG_FILE} 2>&1' @@ -145,7 +151,7 @@ def test_types2(self): 2 | return x + 1 caused by: :1""" - self.assertEqual(expected, out) + self.assertEqual(removeFilePaths(expected), removeFilePaths(out)) def test_types3(self): out = runInteractive('test-data/testTypesInteractive.py', diff --git a/python/src/runner.py b/python/src/runner.py index 86f04310..d4bca68b 100644 --- a/python/src/runner.py +++ b/python/src/runner.py @@ -264,6 +264,7 @@ def __exit__(self, exc_type, value, traceback): def runCode(fileToRun, globals, args, useUntypy=True): localDir = os.path.dirname(fileToRun) + fileToRun = os.path.realpath(fileToRun) # needed for setting __file__ with sysPathPrepended(localDir): with open(fileToRun) as f: flags = 0 | anns.compiler_flag @@ -285,6 +286,8 @@ def runCode(fileToRun, globals, args, useUntypy=True): oldArgs = sys.argv try: sys.argv = [fileToRun] + args + # set modules globals + globals['__file__'] = fileToRun exec(compiledCode, globals) finally: sys.argv = oldArgs