diff --git a/compiler-plugin/build.gradle.kts b/compiler-plugin/build.gradle.kts index 52da70b..f02ee60 100644 --- a/compiler-plugin/build.gradle.kts +++ b/compiler-plugin/build.gradle.kts @@ -16,6 +16,9 @@ plugins { project.plugins.apply(D8Plugin::class.java) +val testDataDir = layout.projectDirectory.dir("testData") +val testGenDirectory = layout.buildDirectory.dir("test-gen") + sourceSets { main { java.setSrcDirs(listOf("src")) @@ -25,13 +28,14 @@ sourceSets { java.setSrcDirs(listOf("test-fixtures")) } test { - java.setSrcDirs(listOf("test", "test-gen")) - resources.setSrcDirs(listOf("testData")) + java.setSrcDirs(listOf("test", testGenDirectory)) + resources.setSrcDirs(listOf(testDataDir)) } } idea { - module.generatedSourceDirs.add(projectDir.resolve("test-gen")) + // This is needed until IDEA fixes IDEA-339729. + module.generatedSourceDirs.add(testGenDirectory.get().asFile) } val testArtifacts: Configuration by configurations.creating @@ -123,15 +127,21 @@ kotlin { } val generateTests by tasks.registering(JavaExec::class) { - inputs.dir(layout.projectDirectory.dir("testData")) + inputs.dir(testDataDir) .withPropertyName("testData") .withPathSensitivity(PathSensitivity.RELATIVE) - outputs.dir(layout.projectDirectory.dir("test-gen")) + outputs.dir(testGenDirectory) .withPropertyName("generatedTests") classpath = sourceSets.testFixtures.get().runtimeClasspath mainClass.set("org.jetbrains.kotlin.compiler.plugin.template.GenerateTestsKt") workingDir = rootDir + args( + listOf( + testGenDirectory.get().asFile.absolutePath, + testDataDir.asFile.absolutePath, + ) + ) } tasks.compileTestKotlin { diff --git a/compiler-plugin/test-fixtures/org/jetbrains/kotlin/compiler/plugin/template/GenerateTests.kt b/compiler-plugin/test-fixtures/org/jetbrains/kotlin/compiler/plugin/template/GenerateTests.kt index b0efa32..b889b20 100644 --- a/compiler-plugin/test-fixtures/org/jetbrains/kotlin/compiler/plugin/template/GenerateTests.kt +++ b/compiler-plugin/test-fixtures/org/jetbrains/kotlin/compiler/plugin/template/GenerateTests.kt @@ -1,21 +1,24 @@ package org.jetbrains.kotlin.compiler.plugin.template import org.jetbrains.kotlin.compiler.plugin.template.runners.AbstractJsBoxTest +import org.jetbrains.kotlin.compiler.plugin.template.runners.AbstractJsDiagnosticTest import org.jetbrains.kotlin.compiler.plugin.template.runners.AbstractJvmBoxTest import org.jetbrains.kotlin.compiler.plugin.template.runners.AbstractJvmDiagnosticTest import org.jetbrains.kotlin.generators.dsl.junit5.generateTestGroupSuiteWithJUnit5 -fun main() { +fun main(args: Array) { generateTestGroupSuiteWithJUnit5 { - testGroup(testDataRoot = "compiler-plugin/testData", testsRoot = "compiler-plugin/test-gen") { + testGroup(testsRoot = args[0], testDataRoot = args[1]) { testClass { model("diagnostics") } + testClass { + model("diagnostics") + } testClass { model("box") } - testClass { model("box") } diff --git a/compiler-plugin/test-fixtures/org/jetbrains/kotlin/compiler/plugin/template/runners/AbstractJsDiagnosticTest.kt b/compiler-plugin/test-fixtures/org/jetbrains/kotlin/compiler/plugin/template/runners/AbstractJsDiagnosticTest.kt new file mode 100644 index 0000000..5df9dbd --- /dev/null +++ b/compiler-plugin/test-fixtures/org/jetbrains/kotlin/compiler/plugin/template/runners/AbstractJsDiagnosticTest.kt @@ -0,0 +1,37 @@ +package org.jetbrains.kotlin.compiler.plugin.template.runners + +import org.jetbrains.kotlin.compiler.plugin.template.services.configurePlugin +import org.jetbrains.kotlin.js.test.runners.AbstractJsDiagnosticWithBackendTestBase +import org.jetbrains.kotlin.test.FirParser +import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder +import org.jetbrains.kotlin.test.directives.CodegenTestDirectives +import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives +import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives +import org.jetbrains.kotlin.test.runners.AbstractFirPhasedDiagnosticTest +import org.jetbrains.kotlin.test.services.EnvironmentBasedStandardLibrariesPathProvider +import org.jetbrains.kotlin.test.services.KotlinStandardLibrariesPathProvider + +open class AbstractJsDiagnosticTest : AbstractJsDiagnosticWithBackendTestBase(FirParser.LightTree) { + override fun createKotlinStandardLibrariesPathProvider(): KotlinStandardLibrariesPathProvider { + return EnvironmentBasedStandardLibrariesPathProvider + } + + override fun configure(builder: TestConfigurationBuilder) = with(builder) { + super.configure(builder) + /* + * Containers of different directives, which can be used in tests: + * - ModuleStructureDirectives + * - LanguageSettingsDirectives + * - DiagnosticsDirectives + * - FirDiagnosticsDirectives + * + * All of them are located in `org.jetbrains.kotlin.test.directives` package + */ + defaultDirectives { + +FirDiagnosticsDirectives.FIR_DUMP + +FirDiagnosticsDirectives.DISABLE_GENERATED_FIR_TAGS + } + + configurePlugin() + } +} diff --git a/compiler-plugin/test-gen/org/jetbrains/kotlin/compiler/plugin/template/runners/JsBoxTestGenerated.java b/compiler-plugin/test-gen/org/jetbrains/kotlin/compiler/plugin/template/runners/JsBoxTestGenerated.java deleted file mode 100644 index 41dce70..0000000 --- a/compiler-plugin/test-gen/org/jetbrains/kotlin/compiler/plugin/template/runners/JsBoxTestGenerated.java +++ /dev/null @@ -1,38 +0,0 @@ - - -package org.jetbrains.kotlin.compiler.plugin.template.runners; - -import com.intellij.testFramework.TestDataPath; -import org.jetbrains.kotlin.test.util.KtTestUtil; -import org.jetbrains.kotlin.test.TestMetadata; -import org.junit.jupiter.api.Test; - -import java.io.File; -import java.util.regex.Pattern; - -/** This class is generated by {@link org.jetbrains.kotlin.compiler.plugin.template.GenerateTestsKt}. DO NOT MODIFY MANUALLY */ -@SuppressWarnings("all") -@TestMetadata("compiler-plugin/testData/box") -@TestDataPath("$PROJECT_ROOT") -public class JsBoxTestGenerated extends AbstractJsBoxTest { - private void run(String fileName) { - runTest("compiler-plugin/testData/box/" + fileName); - } - - @Test - public void testAllFilesPresentInBox() { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler-plugin/testData/box"), Pattern.compile("^(.+)\\.kt$"), null, true); - } - - @Test - @TestMetadata("anotherBoxTest.kt") - public void testAnotherBoxTest() { - run("anotherBoxTest.kt"); - } - - @Test - @TestMetadata("simple.kt") - public void testSimple() { - run("simple.kt"); - } -} diff --git a/compiler-plugin/test-gen/org/jetbrains/kotlin/compiler/plugin/template/runners/JvmBoxTestGenerated.java b/compiler-plugin/test-gen/org/jetbrains/kotlin/compiler/plugin/template/runners/JvmBoxTestGenerated.java deleted file mode 100644 index c234a49..0000000 --- a/compiler-plugin/test-gen/org/jetbrains/kotlin/compiler/plugin/template/runners/JvmBoxTestGenerated.java +++ /dev/null @@ -1,38 +0,0 @@ - - -package org.jetbrains.kotlin.compiler.plugin.template.runners; - -import com.intellij.testFramework.TestDataPath; -import org.jetbrains.kotlin.test.util.KtTestUtil; -import org.jetbrains.kotlin.test.TestMetadata; -import org.junit.jupiter.api.Test; - -import java.io.File; -import java.util.regex.Pattern; - -/** This class is generated by {@link org.jetbrains.kotlin.compiler.plugin.template.GenerateTestsKt}. DO NOT MODIFY MANUALLY */ -@SuppressWarnings("all") -@TestMetadata("compiler-plugin/testData/box") -@TestDataPath("$PROJECT_ROOT") -public class JvmBoxTestGenerated extends AbstractJvmBoxTest { - private void run(String fileName) { - runTest("compiler-plugin/testData/box/" + fileName); - } - - @Test - public void testAllFilesPresentInBox() { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler-plugin/testData/box"), Pattern.compile("^(.+)\\.kt$"), null, true); - } - - @Test - @TestMetadata("anotherBoxTest.kt") - public void testAnotherBoxTest() { - run("anotherBoxTest.kt"); - } - - @Test - @TestMetadata("simple.kt") - public void testSimple() { - run("simple.kt"); - } -} diff --git a/compiler-plugin/test-gen/org/jetbrains/kotlin/compiler/plugin/template/runners/JvmDiagnosticTestGenerated.java b/compiler-plugin/test-gen/org/jetbrains/kotlin/compiler/plugin/template/runners/JvmDiagnosticTestGenerated.java deleted file mode 100644 index 73ab2d8..0000000 --- a/compiler-plugin/test-gen/org/jetbrains/kotlin/compiler/plugin/template/runners/JvmDiagnosticTestGenerated.java +++ /dev/null @@ -1,38 +0,0 @@ - - -package org.jetbrains.kotlin.compiler.plugin.template.runners; - -import com.intellij.testFramework.TestDataPath; -import org.jetbrains.kotlin.test.util.KtTestUtil; -import org.jetbrains.kotlin.test.TestMetadata; -import org.junit.jupiter.api.Test; - -import java.io.File; -import java.util.regex.Pattern; - -/** This class is generated by {@link org.jetbrains.kotlin.compiler.plugin.template.GenerateTestsKt}. DO NOT MODIFY MANUALLY */ -@SuppressWarnings("all") -@TestMetadata("compiler-plugin/testData/diagnostics") -@TestDataPath("$PROJECT_ROOT") -public class JvmDiagnosticTestGenerated extends AbstractJvmDiagnosticTest { - private void run(String fileName) { - runTest("compiler-plugin/testData/diagnostics/" + fileName); - } - - @Test - public void testAllFilesPresentInDiagnostics() { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler-plugin/testData/diagnostics"), Pattern.compile("^(.+)\\.kt$"), null, true); - } - - @Test - @TestMetadata("anotherDiagnosticTest.kt") - public void testAnotherDiagnosticTest() { - run("anotherDiagnosticTest.kt"); - } - - @Test - @TestMetadata("simple.kt") - public void testSimple() { - run("simple.kt"); - } -} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 1b33c55..b1b8ef5 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ca025c8..b52fb7e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,9 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip networkTimeout=10000 +retries=0 +retryBackOffMs=500 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 23d15a9..b9bb139 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 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. @@ -57,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -114,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -172,7 +171,6 @@ fi # 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" ) @@ -212,7 +210,6 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" diff --git a/gradlew.bat b/gradlew.bat index 5eed7ee..aa5f10b 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -23,8 +23,8 @@ @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. @@ -51,7 +51,7 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% @@ -65,30 +65,18 @@ echo. 1>&2 echo Please set the JAVA_HOME variable in your environment to match the 1>&2 echo location of your Java installation. 1>&2 -goto fail +"%COMSPEC%" /c exit 1 :execute @rem Setup the command line -set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel -: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 +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL%