Merge pull request #10402 from tamasvajk/kotlin-comp-args

Kotlin: Add integration test for compiler argument extraction
This commit is contained in:
Tamás Vajk
2022-09-14 15:27:18 +02:00
committed by GitHub
6 changed files with 86 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Kotlin application project to get you started.
* For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
* User Manual available at https://docs.gradle.org/7.0.2/userguide/building_java_projects.html
*/
plugins {
// Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
id 'org.jetbrains.kotlin.jvm' version '1.7.0'
// Apply the application plugin to add support for building a CLI application in Java.
id 'application'
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
application {
// Define the main class for the application.
mainClass = 'testProject.AppKt'
}

View File

@@ -0,0 +1,15 @@
/*
* This Kotlin source file was generated by the Gradle 'init' task.
*/
package testProject
class App {
val greeting: String
get() {
return "Hello World!"
}
}
fun main() {
// TODO: println(App().greeting)
}

View File

@@ -0,0 +1,15 @@
| 0 | -Xallow-no-source-files |
| 1 | -classpath |
| 2 | <PATH> |
| 3 | -d |
| 4 | app/build/classes/kotlin/main |
| 5 | -jdk-home |
| 6 | <PATH> |
| 7 | -module-name |
| 8 | app |
| 9 | -no-reflect |
| 10 | -no-stdlib |
| 11 | <PLUGINS> |
| 12 | app/src/main/kotlin/testProject/App.kt |
| 13 | -jvm-target |
| 14 | 1.8 |

View File

@@ -0,0 +1,15 @@
import java
private string getArgument(Compilation c, int i) {
exists(string arg | arg = c.getArgument(i) |
if exists(arg.indexOf("-Xplugin="))
then result = "<PLUGINS>"
else
if c.getArgument(i - 1) = ["-classpath", "-jdk-home"]
then result = "<PATH>"
else result = arg
)
}
from Compilation c, int i
select i, getArgument(c, i)

View File

@@ -0,0 +1,11 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user manual at https://docs.gradle.org/7.0.2/userguide/multi_project_builds.html
*/
rootProject.name = 'testProject'
include('app')

View File

@@ -0,0 +1,5 @@
from create_database_utils import *
run_codeql_database_create(
["gradle build --no-daemon --no-build-cache"], lang="java")
runSuccessfully(["gradle", "clean"])