Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion python/integration-tests/testIntegration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import shell
import unittest
import os
import re

def run(path, input='', tycheck=True, ecode=0):
flags = ['--quiet', '--no-clear']
Expand Down Expand Up @@ -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: .*", '<omitted>', s)
s = re.sub(r"caused by: .*", '<omitted>', 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'
Expand Down Expand Up @@ -145,7 +151,7 @@ def test_types2(self):
2 | return x + 1

caused by: <console>:1"""
self.assertEqual(expected, out)
self.assertEqual(removeFilePaths(expected), removeFilePaths(out))

def test_types3(self):
out = runInteractive('test-data/testTypesInteractive.py',
Expand Down
3 changes: 3 additions & 0 deletions python/src/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down