mirror of
https://github.com/github/codeql.git
synced 2026-04-26 01:05:15 +02:00
Port all-platforms/kotlin tests to pytest.
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
from create_database_utils import *
|
||||
import os
|
||||
|
||||
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):
|
||||
os.mkdir("out")
|
||||
codeql.database.create(
|
||||
command=["kotlinc test.kt -d out", "javac User.java -cp out", "kotlinc ktUser.kt -cp out"]
|
||||
)
|
||||
|
||||
@@ -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,23 @@
|
||||
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):
|
||||
for var in [
|
||||
"CODEQL_EXTRACTOR_JAVA_AGENT_ENABLE_KOTLIN",
|
||||
"CODEQL_EXTRACTOR_JAVA_AGENT_DISABLE_KOTLIN",
|
||||
]:
|
||||
if var in os.environ:
|
||||
del os.environ[var]
|
||||
codeql.database.create(command=build)
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
from create_database_utils import *
|
||||
import glob
|
||||
def test(codeql, java_full, cwd):
|
||||
java_srcs = [str(s) for s in cwd.glob('*.java')]
|
||||
|
||||
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")
|
||||
codeql.database.create(
|
||||
command=[
|
||||
f"javac {' '.join(java_srcs)} -d {cwd / '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,10 @@
|
||||
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(["kotlinc test.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="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,11 @@
|
||||
from create_database_utils import *
|
||||
import glob
|
||||
import commands
|
||||
|
||||
# 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, cwd):
|
||||
# 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", *(cwd / "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,18 @@
|
||||
| 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 |
|
||||
Test script
|
||||
Log file
|
||||
1
|
||||
CodeQL Kotlin extractor
|
||||
INFO
|
||||
Extraction started
|
||||
CodeQL Kotlin extractor
|
||||
INFO
|
||||
Extraction for invocation TRAP file <FILENAME>
|
||||
CodeQL Kotlin extractor
|
||||
INFO
|
||||
Kotlin version <VERSION>
|
||||
CodeQL Kotlin extractor
|
||||
INFO
|
||||
Extracting file test.kt
|
||||
CodeQL Kotlin extractor
|
||||
INFO
|
||||
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"
|
||||
file_index = 0
|
||||
for log_file in log_dir.glob("kotlin-extractor*.log"):
|
||||
file_index += 1
|
||||
f_out.write(f"Test script\nLog file\n{file_index}\n")
|
||||
for line in log_file.read_text().splitlines():
|
||||
j = json.loads(line)
|
||||
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
|
||||
f_out.write(f"{j['origin']}\n{j['kind']}\n{msg}\n")
|
||||
|
||||
@@ -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,28 @@
|
||||
from create_database_utils import *
|
||||
import runs_on
|
||||
import os
|
||||
|
||||
|
||||
def check_extensions(directory, counts):
|
||||
if platform.system() == 'Windows':
|
||||
if runs_on.windows:
|
||||
# It's important that the path is a Unicode path on Windows, so
|
||||
# that the right system calls get used.
|
||||
directory = u'' + directory
|
||||
directory = "" + directory
|
||||
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 +31,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))
|
||||
|
||||
Reference in New Issue
Block a user