diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index 210226e4b4b..a7ad979658d 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -121,8 +121,16 @@ ext.konanNoRun = true final CacheTesting cacheTesting = CacheTestingKt.configureCacheTesting(project) if (cacheTesting != null) { - // Note: can't do this in [CacheTesting.configure] since task classes aren't accessible there. + // Check for debug build and set the -g option. + if (project.globalTestArgs.contains("-opt")) { + throw new IllegalArgumentException("Cache testing should be run with debug build. " + + "Remove -opt options from the test args") + } + if (!project.globalTestArgs.contains("-g")) { + project.globalTestArgs.add("-g") + } + // Note: can't do this in [CacheTesting.configure] since task classes aren't accessible there. tasks.withType(KonanCompileNativeBinary.class).configureEach { dependsOn cacheTesting.buildCacheTask extraOpts cacheTesting.compilerArgs