aboutsummaryrefslogtreecommitdiff
path: root/tools/bisect_pair.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-05-04 10:41:41 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-05-04 10:41:41 -0700
commite490418f27d85d89fd7d93ee1e0c25ea25161287 (patch)
tree08ef1e2bf5ce08214ab1a03cc7dae52b328fd526 /tools/bisect_pair.py
parent3c8acde3553d97d6434154980f53ddac73779899 (diff)
fix bisection bug
Diffstat (limited to 'tools/bisect_pair.py')
-rw-r--r--tools/bisect_pair.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/tools/bisect_pair.py b/tools/bisect_pair.py
index 3b880b28..8eea0d61 100644
--- a/tools/bisect_pair.py
+++ b/tools/bisect_pair.py
@@ -47,14 +47,12 @@ if len(curr) > 0:
chunks.append(curr)
# Bisect both sides of the span, until we have a single chunk
-low = 0
high = len(chunks)
print 'beginning bisection, %d chunks' % high
-while high-low > 2:
- mid = (low + high)/2
- print ' current status: %d - %d - %d' % (low, mid, high)
+for mid in range(high):
+ 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')
@@ -64,11 +62,11 @@ while high-low > 2:
Popen(['patch', 'middle', 'diff.diff'], stdout=PIPE, stderr=PIPE).communicate()
result = run_js('middle', stderr=PIPE)
if result == left_result:
- high = mid+1
- else:
- low = mid
+ print 'found where it starts to work: %d' % mid
+ found = mid
+ break
-critical = '\n'.join(chunks[low]) + '\n'
+critical = '\n'.join(chunks[found-1]) + '\n'
c = open('critical.diff', 'w')
c.write(critical)
@@ -76,8 +74,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
-assert run_js('middle2', stderr=PIPE) != left_result
+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
print 'middle is like left, middle2 is like right, critical.diff is the difference that matters,'
print critical