@@ -21,8 +21,11 @@ import org.jetbrains.kotlin.konan.target.CompilerOutputKind
2121import org.jetbrains.kotlin.konan.target.HostManager
2222import org.jetbrains.kotlin.konan.target.KonanTarget
2323import org.jetbrains.kotlin.konan.target.presetName
24- import org.junit.*
25- import org.junit.rules.TemporaryFolder
24+ import org.junit.Assume
25+ import org.junit.Ignore
26+ import org.junit.Rule
27+ import org.junit.Test
28+ import org.junit.rules.ErrorCollector
2629import java.io.File
2730import java.nio.file.Files
2831import java.util.*
@@ -1093,81 +1096,6 @@ class GeneralNativeIT : BaseGradleIT() {
10931096 }
10941097 }
10951098
1096- @Test
1097- fun `check offline mode is propagated to the compiler` () = with (
1098- transformNativeTestProjectWithPluginDsl(
1099- " executables" ,
1100- directoryPrefix = " native-binaries"
1101- )
1102- ) {
1103- val buildOptions = defaultBuildOptions()
1104-
1105- val linkTask = " :linkDebugExecutableHost"
1106- val compileTask = " :compileKotlinHost"
1107-
1108- build(linkTask, options = buildOptions) {
1109- assertSuccessful()
1110- }
1111-
1112- // Check that --offline works when all the dependencies are already downloaded:
1113- val buildOptionsOffline = buildOptions.copy(freeCommandLineArgs = buildOptions.freeCommandLineArgs + " --offline" )
1114-
1115- build(" clean" , linkTask, options = buildOptionsOffline) {
1116- assertSuccessful()
1117- withNativeCommandLineArguments(compileTask, linkTask) {
1118- assertTrue(it.contains(" -Xoverride-konan-properties=airplaneMode=true" ))
1119- }
1120- }
1121-
1122- // Check that --offline fails when there are no downloaded dependencies:
1123- val customKonanDataDir = tempDir.newFolder(" konanOffline" )
1124- val buildOptionsOfflineWithCustomKonanDataDir = buildOptionsOffline.copy(
1125- customEnvironmentVariables = buildOptionsOffline.customEnvironmentVariables +
1126- (" KONAN_DATA_DIR" to customKonanDataDir.absolutePath)
1127- )
1128-
1129- build(" clean" , linkTask, options = buildOptionsOfflineWithCustomKonanDataDir) {
1130- assertFailed()
1131- assertTasksNotExecuted(listOf (linkTask))
1132- }
1133-
1134- checkNoDependenciesDownloaded(customKonanDataDir)
1135-
1136- // Check that the compiler is not extracted if it is not cached:
1137- assertTrue(customKonanDataDir.deleteRecursively())
1138- build(
1139- " clean" , linkTask, " -Pkotlin.native.version=1.6.20-M1-9999" ,
1140- options = buildOptionsOfflineWithCustomKonanDataDir
1141- ) {
1142- assertFailed()
1143- assertTasksNotExecuted(listOf (linkTask, compileTask))
1144- }
1145-
1146- assertFalse(customKonanDataDir.exists())
1147- }
1148-
1149- private fun checkNoDependenciesDownloaded (customKonanDataDir : File ) {
1150- // Check that no files have actually been downloaded or extracted,
1151- // except for maybe the compiler itself, which can be extracted from the Gradle cache
1152- // (see NativeCompilerDownloader, it uses regular dependency resolution,
1153- // so supports --offline properly by default).
1154- val cacheDirName = " cache"
1155- val dependenciesDirName = " dependencies"
1156-
1157- fun assertDirectoryHasNothingButMaybe (directory : File , vararg names : String ) {
1158- assertEquals(emptyList(), directory.listFiles().orEmpty().map { it.name } - names)
1159- }
1160-
1161- assertDirectoryHasNothingButMaybe(File (customKonanDataDir, cacheDirName), " .lock" )
1162- assertDirectoryHasNothingButMaybe(File (customKonanDataDir, dependenciesDirName), " .extracted" )
1163-
1164- val customKonanDataDirFiles = customKonanDataDir.listFiles().orEmpty().map { it.name } - setOf (cacheDirName, dependenciesDirName)
1165- if (customKonanDataDirFiles.isNotEmpty()) {
1166- assertEquals(1 , customKonanDataDirFiles.size, message = customKonanDataDirFiles.toString())
1167- assertTrue(customKonanDataDirFiles.single().startsWith(" kotlin-native-" ), message = customKonanDataDirFiles.single())
1168- }
1169- }
1170-
11711099 @Test
11721100 fun allowToOverrideDownloadUrl () {
11731101 with (transformNativeTestProjectWithPluginDsl(" native-parallel" )) {
@@ -1263,15 +1191,5 @@ class GeneralNativeIT : BaseGradleIT() {
12631191 toolName : String = "konanc",
12641192 check : (Map <String , String >) -> Unit
12651193 ) = taskPaths.forEach { taskPath -> check(extractNativeCustomEnvironment(taskPath, toolName)) }
1266-
1267- @field:ClassRule
1268- @JvmField
1269- val tempDir = TemporaryFolder ()
1270-
1271- @JvmStatic
1272- @AfterClass
1273- fun deleteTempDir () {
1274- tempDir.delete()
1275- }
12761194 }
12771195}
0 commit comments