aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtests/runner.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 879c279b..66100b8f 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -263,7 +263,7 @@ process(sys.argv[1])
if output_processor is not None:
output_processor(open(filename + '.o.js').read())
- def run_generated_code(self, engine, filename, args=[], check_timeout=True):
+ def run_generated_code(self, engine, filename, args=[], check_timeout=True, output_nicerizer=None):
stdout = os.path.join(self.get_dir(), 'stdout') # use files, as PIPE can get too full and hang us
stderr = os.path.join(self.get_dir(), 'stderr')
try:
@@ -274,7 +274,12 @@ process(sys.argv[1])
run_js(filename, engine, args, check_timeout, stdout=open(stdout, 'w'), stderr=open(stderr, 'w'))
if cwd is not None:
os.chdir(cwd)
- ret = open(stdout, 'r').read() + open(stderr, 'r').read()
+ out = open(stdout, 'r').read()
+ err = open(stderr, 'r').read()
+ if output_nicerizer:
+ ret = output_nicerizer(out, err)
+ else:
+ ret = out + err
assert 'strict warning:' not in ret, 'We should pass all strict mode checks: ' + ret
return ret
@@ -451,9 +456,7 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv) and 'brows
js_engines = filter(lambda engine: engine not in self.banned_js_engines, js_engines)
if len(js_engines) == 0: return self.skip('No JS engine present to run this test with. Check %s and the paths therein.' % EM_CONFIG)
for engine in js_engines:
- js_output = self.run_generated_code(engine, filename + '.o.js', args)
- if output_nicerizer is not None:
- js_output = output_nicerizer(js_output)
+ js_output = self.run_generated_code(engine, filename + '.o.js', args, output_nicerizer=output_nicerizer)
self.assertContained(expected_output, js_output.replace('\r\n', '\n'))
self.assertNotContained('ERROR', js_output)
@@ -3920,7 +3923,7 @@ The current type of b is: 9
return 0;
}
'''
- def check(result):
+ def check(result, err):
return hashlib.sha1(result).hexdigest()
self.do_run(src, '6c9cdfe937383b79e52ca7a2cce83a21d9f5422c',
output_nicerizer = check)
@@ -4233,7 +4236,7 @@ def process(filename):
open(filename, 'w').write(src)
'''
self.do_run(src, 'Sort with main comparison: 5 4 3 2 1 *Sort with lib comparison: 1 2 3 4 5 *',
- output_nicerizer=lambda x: x.replace('\n', '*'),
+ output_nicerizer=lambda x, err: x.replace('\n', '*'),
post_build=add_pre_run_and_checks)
def test_dlfcn_data_and_fptr(self):
@@ -4337,7 +4340,7 @@ def process(filename):
open(filename, 'w').write(src)
'''
self.do_run(src, 'In func: 13*First calling main_fptr from lib.*Second calling lib_fptr from main.*parent_func called from child*parent_func called from child*Var: 42*',
- output_nicerizer=lambda x: x.replace('\n', '*'),
+ output_nicerizer=lambda x, err: x.replace('\n', '*'),
post_build=add_pre_run_and_checks)
def test_dlfcn_alias(self):
@@ -4392,7 +4395,7 @@ def process(filename):
open(filename, 'w').write(src)
'''
self.do_run(src, 'Parent global: 123.*Parent global: 456.*',
- output_nicerizer=lambda x: x.replace('\n', '*'),
+ output_nicerizer=lambda x, err: x.replace('\n', '*'),
post_build=add_pre_run_and_checks,
extra_emscripten_args=['-H', 'libc/fcntl.h,libc/sys/unistd.h,poll.h,libc/math.h,libc/time.h,libc/langinfo.h'])
Settings.INCLUDE_FULL_LIBRARY = 0
@@ -6438,7 +6441,7 @@ void*:16
self.do_ll_run(path_from_root('tests', 'lua', 'lua.ll'),
'hello lua world!\n17\n1\n2\n3\n4\n7',
args=['-e', '''print("hello lua world!");print(17);for x = 1,4 do print(x) end;print(10-3)'''],
- output_nicerizer=lambda string: string.replace('\n\n', '\n').replace('\n\n', '\n'),
+ output_nicerizer=lambda string, err: (string + err).replace('\n\n', '\n').replace('\n\n', '\n'),
extra_emscripten_args=['-H', 'libc/fcntl.h,libc/sys/unistd.h,poll.h,libc/math.h,libc/langinfo.h,libc/time.h'])
finally:
del os.environ['EMCC_LEAVE_INPUTS_RAW']
@@ -6649,7 +6652,7 @@ def process(filename):
# We use doubles in JS, so we get slightly different values than native code. So we
# check our output by comparing the average pixel difference
- def image_compare(output):
+ def image_compare(output, err):
# Get the image generated by JS, from the JSON.stringify'd array
m = re.search('\[[\d, -]*\]', output)
try:
@@ -7642,7 +7645,7 @@ def process(filename):
}
'''
- def check(output):
+ def check(output, err):
# TODO: check the line #
if self.emcc_args is None or self.emcc_args == []: # LLVM full opts optimize out some corrections
assert re.search('^Overflow\|.*src.cpp:6 : 60 hits, %20 failures$', output, re.M), 'no indication of Overflow corrections: ' + output