Drop compilation of built-ins/stdlib from ForTestCompileRuntime
Because the process of building kotlin-runtime.jar will likely get more complicated soon, and that logic will already be present in build.xml. Run "ant compiler-quick runtime" instead before All Tests
This commit is contained in:
Generated
+4
-2
@@ -22,7 +22,6 @@
|
|||||||
<value defaultName="moduleWithDependencies" />
|
<value defaultName="moduleWithDependencies" />
|
||||||
</option>
|
</option>
|
||||||
<envs>
|
<envs>
|
||||||
<env name="kotlin.tests.actually.compile" value="true" />
|
|
||||||
<env name="NO_FS_ROOTS_ACCESS_CHECK" value="true" />
|
<env name="NO_FS_ROOTS_ACCESS_CHECK" value="true" />
|
||||||
</envs>
|
</envs>
|
||||||
<patterns />
|
<patterns />
|
||||||
@@ -35,6 +34,9 @@
|
|||||||
<RunnerSettings RunnerId="Run" />
|
<RunnerSettings RunnerId="Run" />
|
||||||
<ConfigurationWrapper RunnerId="Debug" />
|
<ConfigurationWrapper RunnerId="Debug" />
|
||||||
<ConfigurationWrapper RunnerId="Run" />
|
<ConfigurationWrapper RunnerId="Run" />
|
||||||
<method />
|
<method>
|
||||||
|
<option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/build.xml" target="compiler-quick" />
|
||||||
|
<option name="AntTarget" enabled="true" antfile="file://$PROJECT_DIR$/build.xml" target="runtime" />
|
||||||
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
+1
-3
@@ -16,9 +16,7 @@
|
|||||||
<option name="TEST_SEARCH_SCOPE">
|
<option name="TEST_SEARCH_SCOPE">
|
||||||
<value defaultName="moduleWithDependencies" />
|
<value defaultName="moduleWithDependencies" />
|
||||||
</option>
|
</option>
|
||||||
<envs>
|
<envs />
|
||||||
<env name="kotlin.tests.actually.compile" value="false" />
|
|
||||||
</envs>
|
|
||||||
<patterns>
|
<patterns>
|
||||||
<pattern testClass="org.jetbrains.jet.jps.build.IncrementalJpsTestGenerated" />
|
<pattern testClass="org.jetbrains.jet.jps.build.IncrementalJpsTestGenerated" />
|
||||||
<pattern testClass="org.jetbrains.jet.jps.build.IncrementalCacheVersionChangedTest" />
|
<pattern testClass="org.jetbrains.jet.jps.build.IncrementalCacheVersionChangedTest" />
|
||||||
|
|||||||
+1
-3
@@ -21,9 +21,7 @@
|
|||||||
<option name="TEST_SEARCH_SCOPE">
|
<option name="TEST_SEARCH_SCOPE">
|
||||||
<value defaultName="singleModule" />
|
<value defaultName="singleModule" />
|
||||||
</option>
|
</option>
|
||||||
<envs>
|
<envs />
|
||||||
<env name="kotlin.tests.actually.compile" value="false" />
|
|
||||||
</envs>
|
|
||||||
<patterns>
|
<patterns>
|
||||||
<pattern testClass="org.jetbrains.jet.completion.JvmSmartCompletionTestGenerated" />
|
<pattern testClass="org.jetbrains.jet.completion.JvmSmartCompletionTestGenerated" />
|
||||||
<pattern testClass="org.jetbrains.jet.completion.handlers.SmartCompletionHandlerTestGenerated" />
|
<pattern testClass="org.jetbrains.jet.completion.handlers.SmartCompletionHandlerTestGenerated" />
|
||||||
|
|||||||
+1
-101
@@ -16,113 +16,13 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.codegen.forTestCompile;
|
package org.jetbrains.jet.codegen.forTestCompile;
|
||||||
|
|
||||||
import com.intellij.openapi.util.io.FileUtil;
|
|
||||||
import com.intellij.util.ArrayUtil;
|
|
||||||
import kotlin.Function1;
|
|
||||||
import kotlin.KotlinPackage;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
|
||||||
import org.jetbrains.jet.cli.common.ExitCode;
|
|
||||||
import org.jetbrains.jet.cli.jvm.K2JVMCompiler;
|
|
||||||
import org.jetbrains.jet.utils.Profiler;
|
|
||||||
import org.jetbrains.jet.utils.UtilsPackage;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compile kotlin-runtime.jar that can be used in tests
|
|
||||||
*
|
|
||||||
* @see #runtimeJarForTests
|
|
||||||
*/
|
|
||||||
public class ForTestCompileRuntime {
|
public class ForTestCompileRuntime {
|
||||||
private static final String[] PATHS = {
|
|
||||||
"core/builtins/src", "core/runtime.jvm/src", "core/reflection/src", "core/reflection.jvm/src"
|
|
||||||
};
|
|
||||||
|
|
||||||
private ForTestCompileRuntime() {
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class Runtime extends ForTestCompileSomething {
|
|
||||||
private Runtime() {
|
|
||||||
super("runtime");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Runtime runtime = new Runtime();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void doCompile(@NotNull File classesDir) throws Exception {
|
|
||||||
compileBuiltIns(classesDir);
|
|
||||||
compileStdlib(classesDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void compileBuiltIns(@NotNull File destDir) throws IOException {
|
|
||||||
compileKotlinToJvm("built-ins", destDir, UtilsPackage.join(Arrays.asList(PATHS), File.pathSeparator), PATHS);
|
|
||||||
|
|
||||||
JetTestUtils.compileJavaFiles(
|
|
||||||
javaFilesUnder(PATHS),
|
|
||||||
Arrays.asList(
|
|
||||||
"-classpath", destDir.getPath(),
|
|
||||||
"-d", destDir.getPath()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private static List<File> javaFilesUnder(@NotNull String... paths) {
|
|
||||||
return KotlinPackage.flatMap(Arrays.asList(paths), new Function1<String, List<File>>() {
|
|
||||||
@Override
|
|
||||||
public List<File> invoke(String path) {
|
|
||||||
return FileUtil.findFilesByMask(Pattern.compile(".*\\.java"), new File(path));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void compileStdlib(@NotNull File destDir) throws IOException {
|
|
||||||
compileKotlinToJvm("stdlib", destDir, destDir.getPath(), "libraries/stdlib/src");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void compileKotlinToJvm(
|
|
||||||
@NotNull String debugName,
|
|
||||||
@NotNull File destDir,
|
|
||||||
@NotNull String classPath,
|
|
||||||
@NotNull String... src
|
|
||||||
) {
|
|
||||||
List<String> args = KotlinPackage.arrayListOf(
|
|
||||||
"-d", destDir.getPath(),
|
|
||||||
"-no-stdlib",
|
|
||||||
"-no-jdk-annotations",
|
|
||||||
"-nowarn",
|
|
||||||
"-annotations", JetTestUtils.getJdkAnnotationsJar().getAbsolutePath(),
|
|
||||||
"-classpath", classPath
|
|
||||||
);
|
|
||||||
args.addAll(Arrays.asList(src));
|
|
||||||
ExitCode exitCode = new K2JVMCompiler().exec(System.out, ArrayUtil.toStringArray(args));
|
|
||||||
if (exitCode != ExitCode.OK) {
|
|
||||||
throw new IllegalStateException("Compilation of " + debugName + " failed: " + exitCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static File runtimeJarForTests() {
|
public static File runtimeJarForTests() {
|
||||||
return ForTestCompileSomething.ACTUALLY_COMPILE ? Runtime.runtime.getJarFile() : new File("dist/kotlinc/lib/kotlin-runtime.jar");
|
return new File("dist/kotlinc/lib/kotlin-runtime.jar");
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method is very convenient when you have trouble compiling runtime in tests
|
|
||||||
public static void main(String[] args) throws IOException {
|
|
||||||
File destDir = JetTestUtils.tmpDir("runtime");
|
|
||||||
|
|
||||||
Profiler builtIns = Profiler.create("compileBuiltIns").start();
|
|
||||||
compileBuiltIns(destDir);
|
|
||||||
builtIns.end();
|
|
||||||
|
|
||||||
Profiler stdlib = Profiler.create("compileStdlib").start();
|
|
||||||
compileStdlib(destDir);
|
|
||||||
stdlib.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2013 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.jet.codegen.forTestCompile;
|
|
||||||
|
|
||||||
import com.google.common.io.Files;
|
|
||||||
import com.intellij.openapi.util.Pair;
|
|
||||||
import com.intellij.openapi.util.io.FileUtil;
|
|
||||||
import com.intellij.util.containers.Stack;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
|
||||||
import org.jetbrains.jet.TimeUtils;
|
|
||||||
|
|
||||||
import java.io.BufferedOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.jar.JarEntry;
|
|
||||||
import java.util.jar.JarOutputStream;
|
|
||||||
|
|
||||||
abstract class ForTestCompileSomething {
|
|
||||||
|
|
||||||
public static final boolean ACTUALLY_COMPILE = "true".equals(System.getenv("kotlin.tests.actually.compile"));
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private final String jarName;
|
|
||||||
private Throwable error;
|
|
||||||
private File jarFile;
|
|
||||||
|
|
||||||
ForTestCompileSomething(@NotNull String jarName) {
|
|
||||||
System.out.println("Compiling " + jarName + "...");
|
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
this.jarName = jarName;
|
|
||||||
try {
|
|
||||||
File tmpDir = JetTestUtils.tmpDir("test_jars");
|
|
||||||
|
|
||||||
jarFile = new File(tmpDir, jarName + ".jar");
|
|
||||||
|
|
||||||
File classesDir = new File(tmpDir, "classes");
|
|
||||||
|
|
||||||
FileUtil.createParentDirs(new File(classesDir, "dummy"));
|
|
||||||
|
|
||||||
doCompile(classesDir);
|
|
||||||
|
|
||||||
FileOutputStream stdlibJar = new FileOutputStream(jarFile);
|
|
||||||
try {
|
|
||||||
JarOutputStream jarOutputStream = new JarOutputStream(new BufferedOutputStream(stdlibJar));
|
|
||||||
try {
|
|
||||||
copyToJar(classesDir, jarOutputStream);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
jarOutputStream.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
stdlibJar.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
FileUtil.delete(classesDir);
|
|
||||||
long end = System.currentTimeMillis();
|
|
||||||
System.out.println("Compiling " + jarName + " done in " + TimeUtils.millisecondsToSecondsString(end - start) + "s");
|
|
||||||
} catch (Throwable e) {
|
|
||||||
error = e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void copyToJar(File root, JarOutputStream os) throws IOException {
|
|
||||||
Stack<Pair<String, File>> toCopy = new Stack<Pair<String, File>>();
|
|
||||||
toCopy.add(new Pair<String, File>("", root));
|
|
||||||
while (!toCopy.empty()) {
|
|
||||||
Pair<String, File> pop = toCopy.pop();
|
|
||||||
File file = pop.getSecond();
|
|
||||||
if (file.isFile()) {
|
|
||||||
os.putNextEntry(new JarEntry(pop.getFirst()));
|
|
||||||
Files.copy(file, os);
|
|
||||||
}
|
|
||||||
else if (file.isDirectory()) {
|
|
||||||
for (File child : file.listFiles()) {
|
|
||||||
String path = pop.getFirst().isEmpty() ? child.getName() : pop.getFirst() + "/" + child.getName();
|
|
||||||
toCopy.add(new Pair<String, File>(path, child));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void doCompile(@NotNull File classesDir) throws Exception;
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public File getJarFile() {
|
|
||||||
if (error != null) {
|
|
||||||
throw new IllegalStateException("compilation of " + jarName + " failed: " + error, error);
|
|
||||||
}
|
|
||||||
return jarFile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -27,10 +27,9 @@ import org.jetbrains.jet.plugin.PluginTestCaseBase
|
|||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
import org.jetbrains.jet.plugin.caches.resolve.analyzeFully
|
import org.jetbrains.jet.plugin.caches.resolve.analyzeFully
|
||||||
import org.jetbrains.jet.lang.diagnostics.Severity
|
import org.jetbrains.jet.lang.diagnostics.Severity
|
||||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime
|
|
||||||
import org.jetbrains.jet.JetTestUtils
|
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
import org.jetbrains.jet.plugin.JetLightCodeInsightFixtureTestCase
|
import org.jetbrains.jet.plugin.JetLightCodeInsightFixtureTestCase
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
public class NoErrorsInStdlibTest : JetLightCodeInsightFixtureTestCase() {
|
public class NoErrorsInStdlibTest : JetLightCodeInsightFixtureTestCase() {
|
||||||
public fun testNoErrors() {
|
public fun testNoErrors() {
|
||||||
@@ -68,9 +67,7 @@ public class NoErrorsInStdlibTest : JetLightCodeInsightFixtureTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getProjectDescriptor(): LightProjectDescriptor {
|
override fun getProjectDescriptor(): LightProjectDescriptor {
|
||||||
val dir = JetTestUtils.tmpDir("noErrorsInStdlibTest")
|
return object : JetJdkAndLibraryProjectDescriptor(File("dist/classes/builtins")) {
|
||||||
ForTestCompileRuntime.compileBuiltIns(dir)
|
|
||||||
return object : JetJdkAndLibraryProjectDescriptor(dir) {
|
|
||||||
override fun getSdk(): Sdk? = PluginTestCaseBase.fullJdk()
|
override fun getSdk(): Sdk? = PluginTestCaseBase.fullJdk()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user