forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildless_test_utils.py
More file actions
37 lines (31 loc) · 1.22 KB
/
Copy pathbuildless_test_utils.py
File metadata and controls
37 lines (31 loc) · 1.22 KB
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
import sys
import os.path
import glob
def extract_fetched_jar_path(l):
if not l.startswith("["):
# Line continuation
return None
bits = l.split(" ", 3) # date time processid logline
if len(bits) >= 4 and bits[3].startswith("Fetch "):
return bits[3][6:].strip()
else:
return None
def read_fetched_jars(fname):
with open(fname, "r") as f:
lines = [l for l in f]
return [l for l in map(extract_fetched_jar_path, lines) if l is not None]
def check_buildless_fetches():
extractor_logs = glob.glob(os.path.join("test-db", "log", "javac-extractor-*.log"))
fetched_jars = map(read_fetched_jars, extractor_logs)
all_fetched_jars = tuple(sorted([item for sublist in fetched_jars for item in sublist]))
try:
with open("buildless-fetches.expected", "r") as f:
expected_jar_fetches = tuple(l.strip() for l in f)
except FileNotFoundError:
expected_jar_fetches = tuple()
if all_fetched_jars != expected_jar_fetches:
print("Expected jar fetch mismatch. Expected:\n%s\n\nActual:\n%s" % ("\n".join(expected_jar_fetches), "\n".join(all_fetched_jars)), file = sys.stderr)
with open("buildless-fetches.actual", "w") as f:
for j in all_fetched_jars:
f.write(j + "\n")
sys.exit(1)