diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java index a8ca78061f5..64d58f9ce1b 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java @@ -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. diff --git a/libraries/tools/kotlinp/test/org/jetbrains/kotlin/kotlinp/test/KotlinpCompilerTestDataTest.kt b/libraries/tools/kotlinp/test/org/jetbrains/kotlin/kotlinp/test/KotlinpCompilerTestDataTest.kt new file mode 100644 index 00000000000..d972fd73604 --- /dev/null +++ b/libraries/tools/kotlinp/test/org/jetbrains/kotlin/kotlinp/test/KotlinpCompilerTestDataTest.kt @@ -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> { + val baseDirs = listOf( + "compiler/testData/loadJava/compiledKotlin", + "compiler/testData/serialization/builtinsSerializer" + ) + + return buildSequence> { + for (baseDir in baseDirs) { + for (file in File(baseDir).walkTopDown()) { + if (file.extension == "kt") { + yield(arrayOf(file)) + } + } + } + }.toList() + } + } +}