diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-12-06 18:57:06 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-12-07 14:23:24 -0800 |
commit | cdaf0e156e7eed0d8d591bddc143df55017dfb4f (patch) | |
tree | 2041a1852d7abd38c9a35caa3a9c0db986dc2798 /tools/bisect_pair.py | |
parent | bc9ae1361971f1f4d6bfa4af63d027f5e5bc30c4 (diff) |
fully handle stack traces in bisection tool
Diffstat (limited to 'tools/bisect_pair.py')
-rw-r--r-- | tools/bisect_pair.py | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/tools/bisect_pair.py b/tools/bisect_pair.py index 2707c4a3..cdb76286 100644 --- a/tools/bisect_pair.py +++ b/tools/bisect_pair.py @@ -24,7 +24,10 @@ rightf.write(file2) rightf.close() def run_code(name): - return run_js(name, stderr=PIPE, full_output=True).replace(name, 'FILENAME') + ret = run_js(name, stderr=PIPE, full_output=True) + # fix stack traces + ret = filter(lambda line: not line.startswith(' at ') and not name in line, ret.split('\n')) + return '\n'.join(ret) print 'running files' left_result = run_code('left') @@ -55,7 +58,7 @@ high = len(chunks) print 'beginning bisection, %d chunks' % high for mid in range(high): - print ' current: %d' % mid + print ' current: %d' % mid, # Take chunks from the middle and on. This is important because the eliminator removes variables, so starting from the beginning will add errors curr_diff = '\n'.join(map(lambda parts: '\n'.join(parts), chunks[mid:])) + '\n' difff = open('diff.diff', 'w') @@ -63,25 +66,23 @@ for mid in range(high): difff.close() shutil.copy('left', 'middle') Popen(['patch', 'middle', 'diff.diff'], stdout=PIPE).communicate() + shutil.copyfile('middle', 'middle' + str(mid)) 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 + print result == left_result, result == right_result#, 'XXX', left_result, 'YYY', result, 'ZZZ', right_result + if mid == 0: + assert result == right_result, '<<< ' + result + ' ??? ' + right_result + ' >>>' + print 'sanity check passed (a)' + if mid == high-1: + assert result == left_result, '<<< ' + result + ' ??? ' + left_result + ' >>>' + print 'sanity check passed (b)' + if result != right_result: + print 'found where it changes: %d' % mid found = mid break -critical = '\n'.join(chunks[found-1]) + '\n' - +critical = Popen(['diff', '-U', '5', 'middle' + str(mid-1), 'middle' + str(mid)], stdout=PIPE).communicate()[0] c = open('critical.diff', 'w') c.write(critical) c.close() -print 'sanity check' -shutil.copy('middle', 'middle2') -Popen(['patch', 'middle2', 'critical.diff'], stdout=PIPE, stderr=PIPE).communicate() -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 +print 'middle%d is like left, middle%d is like right, critical.diff is the difference that matters' % (mid-1, mid), 'diff:', critical |