Test kotlinx-metadata and kotlinp on compiler test data
#KT-23198
This commit is contained in:
@@ -406,12 +406,17 @@ public class KotlinTestUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File tmpDirForTest(TestCase test) throws IOException {
|
||||
File answer = normalizeFile(FileUtil.createTempDirectory(test.getClass().getSimpleName(), test.getName()));
|
||||
public static File tmpDirForTest(@NotNull String testClassName, @NotNull String testName) throws IOException {
|
||||
File answer = normalizeFile(FileUtil.createTempDirectory(testClassName, testName));
|
||||
deleteOnShutdown(answer);
|
||||
return answer;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File tmpDirForTest(TestCase test) throws IOException {
|
||||
return tmpDirForTest(test.getClass().getSimpleName(), test.getName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File tmpDir(String name) throws IOException {
|
||||
// We should use this form. otherwise directory will be deleted on each test.
|
||||
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.kotlinp.test
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.Parameterized
|
||||
import java.io.File
|
||||
import kotlin.coroutines.experimental.buildSequence
|
||||
|
||||
@RunWith(Parameterized::class)
|
||||
class KotlinpCompilerTestDataTest(private val file: File) {
|
||||
private class TestDisposable : Disposable {
|
||||
override fun dispose() {}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun doTest() {
|
||||
val tmpdir = KotlinTestUtils.tmpDirForTest(this::class.java.simpleName, file.nameWithoutExtension)
|
||||
|
||||
val disposable = TestDisposable()
|
||||
try {
|
||||
compileAndPrintAllFiles(file, disposable, tmpdir, compareWithTxt = false, readWriteAndCompare = true)
|
||||
} finally {
|
||||
Disposer.dispose(disposable)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
fun computeTestDataFiles(): Collection<Array<*>> {
|
||||
val baseDirs = listOf(
|
||||
"compiler/testData/loadJava/compiledKotlin",
|
||||
"compiler/testData/serialization/builtinsSerializer"
|
||||
)
|
||||
|
||||
return buildSequence<Array<*>> {
|
||||
for (baseDir in baseDirs) {
|
||||
for (file in File(baseDir).walkTopDown()) {
|
||||
if (file.extension == "kt") {
|
||||
yield(arrayOf(file))
|
||||
}
|
||||
}
|
||||
}
|
||||
}.toList()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user