Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
64 lines (50 loc) · 2.12 KB

File metadata and controls

64 lines (50 loc) · 2.12 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Copyright 2017 The Emscripten Authors. All rights reserved.
# Emscripten is available under two separate licenses, the MIT license and the
# University of Illinois/NCSA Open Source License. Both these licenses can be
# found in the LICENSE file.
'''
Given two similar files, for example one with an additional optimization pass,
and with different results, will bisect between them to find the smallest
diff that makes the outputs different.
Unlike bisect_pairs, this uses lines instead of diffs. We replace line by line. This assumes
the programs differ on each line but lines have not been added or removed
'''
from __future__ import print_function
import os, sys, shutil
from pathlib import Path
from subprocess import Popen, PIPE, STDOUT
__rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
def path_from_root(*pathelems):
return os.path.join(__rootpath__, *pathelems)
exec(Path(path_from_root('tools', 'shared.py').read())
shutil.copyfile(sys.argv[1], 'left')
shutil.copyfile(sys.argv[2], 'right')
def run_code(name):
ret = run_js(name, stderr=PIPE, full_output=True)
# fix stack traces
ret = [line for line in ret.split('\n') if not line.startswith(' at ') and not name in line]
return '\n'.join(ret)
print('running files')
left_result = run_code('left')
right_result = run_code('right') # right as in left-right, not as in correct
assert left_result != right_result
low = 0
high = file1.count('\n')
print('beginning bisection, %d lines' % high)
left_lines = file1.split('\n')
right_lines = file2.split('\n')
while True:
mid = int((low + high)/2)
print(low, high, ' current: %d' % mid, end=' ')
Path('middle').write_text('\n'.join(left_lines[:mid] + right_lines[mid:]))
shutil.copyfile('middle', 'middle' + str(mid))
result = run_code('middle')
print(result == left_result, result == right_result)#, 'XXX', left_result, 'YYY', result, 'ZZZ', right_result
if mid == low or mid == high: break
if result == right_result:
low = mid
elif result == left_result:
high = mid
else:
raise Exception('new result!?!?')
print('middle%d is like left, middle%d is like right' % (mid+1, mid))
Morty Proxy This is a proxified and sanitized view of the page, visit original site.