Skip to content

Commit 06d6ddc

Browse files
Fix issue with reporting javac output
1 parent 8f40a6e commit 06d6ddc

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

java/ql/src/Stubs/make_stubs.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import shlex
99
from shutil import copyfile
1010

11+
1112
def print_usage(exit_code=1):
1213
print("Usage: python3 make_stubs.py testDir stubDir\n",
1314
"testDir: the directory containing the qltest to be stubbed. Should contain an `options0` file pointing to the jars to stub, and an `options1` file pointing to `stubdir`\n",
@@ -36,6 +37,7 @@ def check_file_exists(path):
3637
print(path, "does not exist or is not a regular file")
3738
exit(1)
3839

40+
3941
check_dir_exists(testDir)
4042
check_dir_exists(stubDir)
4143

@@ -49,7 +51,8 @@ def check_file_exists(path):
4951
# Does it contain a .ql file and a .java file?
5052

5153
foundJava = any(f.endswith(".java") for f in os.listdir(testDir))
52-
foundQL = any(f.endswith(".ql") or f.endswith(".qlref") for f in os.listdir(testDir))
54+
foundQL = any(f.endswith(".ql") or f.endswith(".qlref")
55+
for f in os.listdir(testDir))
5356

5457
if not foundQL:
5558
print("Test directory does not contain .ql files. Please specify a working qltest directory.")
@@ -70,19 +73,25 @@ def check_file_exists(path):
7073
def print_javac_output():
7174
logFiles = glob.glob(os.path.join(dbDir, "log", "javac-output*"))
7275

73-
print("\nJavac output:\n")
76+
if not(logFiles):
77+
print("\nNo javac output found.")
78+
else:
79+
logFile = os.path.join(dbDir, "log", logFiles[0])
80+
print("\nJavac output:\n")
81+
82+
with open(logFile) as f:
83+
for line in f:
84+
b1 = line.find(']')
85+
b2 = line.find(']', b1+1)
86+
print(line[b2+2:], end="")
7487

75-
with open(logFile) as f:
76-
for line in f:
77-
b1 = line.find(']')
78-
b2 = line.find(']', b1+1)
79-
print(line[b2+2:], end="")
8088

8189
def run(cmd):
8290
"""Runs the given command, returning the exit code (nonzero on failure)"""
8391
print('\nRunning: ' + shlex.join(cmd) + '\n')
8492
return subprocess.call(cmd)
8593

94+
8695
print("Stubbing qltest in", testDir)
8796

8897
copyfile(options0File, optionsFile)

0 commit comments

Comments
 (0)