diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-12-06 18:21:01 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-12-07 14:23:24 -0800 |
commit | bc9ae1361971f1f4d6bfa4af63d027f5e5bc30c4 (patch) | |
tree | 70a012100f89e49c6a07b87b64c9d04f1d390566 | |
parent | 556924460a93c8d7218225b8c52c4de1fef3c730 (diff) |
improve bisection tool to not ignore stderr
-rw-r--r-- | tools/bisect_pair.py | 17 | ||||
-rw-r--r-- | tools/shared.py | 9 |
2 files changed, 16 insertions, 10 deletions
diff --git a/tools/bisect_pair.py b/tools/bisect_pair.py index 8eea0d61..2707c4a3 100644 --- a/tools/bisect_pair.py +++ b/tools/bisect_pair.py @@ -23,9 +23,12 @@ rightf = open('right', 'w') rightf.write(file2) rightf.close() +def run_code(name): + return run_js(name, stderr=PIPE, full_output=True).replace(name, 'FILENAME') + print 'running files' -left_result = run_js('left', stderr=PIPE) -right_result = run_js('right', stderr=PIPE) # right as in left-right, not as in correct +left_result = run_code('left') +right_result = run_code('right') # right as in left-right, not as in correct assert left_result != right_result # Calculate diff chunks @@ -59,8 +62,10 @@ for mid in range(high): difff.write(curr_diff) difff.close() shutil.copy('left', 'middle') - Popen(['patch', 'middle', 'diff.diff'], stdout=PIPE, stderr=PIPE).communicate() - result = run_js('middle', stderr=PIPE) + Popen(['patch', 'middle', 'diff.diff'], stdout=PIPE).communicate() + result = run_code('middle') + if mid == 0: assert result == right_result, '<<< ' + result + ' ??? ' + right_result + ' >>>' + if mid == high-1: assert result == left_result, '<<< ' + result + ' ??? ' + right_result + ' >>>' if result == left_result: print 'found where it starts to work: %d' % mid found = mid @@ -74,8 +79,8 @@ c.close() print 'sanity check' shutil.copy('middle', 'middle2') Popen(['patch', 'middle2', 'critical.diff'], stdout=PIPE, stderr=PIPE).communicate() -assert run_js('middle', stderr=PIPE) == left_result, 'middle was expected %s' % left_result -assert run_js('middle2', stderr=PIPE) != left_result, 'middle2 was expected NOT %s' % left_result +assert run_code('middle') == left_result, 'middle was expected %s' % left_result +assert run_code('middle2') != left_result, 'middle2 was expected NOT %s' % left_result print 'middle is like left, middle2 is like right, critical.diff is the difference that matters,' print critical diff --git a/tools/shared.py b/tools/shared.py index 86a5ba77..18a32d27 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -433,7 +433,7 @@ def check_engine(engine): print 'Checking JS engine %s failed. Check %s. Details: %s' % (str(engine), EM_CONFIG, str(e)) return False -def timeout_run(proc, timeout, note='unnamed process'): +def timeout_run(proc, timeout, note='unnamed process', full_output=False): start = time.time() if timeout is not None: while time.time() - start < timeout and proc.poll() is None: @@ -441,13 +441,14 @@ def timeout_run(proc, timeout, note='unnamed process'): if proc.poll() is None: proc.kill() # XXX bug: killing emscripten.py does not kill it's child process! raise Exception("Timed out: " + note) - return proc.communicate()[0] + out = proc.communicate() + return '\n'.join(out) if full_output else out[0] -def run_js(filename, engine=None, args=[], check_timeout=False, stdout=PIPE, stderr=None, cwd=None): +def run_js(filename, engine=None, args=[], check_timeout=False, stdout=PIPE, stderr=None, cwd=None, full_output=False): if engine is None: engine = JS_ENGINES[0] if type(engine) is not list: engine = [engine] command = engine + [filename] + (['--'] if 'd8' in engine[0] else []) + args - return timeout_run(Popen(command, stdout=stdout, stderr=stderr, cwd=cwd), 15*60 if check_timeout else None, 'Execution') + return timeout_run(Popen(command, stdout=stdout, stderr=stderr, cwd=cwd), 15*60 if check_timeout else None, 'Execution', full_output=full_output) def to_cc(cxx): # By default, LLVM_GCC and CLANG are really the C++ versions. This gets an explicit C version |