Created
February 20, 2024 05:32
-
-
Save MaskRay/0bcb12e0bf99a78325c817e7364d317f to your computer and use it in GitHub Desktop.
Script used to help fix tests for https://github.com/llvm/llvm-project/pull/81037 ("[Driver] Improve error when a compiler-rt library is not found")
This file contains 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 python | |
import os, re, subprocess, sys | |
from ipdb import set_trace as bp | |
def main(filename): | |
last = 0 | |
while 1: | |
p = subprocess.run(['/tmp/Rel/bin/llvm-lit', '-v', filename], capture_output=True) | |
if p.returncode != 1: break | |
lines = p.stdout.decode().split('\n') | |
m = None | |
for line in lines: | |
m = re.search(r'clang/test/Driver/([-0-9a-z]+\.\w+):(\d+).*error', line) | |
if m: break | |
if not m: break | |
ms = m.groups() | |
if ms[1] == last: break | |
last = ms[1] | |
with open(ms[0]) as f: content = f.read() | |
lines = content.split('\n') | |
t = lines[int(ms[1])-1] | |
t = re.sub(r'lib{{/\|\\\\\\\\}}(linux|fuchsia){{/\|\\\\\\\\}}(libclang_rt.[_a-z]+)-([_0-9a-z]+)', r'lib{{.*}}\1{{.*}}\2', t) | |
t = re.sub(r'(clang_rt.[_a-z]+)-([_0-9a-z]+)', '\\1', t) | |
lines[int(ms[1])-1] = t | |
with open(ms[0], 'w') as f: f.write('\n'.join(lines)) | |
print('update', ms) | |
os.putenv('NO_COLOR','1') | |
for i in sys.stdin.readlines(): | |
main(i.strip()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment