Skip to content

Commit

Permalink
[Test] Don't infer target platform from module name
Browse files Browse the repository at this point in the history
For compiler tests, the target platform is a property of the test itself,
not the particular module in the test
  • Loading branch information
demiurg906 authored and Space Cloud committed Jan 8, 2025
1 parent 4da2d50 commit c86a7d4
Showing 1 changed file with 1 addition and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class ModuleStructureExtractorImpl(
val moduleName = currentModuleName
?: testServices.defaultDirectives[ModuleStructureDirectives.MODULE].firstOrNull()
?: DEFAULT_MODULE_NAME
val targetPlatform = currentModuleTargetPlatform ?: parseModulePlatformByName(moduleName) ?: defaultsProvider.defaultPlatform
val targetPlatform = currentModuleTargetPlatform ?: defaultsProvider.defaultPlatform
val testModule = TestModule(
name = moduleName,
targetPlatform = targetPlatform,
Expand All @@ -360,19 +360,6 @@ class ModuleStructureExtractorImpl(
resetModuleCaches()
}

private fun parseModulePlatformByName(moduleName: String): TargetPlatform? {
val nameSuffix = moduleName.substringAfterLast("-", "").uppercase()
return when {
nameSuffix == "COMMON" -> CommonPlatforms.defaultCommonPlatform
nameSuffix == "JVM" -> JvmPlatforms.unspecifiedJvmPlatform // TODO(dsavvinov): determine JvmTarget precisely
nameSuffix == "JS" -> JsPlatforms.defaultJsPlatform
nameSuffix == "WASM" -> WasmPlatforms.wasmJs
nameSuffix == "NATIVE" -> NativePlatforms.unspecifiedNativePlatform
nameSuffix.isEmpty() -> null // TODO(dsavvinov): this leads to 'null'-platform in ModuleDescriptor
else -> throw IllegalStateException("Can't determine platform by name $nameSuffix")
}
}

private fun finishFile(lineNumber: Int) {
val actualDefaultFileName = if (currentModuleName == null) {
defaultFileName
Expand Down

0 comments on commit c86a7d4

Please sign in to comment.