mirror of
https://github.com/github/codeql.git
synced 2026-07-20 18:58:36 +02:00
Merge pull request #17252 from github/criemen/pytest-java
kotlin: Move integration tests to pytest
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
from create_database_utils import *
|
||||
|
||||
os.mkdir('out')
|
||||
os.mkdir('out2')
|
||||
run_codeql_database_create(["kotlinc test.kt -d out", "javac User.java -cp out -d out2", "kotlinc ktUser.kt -cp out -d out2"], lang="java")
|
||||
def test(codeql, java_full):
|
||||
codeql.database.create(
|
||||
command=["kotlinc test.kt -d out", "javac User.java -cp out -d out2", "kotlinc ktUser.kt -cp out -d out2"]
|
||||
)
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#
|
||||
# https://help.github.com/articles/dealing-with-line-endings/
|
||||
#
|
||||
# These are explicitly windows files and should use crlf
|
||||
*.bat text eol=crlf
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# We currently have a bug where gradle tests become flaky when executed in parallel
|
||||
# - sometimes, gradle fails to connect to the gradle daemon.
|
||||
# Therefore, force this test to run sequentially.
|
||||
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -1,244 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
@@ -1,92 +0,0 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -1,7 +1,2 @@
|
||||
import platform
|
||||
from create_database_utils import *
|
||||
|
||||
gradle_cmd = "gradlew.bat" if platform.system() == "Windows" else "./gradlew"
|
||||
|
||||
run_codeql_database_create(
|
||||
["%s build --no-daemon --no-build-cache" % gradle_cmd], lang="java")
|
||||
def test(codeql, java_full, gradle_7_6):
|
||||
codeql.database.create(command=f"{gradle_7_6} build")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from create_database_utils import *
|
||||
import subprocess
|
||||
import commands
|
||||
|
||||
subprocess.check_call([get_cmd("kotlinc"), "lib.kt", "-d", "lib"])
|
||||
run_codeql_database_create(["kotlinc user.kt -cp lib"], lang="java")
|
||||
|
||||
def test(codeql, java_full):
|
||||
commands.run("kotlinc lib.kt -d lib")
|
||||
codeql.database.create(command=["kotlinc user.kt -cp lib"])
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
import commands
|
||||
import pathlib
|
||||
|
||||
import glob
|
||||
import os.path
|
||||
|
||||
os.mkdir('fake-kotlinc-classes')
|
||||
runSuccessfully(["javac"] + [os.path.relpath(x, "fake-kotlinc-source") for x in glob.glob("fake-kotlinc-source/**/*.java", recursive = True)] + ["-d", "../fake-kotlinc-classes"], cwd = "fake-kotlinc-source")
|
||||
run_codeql_database_create(["java -cp fake-kotlinc-classes driver.Main"], lang = "java", runFunction = runUnsuccessfully, db = None)
|
||||
|
||||
check_diagnostics()
|
||||
def test(codeql, java_full):
|
||||
fake_kotlin_classes = pathlib.Path("fake-kotlinc-classes")
|
||||
fake_kotlin_classes.mkdir()
|
||||
for source_file in pathlib.Path("fake-kotlinc-source").rglob("*.java"):
|
||||
commands.run(
|
||||
f"javac {source_file.relative_to("fake-kotlinc-source")} -d {fake_kotlin_classes.absolute()}",
|
||||
_cwd="fake-kotlinc-source",
|
||||
)
|
||||
codeql.database.create(
|
||||
command=[f"java -cp {fake_kotlin_classes} driver.Main"], _assert_failure=True
|
||||
)
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from create_database_utils import *
|
||||
|
||||
runSuccessfully([get_cmd("kotlinc"), "KotlinDefault.kt"])
|
||||
os.environ['CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN'] = 'true'
|
||||
runSuccessfully([get_cmd("kotlinc"), "KotlinDisabled.kt"])
|
||||
del(os.environ['CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN'])
|
||||
os.environ['CODEQL_EXTRACTOR_JAVA_AGENT_ENABLE_KOTLIN'] = 'true'
|
||||
runSuccessfully([get_cmd("kotlinc"), "KotlinEnabled.kt"])
|
||||
@@ -1,2 +0,0 @@
|
||||
| KotlinDefault.kt:1:1:1:22 | KotlinDefault |
|
||||
| KotlinEnabled.kt:1:1:1:22 | KotlinEnabled |
|
||||
@@ -1,5 +0,0 @@
|
||||
import java
|
||||
|
||||
from Class c
|
||||
where c.fromSource()
|
||||
select c
|
||||
@@ -0,0 +1,2 @@
|
||||
KotlinDefault.kt
|
||||
KotlinEnabled.kt
|
||||
@@ -1,9 +1,19 @@
|
||||
from create_database_utils import *
|
||||
import os
|
||||
import commands
|
||||
from build_fixture import build_fixture
|
||||
|
||||
for var in ['CODEQL_EXTRACTOR_JAVA_AGENT_ENABLE_KOTLIN',
|
||||
'CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN']:
|
||||
if var in os.environ:
|
||||
del(os.environ[var])
|
||||
|
||||
run_codeql_database_create(['"%s" build.py' % sys.executable], lang="java")
|
||||
@build_fixture
|
||||
def build():
|
||||
commands.run("kotlinc KotlinDefault.kt")
|
||||
os.environ["CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN"] = "true"
|
||||
commands.run("kotlinc KotlinDisabled.kt")
|
||||
del os.environ["CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN"]
|
||||
os.environ["CODEQL_EXTRACTOR_JAVA_AGENT_ENABLE_KOTLIN"] = "true"
|
||||
commands.run("kotlinc KotlinEnabled.kt")
|
||||
|
||||
|
||||
def test(codeql, java_full, build):
|
||||
os.environ.pop("CODEQL_EXTRACTOR_JAVA_AGENT_ENABLE_KOTLIN", None)
|
||||
os.environ.pop("CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN", None)
|
||||
codeql.database.create(command=build)
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
from create_database_utils import *
|
||||
import glob
|
||||
import pathlib
|
||||
|
||||
os.mkdir('build')
|
||||
runSuccessfully(["javac"] + glob.glob("*.java") + ["-d", "build"])
|
||||
run_codeql_database_create(["javac " + " ".join(glob.glob("*.java")) + " -d build", "kotlinc -language-version 1.9 user.kt -cp build"], lang="java")
|
||||
|
||||
def test(codeql, java_full):
|
||||
java_srcs = " ".join([str(s) for s in pathlib.Path().glob("*.java")])
|
||||
codeql.database.create(
|
||||
command=[
|
||||
f"javac {java_srcs} -d build",
|
||||
"kotlinc -language-version 1.9 user.kt -cp build",
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from create_database_utils import *
|
||||
import commands
|
||||
|
||||
os.mkdir('lib')
|
||||
runSuccessfully([get_cmd("kotlinc"), "-language-version", "1.9", "test.kt", "-d", "lib"])
|
||||
run_codeql_database_create(["kotlinc -language-version 1.9 user.kt -cp lib"], lang="java")
|
||||
|
||||
def test(codeql, java_full):
|
||||
commands.run("kotlinc -language-version 1.9 test.kt -d lib")
|
||||
codeql.database.create(command="kotlinc -language-version 1.9 user.kt -cp lib")
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from create_database_utils import *
|
||||
|
||||
os.environ['CODEQL_KOTLIN_INTERNAL_EXCEPTION_WHILE_EXTRACTING_FILE'] = 'B.kt'
|
||||
|
||||
subprocess.check_call([get_cmd('kotlinc'), 'A.kt', 'B.kt', 'C.kt', ])
|
||||
@@ -1,7 +1,6 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
from create_database_utils import *
|
||||
|
||||
run_codeql_database_create(
|
||||
['"%s" build.py' % sys.executable],
|
||||
source="code", lang="java")
|
||||
def test(codeql, java_full):
|
||||
os.environ["CODEQL_KOTLIN_INTERNAL_EXCEPTION_WHILE_EXTRACTING_FILE"] = "B.kt"
|
||||
codeql.database.create(command="kotlinc A.kt B.kt C.kt", source_root="code")
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
from create_database_utils import *
|
||||
|
||||
run_codeql_database_create(["kotlinc -J-Xmx2G -language-version 1.9 SomeClass.kt"], lang="java")
|
||||
def test(codeql, java_full):
|
||||
codeql.database.create(command="kotlinc -J-Xmx2G -language-version 1.9 SomeClass.kt")
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
from create_database_utils import *
|
||||
|
||||
run_codeql_database_create(["kotlinc -J-Xmx2G -language-version 2.0 SomeClass.kt"], lang="java")
|
||||
def test(codeql, java_full):
|
||||
codeql.database.create(command="kotlinc -J-Xmx2G -language-version 2.0 SomeClass.kt")
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
from create_database_utils import *
|
||||
import commands
|
||||
|
||||
runSuccessfully([get_cmd("kotlinc"), '-language-version', '1.9', 'A.kt'])
|
||||
run_codeql_database_create(['kotlinc -cp . -language-version 1.9 B.kt C.kt'], lang="java")
|
||||
|
||||
def test(codeql, java_full):
|
||||
commands.run("kotlinc -language-version 1.9 A.kt")
|
||||
codeql.database.create(command="kotlinc -cp . -language-version 1.9 B.kt C.kt")
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#
|
||||
# https://help.github.com/articles/dealing-with-line-endings/
|
||||
#
|
||||
# These are explicitly windows files and should use crlf
|
||||
*.bat text eol=crlf
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# We currently have a bug where gradle tests become flaky when executed in parallel
|
||||
# - sometimes, gradle fails to connect to the gradle daemon.
|
||||
# Therefore, force this test to run sequentially.
|
||||
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -1,244 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
@@ -1,92 +0,0 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -1,7 +1,2 @@
|
||||
import platform
|
||||
from create_database_utils import *
|
||||
|
||||
gradle_cmd = "gradlew.bat" if platform.system() == "Windows" else "./gradlew"
|
||||
|
||||
run_codeql_database_create(
|
||||
["%s build --no-daemon --no-build-cache" % gradle_cmd], lang="java")
|
||||
def test(codeql, java_full, gradle_7_6):
|
||||
codeql.database.create(command=f"{gradle_7_6} build")
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#
|
||||
# https://help.github.com/articles/dealing-with-line-endings/
|
||||
#
|
||||
# These are explicitly windows files and should use crlf
|
||||
*.bat text eol=crlf
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# We currently have a bug where gradle tests become flaky when executed in parallel
|
||||
# - sometimes, gradle fails to connect to the gradle daemon.
|
||||
# Therefore, force this test to run sequentially.
|
||||
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -1,244 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
@@ -1,92 +0,0 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -1,6 +0,0 @@
|
||||
name: integrationtest-gradle-kotlinx-serialization
|
||||
dependencies:
|
||||
codeql/java-all: '*'
|
||||
codeql/java-tests: '*'
|
||||
codeql/java-queries: '*'
|
||||
warnOnImplicitThis: true
|
||||
@@ -1,7 +1,2 @@
|
||||
import platform
|
||||
from create_database_utils import *
|
||||
|
||||
gradle_cmd = "gradlew.bat" if platform.system() == "Windows" else "./gradlew"
|
||||
|
||||
run_codeql_database_create(
|
||||
["%s build --no-daemon --no-build-cache" % gradle_cmd], lang="java")
|
||||
def test(codeql, java_full, gradle_7_6):
|
||||
codeql.database.create(command=f"{gradle_7_6} build")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from create_database_utils import *
|
||||
import commands
|
||||
|
||||
os.mkdir('bin')
|
||||
runSuccessfully(["javac", "Test.java", "-d", "bin"])
|
||||
run_codeql_database_create(["kotlinc -language-version 1.9 user.kt -cp bin"], lang="java")
|
||||
|
||||
def test(codeql, java_full):
|
||||
commands.run(["javac", "Test.java", "-d", "bin"])
|
||||
codeql.database.create(command="kotlinc -language-version 1.9 user.kt -cp bin")
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
from create_database_utils import *
|
||||
import glob
|
||||
import commands
|
||||
import pathlib
|
||||
|
||||
# Compile Java untraced. Note the Java source is hidden under `javasrc` so the Kotlin compiler
|
||||
# will certainly reference the jar, not the source or class file for extlib.Lib
|
||||
|
||||
os.mkdir('build')
|
||||
runSuccessfully(["javac"] + glob.glob("libsrc/extlib/*.java") + ["-d", "build"])
|
||||
runSuccessfully(["jar", "cf", "extlib.jar", "-C", "build", "extlib"])
|
||||
run_codeql_database_create(["kotlinc test.kt -cp extlib.jar"], lang="java")
|
||||
def test(codeql, java_full):
|
||||
# Compile Java untraced. Note the Java source is hidden under `javasrc` so the Kotlin compiler
|
||||
# will certainly reference the jar, not the source or class file for extlib.Lib
|
||||
java_srcs = pathlib.Path("libsrc", "extlib").glob("*.java")
|
||||
commands.run(["javac", *java_srcs, "-d", "build"])
|
||||
commands.run("jar cf extlib.jar -C build extlib")
|
||||
codeql.database.create(command="kotlinc test.kt -cp extlib.jar")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from create_database_utils import *
|
||||
|
||||
os.mkdir('bin')
|
||||
run_codeql_database_create(["kotlinc test.kt -d bin", "kotlinc user.kt -cp bin", "javac User.java -cp bin"], lang="java")
|
||||
def test(codeql, java_full):
|
||||
codeql.database.create(
|
||||
command=["kotlinc test.kt -d bin", "kotlinc user.kt -cp bin", "javac User.java -cp bin"]
|
||||
)
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
name: integrationtest-kotlin-interface-inherited-default
|
||||
dependencies:
|
||||
codeql/java-all: '*'
|
||||
codeql/java-tests: '*'
|
||||
codeql/java-queries: '*'
|
||||
warnOnImplicitThis: true
|
||||
@@ -1,6 +1,8 @@
|
||||
from create_database_utils import *
|
||||
import glob
|
||||
|
||||
os.mkdir('build')
|
||||
run_codeql_database_create(["kotlinc test.kt -d build", "kotlinc noforwards.kt -d build -Xjvm-default=all", "javac User.java -cp build"], lang="java")
|
||||
|
||||
def test(codeql, java_full):
|
||||
codeql.database.create(
|
||||
command=[
|
||||
"kotlinc test.kt -d build",
|
||||
"kotlinc noforwards.kt -d build -Xjvm-default=all",
|
||||
"javac User.java -cp build",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
from create_database_utils import *
|
||||
|
||||
os.mkdir('build')
|
||||
# Steps:
|
||||
# 1. Compile Kotlin passing Java source code. J.class is extracted with an unknown binary location
|
||||
# 2. Compile Java producing a class file. J.class should be re-extracted this time with a known binary location
|
||||
# 3. Compile a Kotlin user passing a Java class file on the classpath. Should reference the class file location that step 1 didn't know, but step 2 did.
|
||||
run_codeql_database_create(["kotlinc J.java K.kt -d build", "javac J.java -d build", "kotlinc K2.kt -cp build -d build"], lang="java")
|
||||
def test(codeql, java_full):
|
||||
# Steps:
|
||||
# 1. Compile Kotlin passing Java source code. J.class is extracted with an unknown binary location
|
||||
# 2. Compile Java producing a class file. J.class should be re-extracted this time with a known binary location
|
||||
# 3. Compile a Kotlin user passing a Java class file on the classpath. Should reference the class file location that step 1 didn't know, but step 2 did.
|
||||
codeql.database.create(
|
||||
command=[
|
||||
"kotlinc J.java K.kt -d build",
|
||||
"javac J.java -d build",
|
||||
"kotlinc K2.kt -cp build -d build",
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
from create_database_utils import *
|
||||
import glob
|
||||
import commands
|
||||
import pathlib
|
||||
|
||||
# Compile library Kotlin file untraced. Note the library is hidden under `libsrc` so the Kotlin compiler
|
||||
# will certainly reference the jar, not the source or class file.
|
||||
|
||||
os.mkdir('build')
|
||||
runSuccessfully([get_cmd("kotlinc")] + glob.glob("libsrc/*.kt") + ["-d", "build"])
|
||||
runSuccessfully(["jar", "cf", "extlib.jar", "-C", "build", "abcdefghij", "-C", "build", "META-INF"])
|
||||
run_codeql_database_create(["kotlinc user.kt -cp extlib.jar"], lang="java")
|
||||
|
||||
def test(codeql, java_full):
|
||||
# Compile library Kotlin file untraced. Note the library is hidden under `libsrc` so the Kotlin compiler
|
||||
# will certainly reference the jar, not the source or class file.
|
||||
commands.run(["kotlinc", *pathlib.Path("libsrc").glob("*.kt"), "-d", "build"])
|
||||
commands.run(
|
||||
["jar", "cf", "extlib.jar", "-C", "build", "abcdefghij", "-C", "build", "META-INF"]
|
||||
)
|
||||
codeql.database.create(command=["kotlinc user.kt -cp extlib.jar"])
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
from create_database_utils import *
|
||||
import commands
|
||||
|
||||
# Compile the JavaDefns2 copy outside tracing, to make sure the Kotlin view of it matches the Java view seen by the traced javac compilation of JavaDefns.java below.
|
||||
runSuccessfully(["javac", "JavaDefns2.java"])
|
||||
run_codeql_database_create(["kotlinc kotlindefns.kt", "javac JavaUser.java JavaDefns.java -cp .", "kotlinc -language-version 1.9 -cp . kotlinuser.kt"], lang="java")
|
||||
|
||||
def test(codeql, java_full):
|
||||
# Compile the JavaDefns2 copy outside tracing, to make sure the Kotlin view of it matches the Java view seen by the traced javac compilation of JavaDefns.java below.
|
||||
commands.run(["javac", "JavaDefns2.java"])
|
||||
codeql.database.create(
|
||||
command=[
|
||||
"kotlinc kotlindefns.kt",
|
||||
"javac JavaUser.java JavaDefns.java -cp .",
|
||||
"kotlinc -language-version 1.9 -cp . kotlinuser.kt",
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
name: integrationtest-kotlin-java-static-fields
|
||||
dependencies:
|
||||
codeql/java-all: '*'
|
||||
codeql/java-tests: '*'
|
||||
codeql/java-queries: '*'
|
||||
warnOnImplicitThis: true
|
||||
@@ -1,4 +1,7 @@
|
||||
from create_database_utils import *
|
||||
|
||||
os.mkdir('build')
|
||||
run_codeql_database_create(["kotlinc ReadsFields.java hasFields.kt -d kbuild", "javac ReadsFields.java -cp kbuild"], lang="java")
|
||||
def test(codeql, java_full):
|
||||
codeql.database.create(
|
||||
command=[
|
||||
"kotlinc ReadsFields.java hasFields.kt -d kbuild",
|
||||
"javac ReadsFields.java -cp kbuild",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#
|
||||
# https://help.github.com/articles/dealing-with-line-endings/
|
||||
#
|
||||
# These are explicitly windows files and should use crlf
|
||||
*.bat text eol=crlf
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# We currently have a bug where gradle tests become flaky when executed in parallel
|
||||
# - sometimes, gradle fails to connect to the gradle daemon.
|
||||
# Therefore, force this test to run sequentially.
|
||||
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -1,244 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
@@ -1,92 +0,0 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -1,7 +1,2 @@
|
||||
import platform
|
||||
from create_database_utils import *
|
||||
|
||||
gradle_cmd = "gradlew.bat" if platform.system() == "Windows" else "./gradlew"
|
||||
|
||||
run_codeql_database_create(
|
||||
["%s build --no-daemon --no-build-cache" % gradle_cmd], lang="java")
|
||||
def test(codeql, java_full, gradle_7_6):
|
||||
codeql.database.create(command=f"{gradle_7_6} build")
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from create_database_utils import *
|
||||
|
||||
runSuccessfully([get_cmd("kotlinc"), "FileA.kt", "FileB.kt"])
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
from create_database_utils import *
|
||||
|
||||
run_codeql_database_create(['"%s" ./build.py' % sys.executable], lang="java")
|
||||
def test(codeql, java_full):
|
||||
codeql.database.create(
|
||||
command=[
|
||||
"kotlinc FileA.kt FileB.kt",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
from create_database_utils import *
|
||||
|
||||
# Make a source file to keep codeql happy
|
||||
srcDir = os.environ['CODEQL_EXTRACTOR_JAVA_SOURCE_ARCHIVE_DIR']
|
||||
srcFile = srcDir + '/Source.java'
|
||||
os.makedirs(srcDir)
|
||||
with open(srcFile, 'w') as f:
|
||||
pass
|
||||
|
||||
for t in ['Test1', 'sun.something.Test2']:
|
||||
print('Test ' + t + ' started.')
|
||||
sys.stdout.flush()
|
||||
runSuccessfully(['java', t])
|
||||
print('Test ' + t + ' ended.')
|
||||
sys.stdout.flush()
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import csv
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from create_database_utils import *
|
||||
|
||||
# Make a source file to keep codeql happy
|
||||
src_dir = os.environ['CODEQL_EXTRACTOR_JAVA_SOURCE_ARCHIVE_DIR']
|
||||
src_file = src_dir + '/Source.java'
|
||||
os.makedirs(src_dir)
|
||||
with open(src_file, 'w') as f:
|
||||
pass
|
||||
|
||||
line_index = 0
|
||||
file_index = 0
|
||||
with open('logs.csv', 'w', newline='') as f_out:
|
||||
csv_writer = csv.writer(f_out)
|
||||
def write_line(origin, kind, msg):
|
||||
global file_index, line_index
|
||||
csv_writer.writerow([str(file_index), str(line_index), origin, kind, msg])
|
||||
line_index += 1
|
||||
log_dir = 'kt-db/log'
|
||||
for file_name in os.listdir(log_dir):
|
||||
if file_name.startswith('kotlin-extractor'):
|
||||
file_index += 1
|
||||
line_index = 1
|
||||
write_line('Test script', 'Log file', str(file_index))
|
||||
with open(log_dir + '/' + file_name) as f_in:
|
||||
for line in f_in:
|
||||
j = json.loads(line)
|
||||
msg = j['message']
|
||||
msg = re.sub(r'(?<=Extraction for invocation TRAP file ).*[\\/]kt-db[\\/]trap[\\/]java[\\/]invocations[\\/]kotlin\..*\.trap', '<FILENAME>', msg)
|
||||
msg = re.sub('(?<=Kotlin version )[0-9.]+(-[a-zA-Z0-9.]+)?', '<VERSION>', msg)
|
||||
if msg.startswith('Peak memory: '):
|
||||
# Peak memory information varies from run to run, so just ignore it
|
||||
continue
|
||||
if msg.startswith('Will write TRAP file ') or msg.startswith('Finished writing TRAP file '):
|
||||
# These vary between machines etc, and aren't very interesting, so just ignore them
|
||||
continue
|
||||
write_line(j['origin'], j['kind'], msg)
|
||||
|
||||
runSuccessfully(["codeql", "database", "index-files", "--language=csv", "--include=logs.csv", "test-db"])
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
| 1 | 1 | Test script | Log file | 1 |
|
||||
| 1 | 2 | CodeQL Kotlin extractor | INFO | Extraction started |
|
||||
| 1 | 3 | CodeQL Kotlin extractor | INFO | Extraction for invocation TRAP file <FILENAME> |
|
||||
| 1 | 4 | CodeQL Kotlin extractor | INFO | Kotlin version <VERSION> |
|
||||
| 1 | 5 | CodeQL Kotlin extractor | INFO | Extracting file test.kt |
|
||||
| 1 | 6 | CodeQL Kotlin extractor | INFO | Extraction completed |
|
||||
Log file 1
|
||||
{"origin": "CodeQL Kotlin extractor", "kind": "INFO", "message": "Extraction started"}
|
||||
{"origin": "CodeQL Kotlin extractor", "kind": "INFO", "message": "Extraction for invocation TRAP file <FILENAME>"}
|
||||
{"origin": "CodeQL Kotlin extractor", "kind": "INFO", "message": "Kotlin version <VERSION>"}
|
||||
{"origin": "CodeQL Kotlin extractor", "kind": "INFO", "message": "Extracting file test.kt"}
|
||||
{"origin": "CodeQL Kotlin extractor", "kind": "INFO", "message": "Extraction completed"}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
import external.ExternalArtifact
|
||||
|
||||
from ExternalData ed
|
||||
where ed.getDataPath().matches("%logs.csv")
|
||||
select ed.getFieldAsInt(0), ed.getFieldAsInt(1), ed.getField(2), ed.getField(3), ed.getField(4)
|
||||
@@ -1,4 +1,39 @@
|
||||
from create_database_utils import *
|
||||
import json
|
||||
from math import log
|
||||
import pathlib
|
||||
import re
|
||||
|
||||
run_codeql_database_create(['kotlinc test.kt'], test_db="kt-db", db=None, lang="java")
|
||||
run_codeql_database_create(['"%s" ./index_logs.py' % sys.executable], lang="java")
|
||||
|
||||
def test(codeql, java_full, cwd: pathlib.Path, expected_files):
|
||||
codeql.database.create(command=["kotlinc test.kt"])
|
||||
expected_files.add("logs.actual")
|
||||
|
||||
with open("logs.actual", "w") as f_out:
|
||||
log_dir = cwd / "test-db" / "log"
|
||||
for file_index, log_file in enumerate(log_dir.glob("kotlin-extractor*.log"), 1):
|
||||
f_out.write(f"Log file {file_index}\n")
|
||||
for line in log_file.read_text().splitlines():
|
||||
j = json.loads(line)
|
||||
del j["timestamp"]
|
||||
msg = j["message"]
|
||||
msg = re.sub(
|
||||
r"(?<=Extraction for invocation TRAP file ).*[\\/]test-db[\\/]trap[\\/]java[\\/]invocations[\\/]kotlin\..*\.trap",
|
||||
"<FILENAME>",
|
||||
msg,
|
||||
)
|
||||
msg = re.sub(
|
||||
r"(?<=Extracting file ).?:?[\\/].*test\.kt",
|
||||
"test.kt",
|
||||
msg,
|
||||
)
|
||||
msg = re.sub("(?<=Kotlin version )[0-9.]+(-[a-zA-Z0-9.]+)?", "<VERSION>", msg)
|
||||
if msg.startswith("Peak memory: "):
|
||||
# Peak memory information varies from run to run, so just ignore it
|
||||
continue
|
||||
if msg.startswith("Will write TRAP file ") or msg.startswith(
|
||||
"Finished writing TRAP file "
|
||||
):
|
||||
# These vary between machines etc, and aren't very interesting, so just ignore them
|
||||
continue
|
||||
j["message"] = msg
|
||||
print(json.dumps(j), file=f_out)
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
from create_database_utils import *
|
||||
import glob
|
||||
import commands
|
||||
|
||||
# Compile Java untraced. Note the Java source is hidden under `javasrc` so the Kotlin compiler
|
||||
# will certainly reference the jar, not the source or class file for extlib.Lib
|
||||
|
||||
os.mkdir('build')
|
||||
runSuccessfully(["javac"] + glob.glob("libsrc/extlib/*.java") + ["-d", "build"])
|
||||
runSuccessfully(["jar", "cf", "extlib.jar", "-C", "build", "extlib"])
|
||||
run_codeql_database_create(["javac JavaUser.java -cp extlib.jar", "kotlinc KotlinUser.kt -cp extlib.jar"], lang="java")
|
||||
|
||||
def test(codeql, java_full, cwd):
|
||||
# Compile Java untraced. Note the Java source is hidden under `javasrc` so the Kotlin compiler
|
||||
# will certainly reference the jar, not the source or class file for extlib.Lib
|
||||
java_srcs = (cwd / "libsrc" / "extlib").glob("*.java")
|
||||
commands.run(["javac", *java_srcs, "-d", "build"])
|
||||
commands.run("jar cf extlib.jar -C build extlib")
|
||||
codeql.database.create(
|
||||
command=["javac JavaUser.java -cp extlib.jar", "kotlinc KotlinUser.kt -cp extlib.jar"]
|
||||
)
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
from create_database_utils import *
|
||||
import os
|
||||
|
||||
os.mkdir('out')
|
||||
os.mkdir('out2')
|
||||
os.mkdir('out3')
|
||||
run_codeql_database_create(["javac AnnotatedInterface.java AnnotatedMethods.java zpkg/A.java org/jetbrains/annotations/NotNull.java org/jetbrains/annotations/Nullable.java -d out", "kotlinc ktUser.kt -cp out -d out2", "javac JavaUser.java -cp out" + os.pathsep + "out2 -d out3"], lang="java")
|
||||
|
||||
def test(codeql, java_full):
|
||||
codeql.database.create(
|
||||
command=[
|
||||
"javac AnnotatedInterface.java AnnotatedMethods.java zpkg/A.java org/jetbrains/annotations/NotNull.java org/jetbrains/annotations/Nullable.java -d out",
|
||||
"kotlinc ktUser.kt -cp out -d out2",
|
||||
"javac JavaUser.java -cp out" + os.pathsep + "out2 -d out3",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
from create_database_utils import *
|
||||
import os
|
||||
|
||||
path_transformer_file = 'path_transformer'
|
||||
root = os.getcwd().replace('\\', '/')
|
||||
with open(path_transformer_file, 'w') as f:
|
||||
f.write('#/src\n' + root + '//\n')
|
||||
os.environ['SEMMLE_PATH_TRANSFORMER'] = root + '/' + path_transformer_file
|
||||
|
||||
run_codeql_database_create(["kotlinc kotlin_source.kt"], lang="java")
|
||||
files = ['test-db/trap/java/src/kotlin_source.kt.trap.gz', 'test-db/src/src/kotlin_source.kt']
|
||||
exists = list(map(os.path.exists, files))
|
||||
if exists != [True] * 2:
|
||||
print(exists)
|
||||
raise Exception("Didn't get expected files")
|
||||
def test(codeql, java_full):
|
||||
path_transformer_file = "path_transformer"
|
||||
root = os.getcwd().replace("\\", "/")
|
||||
with open(path_transformer_file, "w") as f:
|
||||
f.write("#/src\n" + root + "//\n")
|
||||
os.environ["SEMMLE_PATH_TRANSFORMER"] = root + "/" + path_transformer_file
|
||||
|
||||
codeql.database.create(command=["kotlinc kotlin_source.kt"])
|
||||
files = ["test-db/trap/java/src/kotlin_source.kt.trap.gz", "test-db/src/src/kotlin_source.kt"]
|
||||
for file in files:
|
||||
assert os.path.exists(file)
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
from create_database_utils import *
|
||||
|
||||
run_codeql_database_create(["kotlinc hasprops.kt", "kotlinc usesprops.kt -cp ."], lang="java")
|
||||
def test(codeql, java_full):
|
||||
codeql.database.create(command=["kotlinc hasprops.kt", "kotlinc usesprops.kt -cp ."])
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
dependencies:
|
||||
codeql/java-all: '*'
|
||||
codeql/java-tests: '*'
|
||||
codeql/java-queries: '*'
|
||||
warnOnImplicitThis: true
|
||||
@@ -1,10 +1,12 @@
|
||||
from create_database_utils import *
|
||||
import glob
|
||||
import commands
|
||||
|
||||
# Compile Java untraced. Note the Java source is hidden under `javasrc` so the Kotlin compiler
|
||||
# will certainly reference the jar, not the source or class file for extlib.Lib
|
||||
|
||||
os.mkdir('build')
|
||||
runSuccessfully(["javac"] + glob.glob("libsrc/extlib/*.java") + ["-d", "build"])
|
||||
runSuccessfully(["jar", "cf", "extlib.jar", "-C", "build", "extlib"])
|
||||
run_codeql_database_create(["javac JavaUser.java -cp extlib.jar", "kotlinc KotlinUser.kt -cp extlib.jar"], lang="java")
|
||||
def test(codeql, java_full, cwd):
|
||||
# Compile Java untraced. Note the Java source is hidden under `javasrc` so the Kotlin compiler
|
||||
# will certainly reference the jar, not the source or class file for extlib.Lib
|
||||
java_srcs = (cwd / "libsrc" / "extlib").glob("*.java")
|
||||
commands.run(["javac", *java_srcs, "-d", "build"])
|
||||
commands.run("jar cf extlib.jar -C build extlib")
|
||||
codeql.database.create(
|
||||
command=["javac JavaUser.java -cp extlib.jar", "kotlinc KotlinUser.kt -cp extlib.jar"]
|
||||
)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
from create_database_utils import *
|
||||
import commands
|
||||
|
||||
os.mkdir('out')
|
||||
os.mkdir('out2')
|
||||
runSuccessfully([get_cmd("kotlinc"), "lib.kt", "-d", "out"])
|
||||
runSuccessfully([get_cmd("javac"), "JavaDefinedContainer.java", "JavaDefinedRepeatable.java", "-d", "out"])
|
||||
run_codeql_database_create(["kotlinc test.kt -cp out -d out", "javac JavaUser.java -cp out -d out2"], lang="java")
|
||||
|
||||
def test(codeql, java_full, cwd):
|
||||
commands.run(["kotlinc", "lib.kt", "-d", "out"])
|
||||
commands.run(["javac", "JavaDefinedContainer.java", "JavaDefinedRepeatable.java", "-d", "out"])
|
||||
codeql.database.create(
|
||||
command=["kotlinc test.kt -cp out -d out", "javac JavaUser.java -cp out -d out2"]
|
||||
)
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
from create_database_utils import *
|
||||
import runs_on
|
||||
import os
|
||||
|
||||
|
||||
def check_extensions(directory, counts):
|
||||
if platform.system() == 'Windows':
|
||||
# It's important that the path is a Unicode path on Windows, so
|
||||
# that the right system calls get used.
|
||||
directory = u'' + directory
|
||||
if runs_on.windows:
|
||||
if not directory.startswith("\\\\?\\"):
|
||||
directory = "\\\\?\\" + os.path.abspath(directory)
|
||||
|
||||
check_extensions_worker(counts, directory)
|
||||
check_counts('non-compressed', counts.expected_none, counts.count_none)
|
||||
check_counts('gzipped', counts.expected_gzip, counts.count_gzip)
|
||||
check_counts("non-compressed", counts.expected_none, counts.count_none)
|
||||
check_counts("gzipped", counts.expected_gzip, counts.count_gzip)
|
||||
|
||||
|
||||
def check_counts(name, expected, count):
|
||||
if expected == -1:
|
||||
if count < 10:
|
||||
raise Exception('Expected lots of ' + name + ' files, but got ' + str(count))
|
||||
elif expected != count:
|
||||
raise Exception('Expected ' + str(expected) + ' ' + name + ' files, but got ' + str(count))
|
||||
assert count > 10, "Expected lots of " + name + " files, but got " + str(count)
|
||||
else:
|
||||
assert expected == count, (
|
||||
"Expected " + str(expected) + " " + name + " files, but got " + str(count)
|
||||
)
|
||||
|
||||
|
||||
class Counts:
|
||||
def __init__(self, expected_none, expected_gzip):
|
||||
@@ -26,41 +28,61 @@ class Counts:
|
||||
self.count_none = 0
|
||||
self.count_gzip = 0
|
||||
|
||||
|
||||
def check_extensions_worker(counts, directory):
|
||||
for f in os.listdir(directory):
|
||||
x = os.path.join(directory, f)
|
||||
if os.path.isdir(x):
|
||||
check_extensions_worker(counts, x)
|
||||
elif f.endswith('.trap'):
|
||||
elif f.endswith(".trap"):
|
||||
counts.count_none += 1
|
||||
if not startsWith(x, b'//'): # We start TRAP files with a comment
|
||||
raise Exception("TRAP file that doesn't start with a comment: " + f)
|
||||
elif f.endswith('.trap.gz'):
|
||||
# We start TRAP files with a comment
|
||||
assert startsWith(x, b"//"), "TRAP file that doesn't start with a comment: " + f
|
||||
elif f.endswith(".trap.gz"):
|
||||
counts.count_gzip += 1
|
||||
if not startsWith(x, b'\x1f\x8b'): # The GZip magic numbers
|
||||
raise Exception("GZipped TRAP file that doesn't start with GZip magic numbers: " + f)
|
||||
# The GZip magic numbers
|
||||
assert startsWith(x, b"\x1f\x8b"), (
|
||||
"GZipped TRAP file that doesn't start with GZip magic numbers: " + f
|
||||
)
|
||||
|
||||
|
||||
def startsWith(f, b):
|
||||
with open(f, 'rb') as f_in:
|
||||
with open(f, "rb") as f_in:
|
||||
content = f_in.read()
|
||||
return content.startswith(b)
|
||||
|
||||
|
||||
# In the counts, we expect lots of files of the compression type chosen
|
||||
# (so expected count is -1), but the diagnostic TRAP files will always
|
||||
# be uncompressed (so count_none is always 1 or -1) and the
|
||||
# sourceLocationPrefix TRAP file is always gzipped (so count_gzip is
|
||||
# always 1 or -1).
|
||||
run_codeql_database_create(['kotlinc test.kt'], test_db="default-db", db=None, lang="java")
|
||||
check_extensions('default-db/trap', Counts(1, -1))
|
||||
os.environ["CODEQL_EXTRACTOR_JAVA_OPTION_TRAP_COMPRESSION"] = "nOnE"
|
||||
run_codeql_database_create(['kotlinc test.kt'], test_db="none-db", db=None, lang="java")
|
||||
check_extensions('none-db/trap', Counts(-1, 1))
|
||||
os.environ["CODEQL_EXTRACTOR_JAVA_OPTION_TRAP_COMPRESSION"] = "gzip"
|
||||
run_codeql_database_create(['kotlinc test.kt'], test_db="gzip-db", db=None, lang="java")
|
||||
check_extensions('gzip-db/trap', Counts(1, -1))
|
||||
os.environ["CODEQL_EXTRACTOR_JAVA_OPTION_TRAP_COMPRESSION"] = "brotli"
|
||||
run_codeql_database_create(['kotlinc test.kt'], test_db="brotli-db", db=None, lang="java")
|
||||
check_extensions('brotli-db/trap', Counts(1, -1))
|
||||
os.environ["CODEQL_EXTRACTOR_JAVA_OPTION_TRAP_COMPRESSION"] = "invalidValue"
|
||||
run_codeql_database_create(['kotlinc test.kt'], test_db="invalid-db", db=None, lang="java")
|
||||
check_extensions('invalid-db/trap', Counts(1, -1))
|
||||
|
||||
|
||||
def test_default(codeql, java_full):
|
||||
codeql.database.create(command="kotlinc test.kt")
|
||||
check_extensions("test-db/trap", Counts(1, -1))
|
||||
|
||||
|
||||
def test_none(codeql, java_full):
|
||||
os.environ["CODEQL_EXTRACTOR_JAVA_OPTION_TRAP_COMPRESSION"] = "nOnE"
|
||||
codeql.database.create(command="kotlinc test.kt")
|
||||
check_extensions("test-db/trap", Counts(-1, 1))
|
||||
|
||||
|
||||
def test_gzip(codeql, java_full):
|
||||
os.environ["CODEQL_EXTRACTOR_JAVA_OPTION_TRAP_COMPRESSION"] = "gzip"
|
||||
codeql.database.create(command="kotlinc test.kt")
|
||||
check_extensions("test-db/trap", Counts(1, -1))
|
||||
|
||||
|
||||
def test_brotli(codeql, java_full):
|
||||
os.environ["CODEQL_EXTRACTOR_JAVA_OPTION_TRAP_COMPRESSION"] = "brotli"
|
||||
codeql.database.create(command="kotlinc test.kt")
|
||||
check_extensions("test-db/trap", Counts(1, -1))
|
||||
|
||||
|
||||
def test_invalid(codeql, java_full):
|
||||
os.environ["CODEQL_EXTRACTOR_JAVA_OPTION_TRAP_COMPRESSION"] = "invalidValue"
|
||||
codeql.database.create(command="kotlinc test.kt")
|
||||
check_extensions("test-db/trap", Counts(1, -1))
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
These tests are still run with the legacy test runner
|
||||
@@ -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"])
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
from create_database_utils import *
|
||||
import runs_on
|
||||
|
||||
os.mkdir('build')
|
||||
run_codeql_database_create(["kotlinc test.kt -d build", "javac User.java -cp build"], lang="java")
|
||||
|
||||
@runs_on.posix
|
||||
def test(codeql, java_full):
|
||||
codeql.database.create(command=["kotlinc test.kt -d build", "javac User.java -cp build"])
|
||||
|
||||
@@ -1,128 +1,178 @@
|
||||
from create_database_utils import *
|
||||
import os
|
||||
import os.path
|
||||
import subprocess
|
||||
import commands
|
||||
import runs_on
|
||||
|
||||
# Build a family of dependencies outside tracing, then refer to them from a traced build:
|
||||
|
||||
older_datetime = "202201010101"
|
||||
newer_datetime = "202202020202"
|
||||
@runs_on.posix
|
||||
def test(codeql, java_full):
|
||||
# Build a family of dependencies outside tracing, then refer to them from a traced build:
|
||||
|
||||
classpath_entries = dict()
|
||||
older_datetime = "202201010101"
|
||||
newer_datetime = "202202020202"
|
||||
|
||||
extraction_orders = ["JavaSeesFirst", "KotlinSeesFirst"]
|
||||
jar_states = ["NoJar", "JarMtimesEqual", "JavaJarNewer", "KotlinJarNewer"]
|
||||
class_file_states = ["ClassFileMtimesEqual", "JavaClassFileNewer", "KotlinClassFileNewer"]
|
||||
classpath_entries = dict()
|
||||
|
||||
# Create test classes for each combination of which extractor will see the file first, the relative timestamps of the jar files seen by each, and the relative timestamps of the class file inside:
|
||||
extraction_orders = ["JavaSeesFirst", "KotlinSeesFirst"]
|
||||
jar_states = ["NoJar", "JarMtimesEqual", "JavaJarNewer", "KotlinJarNewer"]
|
||||
class_file_states = ["ClassFileMtimesEqual", "JavaClassFileNewer", "KotlinClassFileNewer"]
|
||||
|
||||
jobs = []
|
||||
# Create test classes for each combination of which extractor will see the file first, the relative timestamps of the jar files seen by each, and the relative timestamps of the class file inside:
|
||||
|
||||
for first_extraction in extraction_orders:
|
||||
for jar_state in jar_states:
|
||||
for class_file_state in class_file_states:
|
||||
dep_dir = os.path.join(first_extraction, jar_state, class_file_state)
|
||||
dep_classname = "Dep___%s___%s___%s" % (first_extraction, jar_state, class_file_state)
|
||||
dep_seen_by_java_dir = os.path.join(dep_dir, "seen_by_java")
|
||||
dep_seen_by_kotlin_dir = os.path.join(dep_dir, "seen_by_kotlin")
|
||||
os.makedirs(dep_seen_by_java_dir)
|
||||
os.makedirs(dep_seen_by_kotlin_dir)
|
||||
dep_seen_by_java_sourcefile = os.path.join(dep_seen_by_java_dir, dep_classname + ".java")
|
||||
dep_seen_by_kotlin_sourcefile = os.path.join(dep_seen_by_kotlin_dir, dep_classname + ".java")
|
||||
with open(dep_seen_by_java_sourcefile, "w") as f:
|
||||
f.write("public class %s { }" % dep_classname)
|
||||
with open(dep_seen_by_kotlin_sourcefile, "w") as f:
|
||||
f.write("public class %s { void memberOnlySeenByKotlin() { } }" % dep_classname)
|
||||
jobs.append({
|
||||
"first_extraction": first_extraction,
|
||||
"jar_state": jar_state,
|
||||
"class_file_state": class_file_state,
|
||||
"dep_dir": dep_dir,
|
||||
"dep_classname": dep_classname,
|
||||
"dep_seen_by_java_dir": dep_seen_by_java_dir,
|
||||
"dep_seen_by_kotlin_dir": dep_seen_by_kotlin_dir,
|
||||
"dep_seen_by_java_sourcefile": dep_seen_by_java_sourcefile,
|
||||
"dep_seen_by_kotlin_sourcefile": dep_seen_by_kotlin_sourcefile
|
||||
})
|
||||
jobs = []
|
||||
|
||||
# Compile all the test classes we just generated, in two commands (since javac objects to seeing the same class file twice in one run)
|
||||
for first_extraction in extraction_orders:
|
||||
for jar_state in jar_states:
|
||||
for class_file_state in class_file_states:
|
||||
dep_dir = os.path.join(first_extraction, jar_state, class_file_state)
|
||||
dep_classname = "Dep___%s___%s___%s" % (
|
||||
first_extraction,
|
||||
jar_state,
|
||||
class_file_state,
|
||||
)
|
||||
dep_seen_by_java_dir = os.path.join(dep_dir, "seen_by_java")
|
||||
dep_seen_by_kotlin_dir = os.path.join(dep_dir, "seen_by_kotlin")
|
||||
os.makedirs(dep_seen_by_java_dir)
|
||||
os.makedirs(dep_seen_by_kotlin_dir)
|
||||
dep_seen_by_java_sourcefile = os.path.join(
|
||||
dep_seen_by_java_dir, dep_classname + ".java"
|
||||
)
|
||||
dep_seen_by_kotlin_sourcefile = os.path.join(
|
||||
dep_seen_by_kotlin_dir, dep_classname + ".java"
|
||||
)
|
||||
with open(dep_seen_by_java_sourcefile, "w") as f:
|
||||
f.write("public class %s { }" % dep_classname)
|
||||
with open(dep_seen_by_kotlin_sourcefile, "w") as f:
|
||||
f.write("public class %s { void memberOnlySeenByKotlin() { } }" % dep_classname)
|
||||
jobs.append(
|
||||
{
|
||||
"first_extraction": first_extraction,
|
||||
"jar_state": jar_state,
|
||||
"class_file_state": class_file_state,
|
||||
"dep_dir": dep_dir,
|
||||
"dep_classname": dep_classname,
|
||||
"dep_seen_by_java_dir": dep_seen_by_java_dir,
|
||||
"dep_seen_by_kotlin_dir": dep_seen_by_kotlin_dir,
|
||||
"dep_seen_by_java_sourcefile": dep_seen_by_java_sourcefile,
|
||||
"dep_seen_by_kotlin_sourcefile": dep_seen_by_kotlin_sourcefile,
|
||||
}
|
||||
)
|
||||
|
||||
subprocess.check_call(["javac"] + [j["dep_seen_by_java_sourcefile"] for j in jobs])
|
||||
subprocess.check_call(["javac"] + [j["dep_seen_by_kotlin_sourcefile"] for j in jobs])
|
||||
# Compile all the test classes we just generated, in two commands (since javac objects to seeing the same class file twice in one run)
|
||||
|
||||
# Create jar files and set class and jar files' relative timestamps for each dependency the two extractors will see:
|
||||
commands.run(["javac"] + [j["dep_seen_by_java_sourcefile"] for j in jobs])
|
||||
commands.run(["javac"] + [j["dep_seen_by_kotlin_sourcefile"] for j in jobs])
|
||||
|
||||
for j in jobs:
|
||||
os.remove(j["dep_seen_by_java_sourcefile"])
|
||||
os.remove(j["dep_seen_by_kotlin_sourcefile"])
|
||||
dep_seen_by_java_classfile = j["dep_seen_by_java_sourcefile"].replace(".java", ".class")
|
||||
dep_seen_by_kotlin_classfile = j["dep_seen_by_kotlin_sourcefile"].replace(".java", ".class")
|
||||
# Create jar files and set class and jar files' relative timestamps for each dependency the two extractors will see:
|
||||
|
||||
subprocess.check_call(["touch", "-t", newer_datetime if j["class_file_state"] == "JavaClassFileNewer" else older_datetime, dep_seen_by_java_classfile])
|
||||
subprocess.check_call(["touch", "-t", newer_datetime if j["class_file_state"] == "KotlinClassFileNewer" else older_datetime, dep_seen_by_kotlin_classfile])
|
||||
for j in jobs:
|
||||
os.remove(j["dep_seen_by_java_sourcefile"])
|
||||
os.remove(j["dep_seen_by_kotlin_sourcefile"])
|
||||
dep_seen_by_java_classfile = j["dep_seen_by_java_sourcefile"].replace(".java", ".class")
|
||||
dep_seen_by_kotlin_classfile = j["dep_seen_by_kotlin_sourcefile"].replace(".java", ".class")
|
||||
|
||||
if j["jar_state"] != "NoJar":
|
||||
classfile_name = os.path.basename(dep_seen_by_java_classfile)
|
||||
jar_command = ["jar", "cf", "dep.jar", classfile_name]
|
||||
subprocess.check_call(jar_command, cwd = j["dep_seen_by_java_dir"])
|
||||
subprocess.check_call(jar_command, cwd = j["dep_seen_by_kotlin_dir"])
|
||||
jar_seen_by_java = os.path.join(j["dep_seen_by_java_dir"], "dep.jar")
|
||||
jar_seen_by_kotlin = os.path.join(j["dep_seen_by_kotlin_dir"], "dep.jar")
|
||||
subprocess.check_call(["touch", "-t", newer_datetime if j["jar_state"] == "JavaJarNewer" else older_datetime, jar_seen_by_java])
|
||||
subprocess.check_call(["touch", "-t", newer_datetime if j["jar_state"] == "KotlinJarNewer" else older_datetime, jar_seen_by_kotlin])
|
||||
j["javac_classpath_entry"] = jar_seen_by_java
|
||||
j["kotlinc_classpath_entry"] = jar_seen_by_kotlin
|
||||
else:
|
||||
# No jar file involved, just add the dependency build directory to the classpath:
|
||||
j["javac_classpath_entry"] = j["dep_seen_by_java_dir"]
|
||||
j["kotlinc_classpath_entry"] = j["dep_seen_by_kotlin_dir"]
|
||||
commands.run(
|
||||
[
|
||||
"touch",
|
||||
"-t",
|
||||
newer_datetime if j["class_file_state"] == "JavaClassFileNewer" else older_datetime,
|
||||
dep_seen_by_java_classfile,
|
||||
]
|
||||
)
|
||||
commands.run(
|
||||
[
|
||||
"touch",
|
||||
"-t",
|
||||
(
|
||||
newer_datetime
|
||||
if j["class_file_state"] == "KotlinClassFileNewer"
|
||||
else older_datetime
|
||||
),
|
||||
dep_seen_by_kotlin_classfile,
|
||||
]
|
||||
)
|
||||
|
||||
# Create source files that instantiate each dependency type:
|
||||
if j["jar_state"] != "NoJar":
|
||||
classfile_name = os.path.basename(dep_seen_by_java_classfile)
|
||||
jar_command = ["jar", "cf", "dep.jar", classfile_name]
|
||||
commands.run(jar_command, _cwd=j["dep_seen_by_java_dir"])
|
||||
commands.run(jar_command, _cwd=j["dep_seen_by_kotlin_dir"])
|
||||
jar_seen_by_java = os.path.join(j["dep_seen_by_java_dir"], "dep.jar")
|
||||
jar_seen_by_kotlin = os.path.join(j["dep_seen_by_kotlin_dir"], "dep.jar")
|
||||
commands.run(
|
||||
[
|
||||
"touch",
|
||||
"-t",
|
||||
newer_datetime if j["jar_state"] == "JavaJarNewer" else older_datetime,
|
||||
jar_seen_by_java,
|
||||
]
|
||||
)
|
||||
commands.run(
|
||||
[
|
||||
"touch",
|
||||
"-t",
|
||||
newer_datetime if j["jar_state"] == "KotlinJarNewer" else older_datetime,
|
||||
jar_seen_by_kotlin,
|
||||
]
|
||||
)
|
||||
j["javac_classpath_entry"] = jar_seen_by_java
|
||||
j["kotlinc_classpath_entry"] = jar_seen_by_kotlin
|
||||
else:
|
||||
# No jar file involved, just add the dependency build directory to the classpath:
|
||||
j["javac_classpath_entry"] = j["dep_seen_by_java_dir"]
|
||||
j["kotlinc_classpath_entry"] = j["dep_seen_by_kotlin_dir"]
|
||||
|
||||
kotlin_first_jobs = [j for j in jobs if j["first_extraction"] == "KotlinSeesFirst"]
|
||||
java_first_jobs = [j for j in jobs if j["first_extraction"] == "JavaSeesFirst"]
|
||||
kotlin_first_classes = [j["dep_classname"] for j in kotlin_first_jobs]
|
||||
java_first_classes = [j["dep_classname"] for j in java_first_jobs]
|
||||
# Create source files that instantiate each dependency type:
|
||||
|
||||
kotlin_first_user = "kotlinFirstUser.kt"
|
||||
kotlin_second_user = "kotlinSecondUser.kt"
|
||||
java_first_user = "JavaFirstUser.java"
|
||||
java_second_user = "JavaSecondUser.java"
|
||||
kotlin_first_jobs = [j for j in jobs if j["first_extraction"] == "KotlinSeesFirst"]
|
||||
java_first_jobs = [j for j in jobs if j["first_extraction"] == "JavaSeesFirst"]
|
||||
kotlin_first_classes = [j["dep_classname"] for j in kotlin_first_jobs]
|
||||
java_first_classes = [j["dep_classname"] for j in java_first_jobs]
|
||||
|
||||
def kotlin_instantiate_classes(classes):
|
||||
return "; ".join(["noop(%s())" % c for c in classes])
|
||||
kotlin_first_user = "kotlinFirstUser.kt"
|
||||
kotlin_second_user = "kotlinSecondUser.kt"
|
||||
java_first_user = "JavaFirstUser.java"
|
||||
java_second_user = "JavaSecondUser.java"
|
||||
|
||||
def make_kotlin_user(user_filename, classes):
|
||||
with open(user_filename, "w") as f:
|
||||
f.write("fun noop(x: Any) { } fun user() { %s }" % kotlin_instantiate_classes(classes))
|
||||
def kotlin_instantiate_classes(classes):
|
||||
return "; ".join(["noop(%s())" % c for c in classes])
|
||||
|
||||
make_kotlin_user(kotlin_first_user, kotlin_first_classes)
|
||||
make_kotlin_user(kotlin_second_user, java_first_classes)
|
||||
def make_kotlin_user(user_filename, classes):
|
||||
with open(user_filename, "w") as f:
|
||||
f.write("fun noop(x: Any) { } fun user() { %s }" % kotlin_instantiate_classes(classes))
|
||||
|
||||
def java_instantiate_classes(classes):
|
||||
return " ".join(["noop(new %s());" % c for c in classes])
|
||||
make_kotlin_user(kotlin_first_user, kotlin_first_classes)
|
||||
make_kotlin_user(kotlin_second_user, java_first_classes)
|
||||
|
||||
def make_java_user(user_filename, classes):
|
||||
with open(user_filename, "w") as f:
|
||||
f.write("public class %s { private static void noop(Object x) { } public static void user() { %s } }" % (user_filename.replace(".java", ""), java_instantiate_classes(classes)))
|
||||
def java_instantiate_classes(classes):
|
||||
return " ".join(["noop(new %s());" % c for c in classes])
|
||||
|
||||
make_java_user(java_first_user, java_first_classes)
|
||||
make_java_user(java_second_user, kotlin_first_classes)
|
||||
def make_java_user(user_filename, classes):
|
||||
with open(user_filename, "w") as f:
|
||||
f.write(
|
||||
"public class %s { private static void noop(Object x) { } public static void user() { %s } }"
|
||||
% (user_filename.replace(".java", ""), java_instantiate_classes(classes))
|
||||
)
|
||||
|
||||
# Now finally make a database, including classes where Java sees them first followed by Kotlin and vice versa.
|
||||
# In all cases the Kotlin extraction should take precedence.
|
||||
make_java_user(java_first_user, java_first_classes)
|
||||
make_java_user(java_second_user, kotlin_first_classes)
|
||||
|
||||
def make_classpath(jobs, entry_name):
|
||||
return ":".join([j[entry_name] for j in jobs])
|
||||
# Now finally make a database, including classes where Java sees them first followed by Kotlin and vice versa.
|
||||
# In all cases the Kotlin extraction should take precedence.
|
||||
|
||||
kotlin_first_classpath = make_classpath(kotlin_first_jobs, "kotlinc_classpath_entry")
|
||||
java_first_classpath = make_classpath(java_first_jobs, "javac_classpath_entry")
|
||||
kotlin_second_classpath = make_classpath(java_first_jobs, "kotlinc_classpath_entry")
|
||||
java_second_classpath = make_classpath(kotlin_first_jobs, "javac_classpath_entry")
|
||||
def make_classpath(jobs, entry_name):
|
||||
return ":".join([j[entry_name] for j in jobs])
|
||||
|
||||
run_codeql_database_create([
|
||||
"kotlinc -cp %s %s" % (kotlin_first_classpath, kotlin_first_user),
|
||||
"javac -cp %s %s" % (java_first_classpath, java_first_user),
|
||||
"kotlinc -cp %s %s" % (kotlin_second_classpath, kotlin_second_user),
|
||||
"javac -cp %s %s" % (java_second_classpath, java_second_user)
|
||||
], lang="java")
|
||||
kotlin_first_classpath = make_classpath(kotlin_first_jobs, "kotlinc_classpath_entry")
|
||||
java_first_classpath = make_classpath(java_first_jobs, "javac_classpath_entry")
|
||||
kotlin_second_classpath = make_classpath(java_first_jobs, "kotlinc_classpath_entry")
|
||||
java_second_classpath = make_classpath(kotlin_first_jobs, "javac_classpath_entry")
|
||||
|
||||
codeql.database.create(
|
||||
command=[
|
||||
"kotlinc -cp %s %s" % (kotlin_first_classpath, kotlin_first_user),
|
||||
"javac -cp %s %s" % (java_first_classpath, java_first_user),
|
||||
"kotlinc -cp %s %s" % (kotlin_second_classpath, kotlin_second_user),
|
||||
"javac -cp %s %s" % (java_second_classpath, java_second_user),
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import glob
|
||||
import os
|
||||
import re
|
||||
from create_database_utils import *
|
||||
|
||||
def say(s):
|
||||
print(s)
|
||||
sys.stdout.flush()
|
||||
|
||||
say('Doing normal compilation')
|
||||
# This is a normal intercepted compilation
|
||||
runSuccessfully([get_cmd('kotlinc'), 'normal.kt'])
|
||||
|
||||
say('Identifying extractor jar')
|
||||
# Find the extractor jar that is being used
|
||||
trapDir = os.environ['CODEQL_EXTRACTOR_JAVA_TRAP_DIR']
|
||||
invocationTrapDir = os.path.join(trapDir, 'invocations')
|
||||
invocationTraps = os.listdir(invocationTrapDir)
|
||||
if len(invocationTraps) != 1:
|
||||
raise Exception('Expected to find 1 invocation TRAP, but found ' + str(invocationTraps))
|
||||
invocationTrap = os.path.join(invocationTrapDir, invocationTraps[0])
|
||||
with open(invocationTrap, 'r') as f:
|
||||
content = f.read()
|
||||
m = re.search('^// Using extractor: (.*)$', content, flags = re.MULTILINE)
|
||||
extractorJar = m.group(1)
|
||||
|
||||
def getManualFlags(invocationTrapName):
|
||||
return ['-Xplugin=' + extractorJar, '-P', 'plugin:kotlin-extractor:invocationTrapFile=' + os.path.join(trapDir, 'invocations', invocationTrapName + '.trap')]
|
||||
|
||||
# This is both normally intercepted, and it has the extractor flags manually added
|
||||
say('Doing double-interception compilation')
|
||||
runSuccessfully([get_cmd('kotlinc'), 'doubleIntercepted.kt'] + getManualFlags('doubleIntercepted'))
|
||||
os.environ['CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN'] = 'true'
|
||||
# We don't see this compilation at all
|
||||
say('Doing unseen compilation')
|
||||
runSuccessfully([get_cmd('kotlinc'), 'notSeen.kt'])
|
||||
# This is extracted as it has the extractor flags manually added
|
||||
say('Doing manual compilation')
|
||||
runSuccessfully([get_cmd('kotlinc'), 'manual.kt'] + getManualFlags('manual'))
|
||||
@@ -1,7 +1,59 @@
|
||||
from build_fixture import build_fixture
|
||||
import sys
|
||||
import commands
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
import runs_on
|
||||
|
||||
from create_database_utils import *
|
||||
|
||||
run_codeql_database_create(
|
||||
['"%s" build.py' % sys.executable],
|
||||
source="code", lang="java")
|
||||
def say(s):
|
||||
print(s)
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
@build_fixture
|
||||
def build():
|
||||
say("Doing normal compilation")
|
||||
|
||||
# This is a normal intercepted compilation
|
||||
commands.run("kotlinc normal.kt")
|
||||
|
||||
say("Identifying extractor jar")
|
||||
# Find the extractor jar that is being used
|
||||
trapDir = pathlib.Path(os.environ["CODEQL_EXTRACTOR_JAVA_TRAP_DIR"])
|
||||
|
||||
invocationTrapDir = trapDir / "invocations"
|
||||
invocationTraps = list(invocationTrapDir.iterdir())
|
||||
assert len(invocationTraps) == 1, "Expected to find 1 invocation TRAP, but found " + str(
|
||||
invocationTraps
|
||||
)
|
||||
invocationTrap = os.path.join(invocationTrapDir, invocationTraps[0])
|
||||
with open(invocationTrap, "r") as f:
|
||||
content = f.read()
|
||||
m = re.search("^// Using extractor: (.*)$", content, flags=re.MULTILINE)
|
||||
extractorJar = m.group(1)
|
||||
|
||||
def getManualFlags(invocationTrapName):
|
||||
return [
|
||||
f"-Xplugin={extractorJar}",
|
||||
"-P",
|
||||
f"plugin:kotlin-extractor:invocationTrapFile={trapDir / "invocations" / invocationTrapName}.trap",
|
||||
]
|
||||
|
||||
# This is both normally intercepted, and it has the extractor flags manually added
|
||||
say("Doing double-interception compilation")
|
||||
commands.run(["kotlinc", "doubleIntercepted.kt"] + getManualFlags("doubleIntercepted"))
|
||||
|
||||
os.environ["CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN"] = "true"
|
||||
# We don't see this compilation at all
|
||||
say("Doing unseen compilation")
|
||||
commands.run("kotlinc notSeen.kt")
|
||||
# This is extracted as it has the extractor flags manually added
|
||||
say("Doing manual compilation")
|
||||
commands.run(["kotlinc", "manual.kt"] + getManualFlags("manual"))
|
||||
|
||||
|
||||
@runs_on.posix
|
||||
def test(codeql, java_full, build):
|
||||
codeql.database.create(command=build, source_root="code")
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
from create_database_utils import *
|
||||
import runs_on
|
||||
|
||||
run_codeql_database_create(["kotlinc test1.kt", "kotlinc test2.kt -module-name mymodule", "kotlinc test3.kt -module-name reservedchars\\\"${}/", "javac User.java -cp ." ], lang="java")
|
||||
|
||||
@runs_on.posix
|
||||
def test(codeql, java_full):
|
||||
codeql.database.create(
|
||||
command=[
|
||||
"kotlinc test1.kt",
|
||||
"kotlinc test2.kt -module-name mymodule",
|
||||
'kotlinc test3.kt -module-name reservedchars\\"${}/',
|
||||
"javac User.java -cp .",
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
from create_database_utils import *
|
||||
import runs_on
|
||||
|
||||
os.mkdir('build1')
|
||||
os.mkdir('build2')
|
||||
run_codeql_database_create(["kotlinc kConsumer.kt -d build1", "javac Test.java -cp build1 -d build2", "kotlinc user.kt -cp build1:build2"], lang="java")
|
||||
|
||||
@runs_on.posix
|
||||
def test(codeql, java_full):
|
||||
codeql.database.create(
|
||||
command=[
|
||||
"kotlinc kConsumer.kt -d build1",
|
||||
"javac Test.java -cp build1 -d build2",
|
||||
"kotlinc user.kt -cp build1:build2",
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
dependencies:
|
||||
codeql/java-all: '*'
|
||||
codeql/java-tests: '*'
|
||||
codeql/java-queries: '*'
|
||||
warnOnImplicitThis: true
|
||||
Reference in New Issue
Block a user