Remove binary test data from completion tests
Delete CompileBinaryTestData script, since there are no tests with binary test data left in the repository
This commit is contained in:
@@ -1,95 +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.generators.tests
|
|
||||||
|
|
||||||
import java.io.File
|
|
||||||
import com.intellij.openapi.util.SystemInfo
|
|
||||||
import com.intellij.openapi.util.io.FileUtil
|
|
||||||
import java.lang.annotation.Retention
|
|
||||||
import java.lang.annotation.RetentionPolicy
|
|
||||||
|
|
||||||
var cwd = File("")
|
|
||||||
fun mv(from: String, to: String) = File(cwd, from).renameTo(File(cwd, to))
|
|
||||||
fun cp(from: String, to: String) = File(cwd, from).copyTo(File(cwd, to))
|
|
||||||
fun rm(path: String) = FileUtil.delete(File(cwd, path))
|
|
||||||
|
|
||||||
fun runProcess(cmd: String) {
|
|
||||||
val process = Runtime.getRuntime().exec(cmd)
|
|
||||||
process.waitFor()
|
|
||||||
process.getInputStream()?.reader()?.forEachLine { println(it) }
|
|
||||||
process.getErrorStream()?.reader()?.forEachLine { System.err.println(it) }
|
|
||||||
if (process.exitValue() != 0) {
|
|
||||||
System.err.println("Exit code ${process.exitValue()} was returned by: $cmd")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun jar(dest: String, src: String) {
|
|
||||||
runProcess("jar cvf $cwd/$dest -C $cwd $src")
|
|
||||||
}
|
|
||||||
|
|
||||||
Retention(RetentionPolicy.RUNTIME)
|
|
||||||
private annotation class GenScript(val dir: String, val source: String, val binary: String)
|
|
||||||
|
|
||||||
private object BinaryTestData {
|
|
||||||
GenScript("idea/testData/completion/basic/custom/", "TopLevelNonImportedExtFunSource.kt", "TopLevelNonImportedExtFun.jar")
|
|
||||||
fun genTopLevelNonImportedExtFun() {
|
|
||||||
jar("TopLevelNonImportedExtFun.jar", "abc")
|
|
||||||
rm("abc")
|
|
||||||
}
|
|
||||||
|
|
||||||
GenScript("idea/testData/completion/basic/custom/", "TopLevelNonImportedFunSource.kt", "TopLevelNonImportedFun.jar")
|
|
||||||
fun genTopLevelNonImportedFun() {
|
|
||||||
jar("TopLevelNonImportedFun.jar", "abc")
|
|
||||||
rm("abc")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun changeDirectory(dir: String) {
|
|
||||||
cwd = File(dir)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun deleteBinary(file: String) = rm(file)
|
|
||||||
|
|
||||||
fun compileSource(src: String) {
|
|
||||||
// We assume that ${script.source}.txt file exists and contains the source to compile. Kotlin compiler would not compile the source
|
|
||||||
// with the ".txt" extension, so we temporarily rename this file to ${script.source} (it should end with ".kt")
|
|
||||||
assert(src.endsWith(".kt"), "Source should have a '.kt' extension: $src")
|
|
||||||
mv("$src.txt", src)
|
|
||||||
try {
|
|
||||||
runProcess("dist/kotlinc/bin/kotlinc-jvm${if (SystemInfo.isWindows) ".bat" else ""} -src $cwd/$src -output $cwd")
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
mv(src, "$src.txt")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
System.setProperty("java.awt.headless", "true")
|
|
||||||
for (method in javaClass<BinaryTestData>().getDeclaredMethods()) {
|
|
||||||
val script = method.getAnnotation(javaClass<GenScript>()) as? GenScript ?: continue
|
|
||||||
|
|
||||||
println()
|
|
||||||
println("---------------------------------")
|
|
||||||
println("Processing: ${script.dir}")
|
|
||||||
|
|
||||||
changeDirectory(script.dir)
|
|
||||||
deleteBinary(script.binary)
|
|
||||||
compileSource(script.source)
|
|
||||||
|
|
||||||
method.invoke(BinaryTestData)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -316,7 +316,7 @@ public class GenerateTests {
|
|||||||
"idea/tests",
|
"idea/tests",
|
||||||
"JetJavaLibCompletionTestGenerated",
|
"JetJavaLibCompletionTestGenerated",
|
||||||
AbstractJavaWithLibCompletionTest.class,
|
AbstractJavaWithLibCompletionTest.class,
|
||||||
testModel("idea/testData/completion/basic/custom", false, "doTestWithJar"));
|
testModel("idea/testData/completion/basic/custom", false, "doTest"));
|
||||||
|
|
||||||
generateTest(
|
generateTest(
|
||||||
"idea/tests",
|
"idea/tests",
|
||||||
|
|||||||
Binary file not shown.
-3
@@ -1,8 +1,5 @@
|
|||||||
package abc
|
package abc
|
||||||
|
|
||||||
// To regenerate this test, run CompileBinaryTestData.kt
|
|
||||||
// Or manually, compile this file into jar
|
|
||||||
|
|
||||||
public fun abcdAAA1(): Unit {}
|
public fun abcdAAA1(): Unit {}
|
||||||
|
|
||||||
public fun abcdBBB2(i: Int) {}
|
public fun abcdBBB2(i: Int) {}
|
||||||
Binary file not shown.
-3
@@ -1,8 +1,5 @@
|
|||||||
package abc
|
package abc
|
||||||
|
|
||||||
// To regenerate this test, run CompileBinaryTestData.kt
|
|
||||||
// Or manually, compile this file into jar
|
|
||||||
|
|
||||||
public fun abcdAAA1(): Unit {}
|
public fun abcdAAA1(): Unit {}
|
||||||
|
|
||||||
public fun abcdBBB2(i: Int) {}
|
public fun abcdBBB2(i: Int) {}
|
||||||
@@ -16,98 +16,26 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.completion;
|
package org.jetbrains.jet.completion;
|
||||||
|
|
||||||
import com.intellij.openapi.module.Module;
|
|
||||||
import com.intellij.openapi.module.ModuleType;
|
|
||||||
import com.intellij.openapi.module.StdModuleTypes;
|
|
||||||
import com.intellij.openapi.projectRoots.Sdk;
|
|
||||||
import com.intellij.openapi.roots.ContentEntry;
|
|
||||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
|
||||||
import com.intellij.openapi.roots.OrderRootType;
|
|
||||||
import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor;
|
|
||||||
import com.intellij.openapi.vfs.VfsUtil;
|
|
||||||
import com.intellij.testFramework.LightProjectDescriptor;
|
import com.intellij.testFramework.LightProjectDescriptor;
|
||||||
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl;
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.cli.common.ExitCode;
|
import org.jetbrains.jet.plugin.JdkAndMockLibraryProjectDescriptor;
|
||||||
import org.jetbrains.jet.cli.jvm.K2JVMCompiler;
|
|
||||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
|
|
||||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestPackJdkAnnotations;
|
|
||||||
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||||
import org.jetbrains.jet.plugin.project.TargetPlatform;
|
import org.jetbrains.jet.plugin.project.TargetPlatform;
|
||||||
import org.jetbrains.jet.testing.ConfigLibraryUtil;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public abstract class AbstractJavaWithLibCompletionTest extends JetFixtureCompletionBaseTestCase {
|
public abstract class AbstractJavaWithLibCompletionTest extends JetFixtureCompletionBaseTestCase {
|
||||||
public void doTestWithJar(String testPath) throws IOException {
|
private static final String TEST_PATH = PluginTestCaseBase.getTestDataPathBase() + "/completion/basic/custom";
|
||||||
|
|
||||||
File jarDependency = getOrCompileJarDependency(testPath);
|
|
||||||
assert jarDependency.exists() : "Library file should exist: " + jarDependency.getAbsolutePath();
|
|
||||||
NewLibraryEditor editor = new NewLibraryEditor();
|
|
||||||
editor.setName("doTestWithJarLib");
|
|
||||||
editor.addRoot(VfsUtil.getUrlForLibraryRoot(jarDependency), OrderRootType.CLASSES);
|
|
||||||
|
|
||||||
try {
|
|
||||||
ConfigLibraryUtil.configureLibrary(myModule, getProjectDescriptor().getSdk(), editor);
|
|
||||||
CodeInsightTestFixtureImpl.ensureIndexesUpToDate(getProject());
|
|
||||||
doTest(testPath);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
ConfigLibraryUtil.unConfigureLibrary(myModule, getProjectDescriptor().getSdk(), editor.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
protected LightProjectDescriptor getProjectDescriptor() {
|
protected LightProjectDescriptor getProjectDescriptor() {
|
||||||
return new LightProjectDescriptor() {
|
if (PluginTestCaseBase.isAllFilesPresentTest(getTestName(true))) {
|
||||||
@Override
|
return super.getProjectDescriptor();
|
||||||
public ModuleType getModuleType() {
|
}
|
||||||
return StdModuleTypes.JAVA;
|
return new JdkAndMockLibraryProjectDescriptor(TEST_PATH + "/" + getTestName(true) + "Src", false);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Sdk getSdk() {
|
|
||||||
return PluginTestCaseBase.jdkFromIdeaHome();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void configureModule(Module module, ModifiableRootModel model, ContentEntry contentEntry) {
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TargetPlatform getPlatform() {
|
public TargetPlatform getPlatform() {
|
||||||
return TargetPlatform.JVM;
|
return TargetPlatform.JVM;
|
||||||
}
|
}
|
||||||
|
|
||||||
//NOTE: you can just delete existing jar to recompile data for tests that have kotlin dependency
|
|
||||||
@NotNull
|
|
||||||
private File getOrCompileJarDependency(@NotNull String testPath) throws IOException {
|
|
||||||
File fullDirectoryPath = new File(testPath).getParentFile();
|
|
||||||
String jarLibName = getTestName(false) + ".jar";
|
|
||||||
File jarFile = new File(fullDirectoryPath, jarLibName);
|
|
||||||
if (!jarFile.exists()) {
|
|
||||||
compileDependencySources(jarFile, fullDirectoryPath);
|
|
||||||
}
|
|
||||||
return jarFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void compileDependencySources(@NotNull File outputFile, @NotNull File fullDirectoryPath) {
|
|
||||||
File sourcesDir = new File(fullDirectoryPath, getTestName(true) + "Src");
|
|
||||||
File stdlib = ForTestCompileRuntime.runtimeJarForTests();
|
|
||||||
File jdkAnnotations = ForTestPackJdkAnnotations.jdkAnnotationsForTests();
|
|
||||||
ExitCode rv = new K2JVMCompiler().exec(System.out,
|
|
||||||
"-src", sourcesDir.getAbsolutePath(),
|
|
||||||
"-jar", outputFile.getAbsolutePath(),
|
|
||||||
"-noStdlib",
|
|
||||||
"-classpath", stdlib.getAbsolutePath(),
|
|
||||||
"-noJdkAnnotations",
|
|
||||||
"-annotations", jdkAnnotations.getAbsolutePath());
|
|
||||||
Assert.assertEquals("compilation completed with non-zero code: " + rv.getCode(), ExitCode.OK, rv);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,12 +38,12 @@ public class JetJavaLibCompletionTestGenerated extends AbstractJavaWithLibComple
|
|||||||
|
|
||||||
@TestMetadata("TopLevelNonImportedExtFun.kt")
|
@TestMetadata("TopLevelNonImportedExtFun.kt")
|
||||||
public void testTopLevelNonImportedExtFun() throws Exception {
|
public void testTopLevelNonImportedExtFun() throws Exception {
|
||||||
doTestWithJar("idea/testData/completion/basic/custom/TopLevelNonImportedExtFun.kt");
|
doTest("idea/testData/completion/basic/custom/TopLevelNonImportedExtFun.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("TopLevelNonImportedFun.kt")
|
@TestMetadata("TopLevelNonImportedFun.kt")
|
||||||
public void testTopLevelNonImportedFun() throws Exception {
|
public void testTopLevelNonImportedFun() throws Exception {
|
||||||
doTestWithJar("idea/testData/completion/basic/custom/TopLevelNonImportedFun.kt");
|
doTest("idea/testData/completion/basic/custom/TopLevelNonImportedFun.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,16 +20,17 @@ import com.intellij.openapi.projectRoots.Sdk;
|
|||||||
import com.intellij.openapi.projectRoots.SdkModificator;
|
import com.intellij.openapi.projectRoots.SdkModificator;
|
||||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||||
import com.intellij.openapi.roots.AnnotationOrderRootType;
|
import com.intellij.openapi.roots.AnnotationOrderRootType;
|
||||||
|
import com.intellij.openapi.util.text.StringUtil;
|
||||||
import com.intellij.openapi.vfs.JarFileSystem;
|
import com.intellij.openapi.vfs.JarFileSystem;
|
||||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||||
import com.intellij.openapi.vfs.VirtualFile;
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestPackJdkAnnotations;
|
import org.jetbrains.jet.codegen.forTestCompile.ForTestPackJdkAnnotations;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public class PluginTestCaseBase {
|
public class PluginTestCaseBase {
|
||||||
|
|
||||||
public static final String TEST_DATA_PROJECT_RELATIVE = "/idea/testData";
|
public static final String TEST_DATA_PROJECT_RELATIVE = "/idea/testData";
|
||||||
|
|
||||||
private PluginTestCaseBase() {
|
private PluginTestCaseBase() {
|
||||||
@@ -59,4 +60,7 @@ public class PluginTestCaseBase {
|
|||||||
return getSdk(javaHome);
|
return getSdk(javaHome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isAllFilesPresentTest(@NotNull String testName) {
|
||||||
|
return StringUtil.startsWithIgnoreCase(testName, "allFilesPresentIn");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,20 +18,16 @@ package org.jetbrains.jet.resolve;
|
|||||||
|
|
||||||
import com.intellij.testFramework.LightProjectDescriptor;
|
import com.intellij.testFramework.LightProjectDescriptor;
|
||||||
import org.jetbrains.jet.plugin.JdkAndMockLibraryProjectDescriptor;
|
import org.jetbrains.jet.plugin.JdkAndMockLibraryProjectDescriptor;
|
||||||
|
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||||
import static com.intellij.openapi.util.text.StringUtil.startsWithIgnoreCase;
|
|
||||||
|
|
||||||
public abstract class AbstractResolveWithLibTest extends AbstractResolveBaseTest {
|
public abstract class AbstractResolveWithLibTest extends AbstractResolveBaseTest {
|
||||||
|
private static final String TEST_DATA_PATH = PluginTestCaseBase.getTestDataPathBase() + "/resolve/referenceWithLib";
|
||||||
private static final String TEST_DATA_PATH = "idea/testData/resolve/referenceWithLib";
|
|
||||||
private static final String ALL_FILES_PRESENT_PREFIX = "allFilesPresentIn";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LightProjectDescriptor getProjectDescriptor() {
|
protected LightProjectDescriptor getProjectDescriptor() {
|
||||||
String testName = getTestName(true);
|
if (PluginTestCaseBase.isAllFilesPresentTest(getTestName(true))) {
|
||||||
if (startsWithIgnoreCase(testName, ALL_FILES_PRESENT_PREFIX)) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new JdkAndMockLibraryProjectDescriptor(TEST_DATA_PATH + "/" + testName + "Src", false);
|
return new JdkAndMockLibraryProjectDescriptor(TEST_DATA_PATH + "/" + getTestName(true) + "Src", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user