tests fixed

This commit is contained in:
Dmitry Jemerov
2016-01-14 18:45:09 +01:00
parent 39c6e3712b
commit b60621c428
24 changed files with 52 additions and 35 deletions
@@ -7,4 +7,4 @@ java.lang.IllegalStateException: my error
at Script.a(Unknown Source)
at Script.<init>(Unknown Source)
Return code: 0
Return code: 3
@@ -30,7 +30,7 @@ abstract class AbstractForeignAnnotationsTest : AbstractDiagnosticsTest() {
override fun createCompilerConfiguration(javaFilesDir: File?): CompilerConfiguration {
val annotationsFile = MockLibraryUtil.compileLibraryToJar(
"compiler/testData/foreignAnnotations/annotations",
"foreign-annotations", /* addSources = */false)
"foreign-annotations", /* addSources = */false, /* allowKotlinPackage =*/ false)
return KotlinTestUtils.compilerConfigurationForTests(
ConfigurationKind.JDK_ONLY,
@@ -60,7 +60,7 @@ public abstract class AbstractTopLevelMembersInvocationTest extends AbstractByte
File library = new File(root, LIBRARY);
List<File> classPath = library.exists() ?
Collections.singletonList(MockLibraryUtil.compileLibraryToJar(library.getPath(), LIBRARY, false)) :
Collections.singletonList(MockLibraryUtil.compileLibraryToJar(library.getPath(), LIBRARY, false, false)) :
Collections.<File>emptyList();
assert !sourceFiles.isEmpty() : getTestName(true) + " should contain at least one .kt file";
@@ -71,7 +71,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
@NotNull
private File compileLibrary(@NotNull String sourcePath, @NotNull String... extraClassPath) {
return MockLibraryUtil.compileLibraryToJar(
new File(getTestDataDirectory(), sourcePath).getPath(), "customKotlinLib", false, extraClassPath
new File(getTestDataDirectory(), sourcePath).getPath(), "customKotlinLib", false, false, extraClassPath
);
}
@@ -53,13 +53,14 @@ public class MockLibraryUtil {
@NotNull String jarName,
boolean addSources,
boolean isJsLibrary,
boolean allowKotlinPackage,
@NotNull String... extraClasspath
) {
if (isJsLibrary) {
return compileJsLibraryToJar(sourcesPath, jarName, addSources);
}
else {
return compileLibraryToJar(sourcesPath, jarName, addSources, extraClasspath);
return compileLibraryToJar(sourcesPath, jarName, addSources, allowKotlinPackage, extraClasspath);
}
}
@@ -68,6 +69,7 @@ public class MockLibraryUtil {
@NotNull String sourcesPath,
@NotNull String jarName,
boolean addSources,
boolean allowKotlinPackage,
@NotNull String... extraClasspath
) {
try {
@@ -78,7 +80,7 @@ public class MockLibraryUtil {
File srcFile = new File(sourcesPath);
List<File> kotlinFiles = FileUtil.findFilesByMask(Pattern.compile(".*\\.kt"), srcFile);
if (srcFile.isFile() || !kotlinFiles.isEmpty()) {
compileKotlin(sourcesPath, classesDir, extraClasspath);
compileKotlin(sourcesPath, classesDir, allowKotlinPackage, extraClasspath);
}
List<File> javaFiles = FileUtil.findFilesByMask(Pattern.compile(".*\\.java"), srcFile);
@@ -170,6 +172,15 @@ public class MockLibraryUtil {
}
public static void compileKotlin(@NotNull String sourcesPath, @NotNull File outDir, @NotNull String... extraClasspath) {
compileKotlin(sourcesPath, outDir, false, extraClasspath);
}
public static void compileKotlin(
@NotNull String sourcesPath,
@NotNull File outDir,
boolean allowKotlinPackage,
@NotNull String... extraClasspath
) {
List<String> classpath = new ArrayList<String>();
if (new File(sourcesPath).isDirectory()) {
classpath.add(sourcesPath);
@@ -182,6 +193,9 @@ public class MockLibraryUtil {
args.add(outDir.getAbsolutePath());
args.add("-classpath");
args.add(StringUtil.join(classpath, File.pathSeparator));
if (allowKotlinPackage) {
args.add("-Xallow-kotlin-package");
}
runJvmCompiler(args);
}