summaryrefslogtreecommitdiff
path: root/auto_update_tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'auto_update_tests.py')
-rwxr-xr-xauto_update_tests.py37
1 files changed, 26 insertions, 11 deletions
diff --git a/auto_update_tests.py b/auto_update_tests.py
index 0a42d8357..8e33e1517 100755
--- a/auto_update_tests.py
+++ b/auto_update_tests.py
@@ -96,32 +96,47 @@ print '\n[ checking example testcases... ]\n'
for t in sorted(os.listdir(os.path.join('test', 'example'))):
output_file = os.path.join('bin', 'example')
cmd = ['-Isrc', '-g', '-lasmjs', '-lsupport', '-Llib/.', '-pthread', '-o', output_file]
- if t.endswith('.cpp'):
- cmd = [os.path.join('test', 'example', t),
- os.path.join('src', 'passes', 'pass.cpp'),
- os.path.join('src', 'wasm.cpp'),
- os.path.join('src', 'passes', 'Print.cpp')] + cmd
- elif t.endswith('.c'):
+ if t.endswith('.txt'):
+ # check if there is a trace in the file, if so, we should build it
+ out = subprocess.Popen([os.path.join('scripts', 'clean_c_api_trace.py'), os.path.join('test', 'example', t)], stdout=subprocess.PIPE).communicate()[0]
+ if len(out) == 0:
+ print ' (no trace in ', t, ')'
+ continue
+ print ' (will check trace in ', t, ')'
+ src = 'trace.cpp'
+ open(src, 'w').write(out)
+ expected = os.path.join('test', 'example', t + '.txt')
+ else:
+ src = os.path.join('test', 'example', t)
+ expected = os.path.join('test', 'example', '.'.join(t.split('.')[:-1]) + '.txt')
+ if src.endswith(('.c', '.cpp')):
# build the C file separately
extra = [os.environ.get('CC') or 'gcc',
- os.path.join('test', 'example', t), '-c', '-o', 'example.o',
+ src, '-c', '-o', 'example.o',
'-Isrc', '-g', '-Llib/.', '-pthread']
- print ' '.join(extra)
+ print 'build: ', ' '.join(extra)
subprocess.check_call(extra)
# Link against the binaryen C library DSO, using an executable-relative rpath
cmd = ['example.o', '-lbinaryen'] + cmd + ['-Wl,-rpath=$ORIGIN/../lib']
else:
continue
+ print ' ', t, src, expected
if os.environ.get('COMPILER_FLAGS'):
for f in os.environ.get('COMPILER_FLAGS').split(' '):
cmd.append(f)
cmd = [os.environ.get('CXX') or 'g++', '-std=c++11'] + cmd
- print ' '.join(cmd)
try:
+ print 'link: ', ' '.join(cmd)
subprocess.check_call(cmd)
- actual = subprocess.Popen([output_file], stdout=subprocess.PIPE).communicate()[0]
- open(os.path.join('test', 'example', '.'.join(t.split('.')[:-1]) + '.txt'), 'w').write(actual)
+ print 'run...', output_file
+ proc = subprocess.Popen([output_file], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ actual, err = proc.communicate()
+ assert proc.returncode == 0, [proc.returncode, actual, err]
+ open(expected, 'w').write(actual)
finally:
os.remove(output_file)
+ if sys.platform == 'darwin':
+ # Also removes debug directory produced on Mac OS
+ shutil.rmtree(output_file + '.dSYM')
print '\n[ success! ]'