Created
July 26, 2023 20:37
-
-
Save MaskRay/2f1cfb34c7863d65a417d00673d8bf6e to your computer and use it in GitHub Desktop.
Update tests for `[Driver] -###: exit with code 1 if hasErrorOccurred`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import re, subprocess, sys | |
def main(): | |
for line in open(sys.argv[1]).readlines(): | |
line = line.strip() | |
m = re.match(r'Clang :: (.*)', line) | |
if not m: continue | |
name = m.group(1) | |
print(name) | |
while 1: | |
from ipdb import set_trace as bp | |
sub = subprocess.run(['/tmp/Rel/bin/llvm-lit', '-vv', name], capture_output=True) | |
if sub.returncode == 0: break | |
lineno = -1 | |
for l in sub.stdout.decode().splitlines(): | |
m = re.search(r"'RUN: at line (\d+)", l) | |
if m: | |
lineno = int(m.group(1)) | |
bad = False | |
print('line', lineno) | |
with open(name, 'r+') as f: | |
lines = f.readlines() | |
if '%clang' in lines[lineno-1]: | |
lines[lineno-1] = lines[lineno-1].replace('%clang', 'not %clang') | |
elif '%clang' in lines[lineno]: | |
lines[lineno] = lines[lineno].replace('%clang', 'not %clang') | |
else: | |
bad = True | |
print(f'cannot fix {name}, no %clang') | |
print(lines[lineno-1]) | |
break | |
f.seek(0) | |
f.write(''.join(lines)) | |
if bad: | |
print(f'cannot fix {name}, no %clang') | |
break | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment