From b6a6b12f0f2f7ee2843b3c28e247b5fed47c4c1b Mon Sep 17 00:00:00 2001 From: Vladimir Sukharev Date: Fri, 1 Mar 2024 09:28:04 +0100 Subject: [PATCH] [K/N][Tests] Rename compileToExecutable to reflect its one-staged behavior ^KT-66014 --- .../AbstractNativeCInteropKT39120Test.kt | 5 ++--- .../konan/test/blackbox/CachesAutoBuildTest.kt | 2 +- .../konan/test/blackbox/CinteropPackagesTest.kt | 4 ++-- .../InfrastructureDumpedTestListingTest.kt | 4 ++-- .../test/blackbox/KT59030WorkaroundTest.kt | 7 ++----- .../konan/test/blackbox/KlibResolverTest.kt | 2 +- .../test/blackbox/NativeSimpleTestUtils.kt | 17 ++++++++--------- 7 files changed, 18 insertions(+), 23 deletions(-) diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/AbstractNativeCInteropKT39120Test.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/AbstractNativeCInteropKT39120Test.kt index 12de270a08c..a7d018c3fc2 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/AbstractNativeCInteropKT39120Test.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/AbstractNativeCInteropKT39120Test.kt @@ -54,9 +54,8 @@ abstract class AbstractNativeCInteropKT39120Test : AbstractNativeCInteropBaseTes val module = TestModule.Exclusive(DEFAULT_MODULE_NAME, emptySet(), emptySet(), emptySet()).apply { files += TestFile.createCommitted(ktFile, this) } - // KT-66014: TODO convert compileToExecutable() to TestCompilationFactory.testCasesToExecutable(), - // to respect possible `mode=TWO_STAGE_MULTI_MODULE`: factory would then add intermediate LibraryCompilation(kt->klib). - val compilationResult = compileToExecutable( + // KT-39120 is irrelevant to compiler backend, so executable can be compiled in the simplest way, without splitting to stages. + val compilationResult = compileToExecutableInOneStage( createTestCaseNoTestRun(module, TestCompilerArgs.EMPTY), klib1.asLibraryDependency(), klib2.asLibraryDependency() diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/CachesAutoBuildTest.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/CachesAutoBuildTest.kt index 67ef85881e7..f71c71cce81 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/CachesAutoBuildTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/CachesAutoBuildTest.kt @@ -102,7 +102,7 @@ class CachesAutoBuildTest : AbstractNativeSimpleTest() { vararg dependencies: KLIB ): File { autoCacheDir.mkdirs() - return compileToExecutable( + return compileToExecutableInOneStage( sourcesDir, tryPassSystemCacheDirectory = false, // With auto-cache mode, the compiler chooses the system cache directory itself. freeCompilerArgs = TestCompilerArgs( diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/CinteropPackagesTest.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/CinteropPackagesTest.kt index 6d8f7574379..ff96bc4ced0 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/CinteropPackagesTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/CinteropPackagesTest.kt @@ -78,9 +78,9 @@ class CInteropPackagesTest : AbstractNativeSimpleTest() { freeCompilerArgs = TestCompilerArgs.EMPTY ).assertSuccess().resultingArtifact - // KT-66014: TODO convert compileToExecutable() to TestCompilationFactory.testCasesToExecutable(), + // KT-66014: TODO convert compileToExecutableInOneStage() to TestCompilationFactory.testCasesToExecutable(), // to respect possible `mde=TWO_STAGE_MULTI_MODULE`: factory would then add intermediate LibraryCompilation(kt->klib). - compileToExecutable( + compileToExecutableInOneStage( generateTestCaseWithSingleFile( sourceFile = ktFile, testKind = TestKind.STANDALONE_NO_TR, diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/InfrastructureDumpedTestListingTest.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/InfrastructureDumpedTestListingTest.kt index 51f8101a9fe..e5e3a55964f 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/InfrastructureDumpedTestListingTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/InfrastructureDumpedTestListingTest.kt @@ -56,13 +56,13 @@ class InfrastructureDumpedTestListingTest : AbstractNativeSimpleTest() { if (fromSources) { // Compile test, NOT respecting possible `mode=TWO_STAGE_MULTI_MODULE`: don't add intermediate LibraryCompilation(kt->klib). // KT-66014: Extract this test from usual Native test run, and run it in scope of new test module - barTestCase to compileToExecutable(barTestCase, fooLibrary.asLibraryDependency()) + barTestCase to compileToExecutableInOneStage(barTestCase, fooLibrary.asLibraryDependency()) } else { val barCompilationResult: Success = compileToLibrary(barTestCase, fooLibrary.asLibraryDependency()) val barLibrary: KLIB = barCompilationResult.resultingArtifact val executableTestCase = generateTestCaseWithSingleModule(moduleDir = null) // No sources. - executableTestCase to compileToExecutable( + executableTestCase to compileToExecutableInOneStage( executableTestCase, fooLibrary.asLibraryDependency(), barLibrary.asIncludedLibraryDependency() diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/KT59030WorkaroundTest.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/KT59030WorkaroundTest.kt index f23959f0749..3edd11a2384 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/KT59030WorkaroundTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/KT59030WorkaroundTest.kt @@ -11,9 +11,6 @@ import kotlinx.metadata.KmClass import kotlinx.metadata.KmDeclarationContainer import kotlinx.metadata.klib.KlibModuleMetadata import kotlinx.metadata.klib.annotations -import org.jetbrains.kotlin.backend.common.serialization.* -import org.jetbrains.kotlin.backend.common.serialization.proto.* -import org.jetbrains.kotlin.backend.common.serialization.proto.IrDeclaration.DeclaratorCase.* import org.jetbrains.kotlin.konan.file.unzipTo import org.jetbrains.kotlin.konan.file.zipDirAs import org.jetbrains.kotlin.konan.test.blackbox.support.EnforcedHostTarget @@ -58,9 +55,9 @@ class KT59030WorkaroundTest : AbstractNativeSimpleTest() { ).assertSuccess().resultingArtifact spoilDeprecatedAnnotationsInLibrary(library) - // Compile test, NOT respecting possible `mode=TWO_STAGE_MULTI_MODULE`: don't add intermediate LibraryCompilation(kt->klib). + // For this test it's ok to compile executable in the simplest way, not respecting possible `mode=TWO_STAGE_MULTI_MODULE` // KT-66014: Extract this test from usual Native test run, and run it in scope of new test module - compileToExecutable( + compileToExecutableInOneStage( generateTestCaseWithSingleFile( sourceFile = File(MAIN_FILE_PATH), testKind = TestKind.STANDALONE_NO_TR, diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/KlibResolverTest.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/KlibResolverTest.kt index ac6607ab022..6c41c5dd21e 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/KlibResolverTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/KlibResolverTest.kt @@ -105,7 +105,7 @@ class KlibResolverTest : AbstractNativeSimpleTest() { // Compile test, NOT respecting possible `mode=TWO_STAGE_MULTI_MODULE`: don't add intermediate LibraryCompilation(kt->klib). // KT-66014: Extract this test from usual Native test run, and run it in scope of new test module val executableResult = - compileToExecutable(testCase, klibResult.resultingArtifact.asLibraryDependency()).assertSuccess() + compileToExecutableInOneStage(testCase, klibResult.resultingArtifact.asLibraryDependency()).assertSuccess() val testExecutable = TestExecutable( executableResult.resultingArtifact, executableResult.loggedData, diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/NativeSimpleTestUtils.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/NativeSimpleTestUtils.kt index d41e7f2f88a..d2f5135af94 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/NativeSimpleTestUtils.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/NativeSimpleTestUtils.kt @@ -94,7 +94,7 @@ internal class ExecutableBuilder( // WARNING: compiles in one-stage mode (sources->executable) even when `mode=TWO_STAGE_MULTI_MODULE` override fun build(sourcesDir: File, outputDir: File, dependencies: List) = - test.compileToExecutable( + test.compileToExecutableInOneStage( sourcesDir, tryPassSystemCacheDirectory, freeCompilerArgs = if (freeCompilerArgs.isEmpty()) TestCompilerArgs.EMPTY else TestCompilerArgs(freeCompilerArgs), @@ -164,30 +164,29 @@ internal class CompiledExecutable( } // WARNING: compiles in one-stage mode (sources->executable) even when `mode=TWO_STAGE_MULTI_MODULE` -internal fun AbstractNativeSimpleTest.compileToExecutable( +internal fun AbstractNativeSimpleTest.compileToExecutableInOneStage( sourcesDir: File, tryPassSystemCacheDirectory: Boolean, freeCompilerArgs: TestCompilerArgs, vararg dependencies: TestCompilationArtifact.KLIB -) = compileToExecutable(sourcesDir, tryPassSystemCacheDirectory, freeCompilerArgs, dependencies.asList()) +) = compileToExecutableInOneStage(sourcesDir, tryPassSystemCacheDirectory, freeCompilerArgs, dependencies.asList()) // WARNING: compiles in one-stage mode (sources->executable) even when `mode=TWO_STAGE_MULTI_MODULE` -internal fun AbstractNativeSimpleTest.compileToExecutable( +internal fun AbstractNativeSimpleTest.compileToExecutableInOneStage( sourcesDir: File, tryPassSystemCacheDirectory: Boolean, freeCompilerArgs: TestCompilerArgs, dependencies: List ): CompiledExecutable { val testCase: TestCase = generateTestCaseWithSingleModule(sourcesDir, freeCompilerArgs) - val compilationResult = compileToExecutable(testCase, tryPassSystemCacheDirectory, dependencies.map { it.asLibraryDependency() }) + val compilationResult = compileToExecutableInOneStage(testCase, tryPassSystemCacheDirectory, dependencies.map { it.asLibraryDependency() }) return CompiledExecutable(testCase, compilationResult.assertSuccess()) } // WARNING: compiles in one-stage mode (sources->executable) even when `mode=TWO_STAGE_MULTI_MODULE` -internal fun AbstractNativeSimpleTest.compileToExecutable(testCase: TestCase, vararg dependencies: TestCompilationDependency<*>) = - compileToExecutable(testCase, true, dependencies.asList()) +internal fun AbstractNativeSimpleTest.compileToExecutableInOneStage(testCase: TestCase, vararg dependencies: TestCompilationDependency<*>) = + compileToExecutableInOneStage(testCase, true, dependencies.asList()) -// WARNING: compiles in one-stage mode (sources->static cache) even when `mode=TWO_STAGE_MULTI_MODULE` internal fun AbstractNativeSimpleTest.compileToStaticCache( klib: TestCompilationArtifact.KLIB, cacheDir: File, @@ -317,7 +316,7 @@ private fun AbstractNativeSimpleTest.compileToLibrary( return compilation.result.assertSuccess() } -private fun AbstractNativeSimpleTest.compileToExecutable( +private fun AbstractNativeSimpleTest.compileToExecutableInOneStage( testCase: TestCase, tryPassSystemCacheDirectory: Boolean, dependencies: List>