[K/JS] Rework kotlin tests compilation to make it works with per-file granularity ^KT-61525 Fixed

This commit is contained in:
Artem Kobzar
2023-11-16 19:02:04 +00:00
committed by Space Team
parent a4b3b08e59
commit ff50d40b32
48 changed files with 2290 additions and 135 deletions
+3
View File
@@ -269,6 +269,9 @@ fun Test.setUpJsBoxTests(jsEnabled: Boolean, jsIrEnabled: Boolean, firEnabled: B
dependsOn(":kotlin-test:kotlin-test-js-ir:compileKotlinJs")
systemProperty("kotlin.js.kotlin.test.path", "libraries/kotlin.test/js-ir/build/classes/kotlin/js/main")
inputs.dir(rootDir.resolve("libraries/kotlin.test/js-ir/build/classes/kotlin/js/main"))
systemProperty("kotlin.js.kotlin.test.klib.path", "libraries/kotlin.test/js-ir/build/libs/kotlin-test-js-$version.klib")
inputs.file(rootDir.resolve("libraries/kotlin.test/js-ir/build/libs/kotlin-test-js-$version.klib"))
}
exclude("org/jetbrains/kotlin/js/testOld/api/*")
@@ -61,9 +61,11 @@ abstract class AbstractInvalidationTest(
companion object {
private val OUT_DIR_PATH = System.getProperty("kotlin.js.test.root.out.dir") ?: error("'kotlin.js.test.root.out.dir' is not set")
private val STDLIB_KLIB = File(System.getProperty("kotlin.js.stdlib.klib.path") ?: error("Please set stdlib path")).canonicalPath
private val KOTLIN_TEST_KLIB = File(System.getProperty("kotlin.js.kotlin.test.klib.path") ?: error("Please set kotlin.test path")).canonicalPath
private const val BOX_FUNCTION_NAME = "box"
private const val STDLIB_MODULE_NAME = "kotlin-kotlin-stdlib"
private const val KOTLIN_TEST_MODULE_NAME = "kotlin-kotlin-test"
private val TEST_FILE_IGNORE_PATTERN = Regex("^.*\\..+\\.\\w\\w$")
@@ -202,7 +204,7 @@ abstract class AbstractInvalidationTest(
val friends = mutableListOf<File>()
if (moduleStep.rebuildKlib) {
val dependencies = mutableListOf(File(STDLIB_KLIB))
val dependencies = mutableListOf(File(STDLIB_KLIB), File(KOTLIN_TEST_KLIB))
for (dep in moduleStep.dependencies) {
val klibFile = resolveModuleArtifact(dep.moduleName, buildDir)
dependencies += klibFile
@@ -229,7 +231,7 @@ abstract class AbstractInvalidationTest(
}
private fun verifyCacheUpdateStats(stepId: Int, stats: KotlinSourceFileMap<EnumSet<DirtyFileState>>, testInfo: List<TestStepInfo>) {
val gotStats = stats.filter { it.key.path != STDLIB_KLIB }
val gotStats = stats.filter { it.key.path != STDLIB_KLIB && it.key.path != KOTLIN_TEST_KLIB }
val checkedLibs = mutableSetOf<KotlinLibraryFile>()
@@ -260,7 +262,7 @@ abstract class AbstractInvalidationTest(
}
private fun verifyJsExecutableProducerBuildModules(stepId: Int, gotRebuilt: List<String>, expectedRebuilt: List<String>) {
val got = gotRebuilt.filter { !it.startsWith(STDLIB_MODULE_NAME) }
val got = gotRebuilt.filter { !it.startsWith(STDLIB_MODULE_NAME) && !it.startsWith(KOTLIN_TEST_MODULE_NAME) }
JUnit4Assertions.assertSameElements(got, expectedRebuilt) {
"Mismatched rebuilt modules at step $stepId"
}
@@ -388,7 +390,7 @@ abstract class AbstractInvalidationTest(
val cacheUpdater = CacheUpdater(
mainModule = mainModuleInfo.modulePath,
allModules = testInfo.mapTo(mutableListOf(STDLIB_KLIB)) { it.modulePath },
allModules = testInfo.mapTo(mutableListOf(STDLIB_KLIB, KOTLIN_TEST_KLIB)) { it.modulePath },
mainModuleFriends = mainModuleInfo.friends,
cacheDir = buildDir.resolve("incremental-cache").absolutePath,
compilerConfiguration = configuration,
@@ -349,6 +349,12 @@ public class JsFirInvalidationPerFileTestGenerated extends AbstractJsFirInvalida
runTest("js/js.translator/testData/incremental/invalidation/jsModuleAnnotationOnObjectWithUsage/");
}
@Test
@TestMetadata("kotlinTest")
public void testKotlinTest() throws Exception {
runTest("js/js.translator/testData/incremental/invalidation/kotlinTest/");
}
@Test
@TestMetadata("languageVersionSettings")
public void testLanguageVersionSettings() throws Exception {
@@ -349,6 +349,12 @@ public class JsFirInvalidationPerModuleTestGenerated extends AbstractJsFirInvali
runTest("js/js.translator/testData/incremental/invalidation/jsModuleAnnotationOnObjectWithUsage/");
}
@Test
@TestMetadata("kotlinTest")
public void testKotlinTest() throws Exception {
runTest("js/js.translator/testData/incremental/invalidation/kotlinTest/");
}
@Test
@TestMetadata("languageVersionSettings")
public void testLanguageVersionSettings() throws Exception {
@@ -349,6 +349,12 @@ public class JsIrES6InvalidationPerFileTestGenerated extends AbstractJsIrES6Inva
runTest("js/js.translator/testData/incremental/invalidation/jsModuleAnnotationOnObjectWithUsage/");
}
@Test
@TestMetadata("kotlinTest")
public void testKotlinTest() throws Exception {
runTest("js/js.translator/testData/incremental/invalidation/kotlinTest/");
}
@Test
@TestMetadata("languageVersionSettings")
public void testLanguageVersionSettings() throws Exception {
@@ -349,6 +349,12 @@ public class JsIrES6InvalidationPerModuleTestGenerated extends AbstractJsIrES6In
runTest("js/js.translator/testData/incremental/invalidation/jsModuleAnnotationOnObjectWithUsage/");
}
@Test
@TestMetadata("kotlinTest")
public void testKotlinTest() throws Exception {
runTest("js/js.translator/testData/incremental/invalidation/kotlinTest/");
}
@Test
@TestMetadata("languageVersionSettings")
public void testLanguageVersionSettings() throws Exception {
@@ -349,6 +349,12 @@ public class JsIrInvalidationPerFileTestGenerated extends AbstractJsIrInvalidati
runTest("js/js.translator/testData/incremental/invalidation/jsModuleAnnotationOnObjectWithUsage/");
}
@Test
@TestMetadata("kotlinTest")
public void testKotlinTest() throws Exception {
runTest("js/js.translator/testData/incremental/invalidation/kotlinTest/");
}
@Test
@TestMetadata("languageVersionSettings")
public void testLanguageVersionSettings() throws Exception {
@@ -349,6 +349,12 @@ public class JsIrInvalidationPerModuleTestGenerated extends AbstractJsIrInvalida
runTest("js/js.translator/testData/incremental/invalidation/jsModuleAnnotationOnObjectWithUsage/");
}
@Test
@TestMetadata("kotlinTest")
public void testKotlinTest() throws Exception {
runTest("js/js.translator/testData/incremental/invalidation/kotlinTest/");
}
@Test
@TestMetadata("languageVersionSettings")
public void testLanguageVersionSettings() throws Exception {
@@ -2616,6 +2616,70 @@ public class FirJsBoxTestGenerated extends AbstractFirJsBoxTest {
}
}
@Nested
@TestMetadata("js/js.translator/testData/box/esModules/kotlin.test")
@TestDataPath("$PROJECT_ROOT")
public class Kotlin_test {
@Test
public void testAllFilesPresentInKotlin_test() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/kotlin.test"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
}
@Test
@TestMetadata("beforeAfter.kt")
public void testBeforeAfter() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/beforeAfter.kt");
}
@Test
@TestMetadata("ignore.kt")
public void testIgnore() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/ignore.kt");
}
@Test
@TestMetadata("illegalParameters.kt")
public void testIllegalParameters() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/illegalParameters.kt");
}
@Test
@TestMetadata("incremental.kt")
public void testIncremental() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/incremental.kt");
}
@Test
@TestMetadata("inherited.kt")
public void testInherited() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/inherited.kt");
}
@Test
@TestMetadata("mpp.kt")
public void testMpp() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/mpp.kt");
}
@Test
@TestMetadata("nested.kt")
public void testNested() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/nested.kt");
}
@Test
@TestMetadata("returnTestResult.kt")
public void testReturnTestResult() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/returnTestResult.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/simple.kt");
}
}
@Nested
@TestMetadata("js/js.translator/testData/box/esModules/main")
@TestDataPath("$PROJECT_ROOT")
@@ -2722,6 +2722,70 @@ public class FirJsES6BoxTestGenerated extends AbstractFirJsES6BoxTest {
}
}
@Nested
@TestMetadata("js/js.translator/testData/box/esModules/kotlin.test")
@TestDataPath("$PROJECT_ROOT")
public class Kotlin_test {
@Test
public void testAllFilesPresentInKotlin_test() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/kotlin.test"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
}
@Test
@TestMetadata("beforeAfter.kt")
public void testBeforeAfter() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/beforeAfter.kt");
}
@Test
@TestMetadata("ignore.kt")
public void testIgnore() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/ignore.kt");
}
@Test
@TestMetadata("illegalParameters.kt")
public void testIllegalParameters() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/illegalParameters.kt");
}
@Test
@TestMetadata("incremental.kt")
public void testIncremental() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/incremental.kt");
}
@Test
@TestMetadata("inherited.kt")
public void testInherited() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/inherited.kt");
}
@Test
@TestMetadata("mpp.kt")
public void testMpp() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/mpp.kt");
}
@Test
@TestMetadata("nested.kt")
public void testNested() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/nested.kt");
}
@Test
@TestMetadata("returnTestResult.kt")
public void testReturnTestResult() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/returnTestResult.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/simple.kt");
}
}
@Nested
@TestMetadata("js/js.translator/testData/box/esModules/main")
@TestDataPath("$PROJECT_ROOT")
@@ -2722,6 +2722,70 @@ public class IrBoxJsES6TestGenerated extends AbstractIrBoxJsES6Test {
}
}
@Nested
@TestMetadata("js/js.translator/testData/box/esModules/kotlin.test")
@TestDataPath("$PROJECT_ROOT")
public class Kotlin_test {
@Test
public void testAllFilesPresentInKotlin_test() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/kotlin.test"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
}
@Test
@TestMetadata("beforeAfter.kt")
public void testBeforeAfter() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/beforeAfter.kt");
}
@Test
@TestMetadata("ignore.kt")
public void testIgnore() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/ignore.kt");
}
@Test
@TestMetadata("illegalParameters.kt")
public void testIllegalParameters() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/illegalParameters.kt");
}
@Test
@TestMetadata("incremental.kt")
public void testIncremental() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/incremental.kt");
}
@Test
@TestMetadata("inherited.kt")
public void testInherited() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/inherited.kt");
}
@Test
@TestMetadata("mpp.kt")
public void testMpp() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/mpp.kt");
}
@Test
@TestMetadata("nested.kt")
public void testNested() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/nested.kt");
}
@Test
@TestMetadata("returnTestResult.kt")
public void testReturnTestResult() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/returnTestResult.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/simple.kt");
}
}
@Nested
@TestMetadata("js/js.translator/testData/box/esModules/main")
@TestDataPath("$PROJECT_ROOT")
@@ -2616,6 +2616,70 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
}
}
@Nested
@TestMetadata("js/js.translator/testData/box/esModules/kotlin.test")
@TestDataPath("$PROJECT_ROOT")
public class Kotlin_test {
@Test
public void testAllFilesPresentInKotlin_test() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/kotlin.test"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
}
@Test
@TestMetadata("beforeAfter.kt")
public void testBeforeAfter() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/beforeAfter.kt");
}
@Test
@TestMetadata("ignore.kt")
public void testIgnore() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/ignore.kt");
}
@Test
@TestMetadata("illegalParameters.kt")
public void testIllegalParameters() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/illegalParameters.kt");
}
@Test
@TestMetadata("incremental.kt")
public void testIncremental() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/incremental.kt");
}
@Test
@TestMetadata("inherited.kt")
public void testInherited() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/inherited.kt");
}
@Test
@TestMetadata("mpp.kt")
public void testMpp() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/mpp.kt");
}
@Test
@TestMetadata("nested.kt")
public void testNested() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/nested.kt");
}
@Test
@TestMetadata("returnTestResult.kt")
public void testReturnTestResult() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/returnTestResult.kt");
}
@Test
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("js/js.translator/testData/box/esModules/kotlin.test/simple.kt");
}
}
@Nested
@TestMetadata("js/js.translator/testData/box/esModules/main")
@TestDataPath("$PROJECT_ROOT")