Add diagnostic tests against Java 9
These tests currently won't run if you don't have environment variable JDK_9 set up
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
import java.util.stream.IntStream
|
||||||
|
|
||||||
|
fun foo(s: IntStream) {
|
||||||
|
val n = 1000000000
|
||||||
|
val delta = 1.0 / n
|
||||||
|
val startTimeNanos = System.nanoTime()
|
||||||
|
val pi = 4.0 * delta * s.mapToDouble { i ->
|
||||||
|
val x = (i - 0.5) * delta
|
||||||
|
1.0 / (1.0 + x * x)
|
||||||
|
}.sum()
|
||||||
|
val elapseTime = (System.nanoTime() - startTimeNanos) / 1e9
|
||||||
|
println("Parallel Streams $pi $n $elapseTime")
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun foo(/*0*/ s: java.util.stream.IntStream): kotlin.Unit
|
||||||
@@ -459,7 +459,18 @@ public class KotlinTestUtils {
|
|||||||
JvmContentRootsKt.addJvmClasspathRoot(configuration, findAndroidApiJar());
|
JvmContentRootsKt.addJvmClasspathRoot(configuration, findAndroidApiJar());
|
||||||
}
|
}
|
||||||
else if (jdkKind == TestJdkKind.FULL_JDK_6) {
|
else if (jdkKind == TestJdkKind.FULL_JDK_6) {
|
||||||
JvmContentRootsKt.addJvmClasspathRoots(configuration, PathUtil.getJdkClassesRootsFromJre(getJre6Home()));
|
String jdk6 = System.getenv("JDK_16");
|
||||||
|
assert jdk6 != null : "Environment variable JDK_16 is not set";
|
||||||
|
JvmContentRootsKt.addJvmClasspathRoots(configuration, PathUtil.getJdkClassesRootsFromJre(getJreHome(jdk6)));
|
||||||
|
}
|
||||||
|
else if (jdkKind == TestJdkKind.FULL_JDK_9) {
|
||||||
|
String jdk9 = System.getenv("JDK_9");
|
||||||
|
if (jdk9 != null) {
|
||||||
|
JvmContentRootsKt.addJvmClasspathRoots(configuration, PathUtil.getJdkClassesRootsFromJre(getJreHome(jdk9)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.err.println("Environment variable JDK_9 is not set, the test will be skipped");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
JvmContentRootsKt.addJvmClasspathRoots(configuration, PathUtil.getJdkClassesRootsFromCurrentJre());
|
JvmContentRootsKt.addJvmClasspathRoots(configuration, PathUtil.getJdkClassesRootsFromCurrentJre());
|
||||||
@@ -484,12 +495,9 @@ public class KotlinTestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static String getJre6Home() {
|
private static String getJreHome(@NotNull String jdkHome) {
|
||||||
String home = System.getenv("JDK_16");
|
File jre = new File(jdkHome, "jre");
|
||||||
if (home == null) throw new AssertionError("Environment variable JDK_16 is not set");
|
return jre.isDirectory() ? jre.getPath() : jdkHome;
|
||||||
|
|
||||||
File jre = new File(home, "jre");
|
|
||||||
return jre.isDirectory() ? jre.getPath() : home;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void resolveAllKotlinFiles(KotlinCoreEnvironment environment) throws IOException {
|
public static void resolveAllKotlinFiles(KotlinCoreEnvironment environment) throws IOException {
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ public enum TestJdkKind {
|
|||||||
MODIFIED_MOCK_JDK,
|
MODIFIED_MOCK_JDK,
|
||||||
// JDK found at $JDK_16
|
// JDK found at $JDK_16
|
||||||
FULL_JDK_6,
|
FULL_JDK_6,
|
||||||
|
// JDK found at $JDK_9
|
||||||
|
FULL_JDK_9,
|
||||||
// JDK found at java.home
|
// JDK found at java.home
|
||||||
FULL_JDK,
|
FULL_JDK,
|
||||||
ANDROID_API,
|
ANDROID_API,
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
* http://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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.checkers;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.kotlin.test.ConfigurationKind;
|
||||||
|
import org.jetbrains.kotlin.test.TestJdkKind;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public abstract class AbstractDiagnosticsWithJdk9Test extends AbstractDiagnosticsTest {
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
protected ConfigurationKind getConfigurationKind() {
|
||||||
|
return ConfigurationKind.ALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
protected TestJdkKind getTestJdkKind() {
|
||||||
|
return TestJdkKind.FULL_JDK_9;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doMultiFileTest(
|
||||||
|
@NotNull File file,
|
||||||
|
@NotNull Map<String, ModuleAndDependencies> modules,
|
||||||
|
@NotNull List<TestFile> testFiles
|
||||||
|
) {
|
||||||
|
if (System.getenv("JDK_9") == null) {
|
||||||
|
// Skip this test if no environment variable JDK_9 is set up
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
super.doMultiFileTest(file, modules, testFiles);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2017 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
* http://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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.checkers;
|
||||||
|
|
||||||
|
import com.intellij.testFramework.TestDataPath;
|
||||||
|
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||||
|
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||||
|
import org.jetbrains.kotlin.test.TargetBackend;
|
||||||
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
@TestMetadata("compiler/testData/diagnostics/testsWithJava9")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public class DiagnosticsWithJdk9TestGenerated extends AbstractDiagnosticsWithJdk9Test {
|
||||||
|
public void testAllFilesPresentInTestsWithJava9() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithJava9"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt11167.kt")
|
||||||
|
public void testKt11167() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJava9/kt11167.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -205,6 +205,10 @@ fun main(args: Array<String>) {
|
|||||||
model("diagnostics/testWithModifiedMockJdk")
|
model("diagnostics/testWithModifiedMockJdk")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testClass<AbstractDiagnosticsWithJdk9Test> {
|
||||||
|
model("diagnostics/testsWithJava9")
|
||||||
|
}
|
||||||
|
|
||||||
testClass<AbstractMultiPlatformIntegrationTest> {
|
testClass<AbstractMultiPlatformIntegrationTest> {
|
||||||
model("multiplatform", extension = null, recursive = true, excludeParentDirs = true)
|
model("multiplatform", extension = null, recursive = true, excludeParentDirs = true)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user