Skip to content

Commit

Permalink
make it easy to set whether stderr is silent or noisy in the test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
kripken committed Jan 3, 2012
1 parent 7b7e1b6 commit f6e8383
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/runner.py
Expand Up @@ -35,6 +35,8 @@ def path_from_root(*pathelems):
class RunnerCore(unittest.TestCase):
save_dir = os.environ.get('EM_SAVE_DIR')
save_JS = 0
stderr_redirect = STDOUT # This avoids cluttering the test runner output, which is stderr too, with compiler warnings etc.
# Change this to None to get stderr reporting, for debugging purposes

def setUp(self):
Settings.reset()
Expand Down Expand Up @@ -143,7 +145,7 @@ def build(self, src, dirname, filename, output_processor=None, main_file=None, a
['-I', dirname, '-I', os.path.join(dirname, 'include')] + \
map(lambda include: '-I' + include, includes) + \
['-c', f, '-o', f + '.o']
output = Popen(args, stdout=PIPE).communicate()[0]
output = Popen(args, stdout=PIPE, stderr=self.stderr_redirect).communicate()[0]
assert os.path.exists(f + '.o'), 'Source compilation error: ' + output

os.chdir(cwd)
Expand Down Expand Up @@ -182,7 +184,7 @@ def run_generated_code(self, engine, filename, args=[], check_timeout=True):
return ret

def run_llvm_interpreter(self, args):
return Popen([EXEC_LLVM] + args, stdout=PIPE, stderr=STDOUT).communicate()[0]
return Popen([EXEC_LLVM] + args, stdout=PIPE, stderr=self.stderr_redirect).communicate()[0]

def build_native(self, filename):
Popen([CLANG, '-O2', filename, '-o', filename+'.native'], stdout=PIPE).communicate()[0]
Expand Down Expand Up @@ -3771,7 +3773,7 @@ def test_dlmalloc(self):

try_delete(os.path.join(self.get_dir(), 'src.cpp.o.js'))
output = Popen([EMCC, path_from_root('tests', 'dlmalloc_test.c'),
'-o', os.path.join(self.get_dir(), 'src.cpp.o.js')], stdout=PIPE, stderr=PIPE).communicate()
'-o', os.path.join(self.get_dir(), 'src.cpp.o.js')], stdout=PIPE, stderr=self.stderr_redirect).communicate()
#print output

self.do_run('x', '*1,0*', ['200', '1'], no_build=True)
Expand Down Expand Up @@ -4160,7 +4162,7 @@ def test_cases(self):

# Autodebug the code
def do_autodebug(self, filename):
output = Popen(['python', AUTODEBUGGER, filename+'.o.ll', filename+'.o.ll.ll'], stdout=PIPE, stderr=STDOUT).communicate()[0]
output = Popen(['python', AUTODEBUGGER, filename+'.o.ll', filename+'.o.ll.ll'], stdout=PIPE, stderr=self.stderr_redirect).communicate()[0]
assert 'Success.' in output, output
self.prep_ll_run(filename, filename+'.o.ll.ll', force_recompile=True) # rebuild .bc # TODO: use code in do_autodebug_post for this

Expand All @@ -4172,7 +4174,7 @@ def do_autodebug_post(self, filename):
return True
print 'Autodebugging during post time'
delattr(self, 'post')
output = Popen(['python', AUTODEBUGGER, filename+'.o.ll', filename+'.o.ll.ll'], stdout=PIPE, stderr=STDOUT).communicate()[0]
output = Popen(['python', AUTODEBUGGER, filename+'.o.ll', filename+'.o.ll.ll'], stdout=PIPE, stderr=self.stderr_redirect).communicate()[0]
assert 'Success.' in output, output
shutil.copyfile(filename + '.o.ll.ll', filename + '.o.ll')
Building.llvm_as(filename)
Expand Down Expand Up @@ -4405,7 +4407,7 @@ class Child2 : public Parent {
open(header_filename, 'w').write(header)

basename = os.path.join(self.get_dir(), 'bindingtest')
output = Popen([BINDINGS_GENERATOR, basename, header_filename], stdout=PIPE, stderr=STDOUT).communicate()[0]
output = Popen([BINDINGS_GENERATOR, basename, header_filename], stdout=PIPE, stderr=self.stderr_redirect).communicate()[0]
#print output
assert 'Traceback' not in output, 'Failure in binding generation: ' + output

Expand Down Expand Up @@ -5428,7 +5430,7 @@ def do_benchmark(self, src, args=[], expected_output='FAIL', emcc_args=[]):
try_delete(final_filename)
output = Popen([EMCC, filename, '-O3', '-s', 'USE_TYPED_ARRAYS=1', '-s', 'QUANTUM_SIZE=1',
'-s', 'TOTAL_MEMORY=100*1024*1024', '-s', 'FAST_MEMORY=10*1024*1024',
'-o', final_filename] + emcc_args, stdout=PIPE, stderr=PIPE).communicate()
'-o', final_filename] + emcc_args, stdout=PIPE, stderr=self.stderr_redirect).communicate()
assert os.path.exists(final_filename), 'Failed to compile file: ' + '\n'.join(output)

# Run JS
Expand Down

0 comments on commit f6e8383

Please sign in to comment.