mirror of
https://github.com/github/codeql.git
synced 2026-04-25 08:45:14 +02:00
Port linux/kotlin tests to pytest.
This commit is contained in:
@@ -1,26 +1,33 @@
|
||||
from create_database_utils import *
|
||||
|
||||
import pathlib
|
||||
import shutil
|
||||
import runs_on
|
||||
import commands
|
||||
|
||||
this_dir = pathlib.Path(__file__).resolve().parent
|
||||
cwd = pathlib.Path.cwd()
|
||||
builddir = cwd / 'build'
|
||||
|
||||
builddir.mkdir(exist_ok=True)
|
||||
|
||||
try:
|
||||
runSuccessfully(
|
||||
[f'{get_semmle_code_path()}/tools/bazel', f'--output_user_root={builddir}', '--max_idle_secs=1', 'build',
|
||||
'//java/ql/integration-tests/linux-only/kotlin/custom_plugin/plugin', '--spawn_strategy=local',
|
||||
'--nouse_action_cache', '--noremote_accept_cached', '--noremote_upload_local_results',
|
||||
f'--symlink_prefix={cwd / "bazel-"}'], cwd=this_dir)
|
||||
finally:
|
||||
# rules_python creates a read-only directory in bazel's output, this allows cleanup to succeed
|
||||
runSuccessfully(['chmod', '-R', '+w', builddir])
|
||||
|
||||
shutil.copy(
|
||||
'bazel-bin/java/ql/integration-tests/linux-only/kotlin/custom_plugin/plugin/plugin.jar', 'plugin.jar')
|
||||
|
||||
run_codeql_database_create(
|
||||
["kotlinc -J-Xmx2G -language-version 1.9 -Xplugin=plugin.jar a.kt b.kt c.kt d.kt e.kt"], lang="java")
|
||||
@runs_on.linux
|
||||
def test(codeql, java_full, cwd, semmle_code_dir, test_dir):
|
||||
build_dir = cwd / "build"
|
||||
build_dir.mkdir(exist_ok=True)
|
||||
commands.run(
|
||||
[
|
||||
f"{semmle_code_dir}/tools/bazel",
|
||||
f"--output_user_root={build_dir}",
|
||||
"--max_idle_secs=1",
|
||||
"build",
|
||||
"//java/ql/integration-tests/linux-only/kotlin/custom_plugin/plugin",
|
||||
"--spawn_strategy=local",
|
||||
"--nouse_action_cache",
|
||||
"--noremote_accept_cached",
|
||||
"--noremote_upload_local_results",
|
||||
f'--symlink_prefix={cwd / "bazel-"}',
|
||||
],
|
||||
_cwd=test_dir,
|
||||
)
|
||||
shutil.copy(
|
||||
"bazel-bin/java/ql/integration-tests/linux-only/kotlin/custom_plugin/plugin/plugin.jar",
|
||||
"plugin.jar",
|
||||
)
|
||||
codeql.database.create(
|
||||
command=[
|
||||
"kotlinc -J-Xmx2G -language-version 1.9 -Xplugin=plugin.jar a.kt b.kt c.kt d.kt e.kt"
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
dependencies:
|
||||
codeql/java-all: '*'
|
||||
warnOnImplicitThis: true
|
||||
@@ -1,8 +1,9 @@
|
||||
from create_database_utils import *
|
||||
import glob
|
||||
import runs_on
|
||||
|
||||
os.mkdir('build')
|
||||
javaccmd = " ".join(["javac"] + glob.glob("javasrc/extlib/*.java") + ["-d", "build"])
|
||||
jarcmd = " ".join(["jar", "-c", "-f", "extlib.jar", "-C", "build", "extlib"])
|
||||
run_codeql_database_create([javaccmd, jarcmd, "kotlinc user.kt -cp extlib.jar"], lang="java")
|
||||
|
||||
@runs_on.linux
|
||||
def test(codeql, java_full, cwd):
|
||||
java_srcs = (cwd / "javasrc" / "extlib").glob("*.java")
|
||||
javac_cmd = " ".join(["javac"] + [str(s) for s in java_srcs] + ["-d", "build"])
|
||||
jar_cmd = " ".join(["jar", "-c", "-f", "extlib.jar", "-C", "build", "extlib"])
|
||||
codeql.database.create(command=[javac_cmd, jar_cmd, "kotlinc user.kt -cp extlib.jar"])
|
||||
|
||||
Reference in New Issue
Block a user