Skip to content

Commit 932c07a

Browse files
committed
Address review.
1 parent 33f87c0 commit 932c07a

File tree

8 files changed

+25
-44
lines changed

8 files changed

+25
-44
lines changed
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import os
2-
3-
41
def test(codeql, java_full):
5-
os.mkdir("out")
62
codeql.database.create(
7-
command=["kotlinc test.kt -d out", "javac User.java -cp out", "kotlinc ktUser.kt -cp out"]
3+
command=["kotlinc test.kt -d out", "javac User.java -cp out -d out2", "kotlinc ktUser.kt -cp out -d out2"]
84
)

java/ql/integration-tests/all-platforms/kotlin/enabling/test.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ def build():
1414

1515

1616
def test(codeql, java_full, build):
17-
for var in [
18-
"CODEQL_EXTRACTOR_JAVA_AGENT_ENABLE_KOTLIN",
19-
"CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN",
20-
]:
21-
if var in os.environ:
22-
del os.environ[var]
17+
os.environ.pop("CODEQL_EXTRACTOR_JAVA_AGENT_ENABLE_KOTLIN", None)
18+
os.environ.pop("CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN", None)
2319
codeql.database.create(command=build)
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
def test(codeql, java_full, cwd):
2-
java_srcs = [str(s) for s in cwd.glob('*.java')]
1+
import pathlib
32

3+
4+
def test(codeql, java_full):
5+
java_srcs = " ".join([str(s) for s in pathlib.Path().glob("*.java")])
46
codeql.database.create(
57
command=[
6-
f"javac {' '.join(java_srcs)} -d {cwd / 'build'}",
8+
f"javac {java_srcs} -d build",
79
"kotlinc -language-version 1.9 user.kt -cp build",
810
]
911
)
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import commands
2+
import pathlib
23

34

4-
def test(codeql, java_full, cwd):
5+
def test(codeql, java_full):
56
# Compile Java untraced. Note the Java source is hidden under `javasrc` so the Kotlin compiler
67
# will certainly reference the jar, not the source or class file for extlib.Lib
7-
java_srcs = (cwd / "libsrc" / "extlib").glob("*.java")
8+
java_srcs = pathlib.Path("libsrc", "extlib").glob("*.java")
89
commands.run(["javac", *java_srcs, "-d", "build"])
910
commands.run("jar cf extlib.jar -C build extlib")
1011
codeql.database.create(command="kotlinc test.kt -cp extlib.jar")

java/ql/integration-tests/all-platforms/kotlin/kotlin_file_import/test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import commands
2+
import pathlib
23

34

4-
def test(codeql, java_full, cwd):
5+
def test(codeql, java_full):
56
# Compile library Kotlin file untraced. Note the library is hidden under `libsrc` so the Kotlin compiler
67
# will certainly reference the jar, not the source or class file.
7-
commands.run(["kotlinc", *(cwd / "libsrc").glob("*.kt"), "-d", "build"])
8+
commands.run(["kotlinc", *pathlib.Path("libsrc").glob("*.kt"), "-d", "build"])
89
commands.run(
910
["jar", "cf", "extlib.jar", "-C", "build", "abcdefghij", "-C", "build", "META-INF"]
1011
)
Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
1-
Test script
2-
Log file
3-
1
4-
CodeQL Kotlin extractor
5-
INFO
6-
Extraction started
7-
CodeQL Kotlin extractor
8-
INFO
9-
Extraction for invocation TRAP file <FILENAME>
10-
CodeQL Kotlin extractor
11-
INFO
12-
Kotlin version <VERSION>
13-
CodeQL Kotlin extractor
14-
INFO
15-
Extracting file test.kt
16-
CodeQL Kotlin extractor
17-
INFO
18-
Extraction completed
1+
Log file 1
2+
{"origin": "CodeQL Kotlin extractor", "kind": "INFO", "message": "Extraction started"}
3+
{"origin": "CodeQL Kotlin extractor", "kind": "INFO", "message": "Extraction for invocation TRAP file <FILENAME>"}
4+
{"origin": "CodeQL Kotlin extractor", "kind": "INFO", "message": "Kotlin version <VERSION>"}
5+
{"origin": "CodeQL Kotlin extractor", "kind": "INFO", "message": "Extracting file test.kt"}
6+
{"origin": "CodeQL Kotlin extractor", "kind": "INFO", "message": "Extraction completed"}

java/ql/integration-tests/all-platforms/kotlin/logs/test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ def test(codeql, java_full, cwd: pathlib.Path, expected_files):
1010

1111
with open("logs.actual", "w") as f_out:
1212
log_dir = cwd / "test-db" / "log"
13-
file_index = 0
14-
for log_file in log_dir.glob("kotlin-extractor*.log"):
15-
file_index += 1
16-
f_out.write(f"Test script\nLog file\n{file_index}\n")
13+
for file_index, log_file in enumerate(log_dir.glob("kotlin-extractor*.log"), 1):
14+
f_out.write(f"Log file {file_index}\n")
1715
for line in log_file.read_text().splitlines():
1816
j = json.loads(line)
17+
del j["timestamp"]
1918
msg = j["message"]
2019
msg = re.sub(
2120
r"(?<=Extraction for invocation TRAP file ).*[\\/]test-db[\\/]trap[\\/]java[\\/]invocations[\\/]kotlin\..*\.trap",
@@ -36,4 +35,5 @@ def test(codeql, java_full, cwd: pathlib.Path, expected_files):
3635
):
3736
# These vary between machines etc, and aren't very interesting, so just ignore them
3837
continue
39-
f_out.write(f"{j['origin']}\n{j['kind']}\n{msg}\n")
38+
j["message"] = msg
39+
print(json.dumps(j), file=f_out)

java/ql/integration-tests/all-platforms/kotlin/trap_compression/test.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
def check_extensions(directory, counts):
66
if runs_on.windows:
7-
# It's important that the path is a Unicode path on Windows, so
8-
# that the right system calls get used.
9-
directory = "" + directory
107
if not directory.startswith("\\\\?\\"):
118
directory = "\\\\?\\" + os.path.abspath(directory)
129

0 commit comments

Comments
 (0)