[Test] Don't create separate .fir.txt file in BytecodeListingHandler if not necessary
This commit is contained in:
committed by
Space Team
parent
700a117476
commit
dff5799c58
-13
@@ -1,13 +0,0 @@
|
|||||||
@kotlin.Metadata
|
|
||||||
public final class AC {
|
|
||||||
// source: 'AC.kt'
|
|
||||||
private final field number: int
|
|
||||||
public method <init>(): void
|
|
||||||
public final @org.jetbrains.annotations.NotNull method getNumber(): java.lang.Number
|
|
||||||
}
|
|
||||||
|
|
||||||
@kotlin.Metadata
|
|
||||||
public interface AI {
|
|
||||||
// source: 'AI.kt'
|
|
||||||
public abstract @org.jetbrains.annotations.NotNull method getNumber(): java.lang.Number
|
|
||||||
}
|
|
||||||
+20
-10
@@ -44,19 +44,29 @@ class BytecodeListingHandler(testServices: TestServices) : JvmBinaryArtifactHand
|
|||||||
if (multiModuleInfoDumper.isEmpty()) return
|
if (multiModuleInfoDumper.isEmpty()) return
|
||||||
|
|
||||||
val sourceFile = testServices.moduleStructure.originalTestDataFiles.first()
|
val sourceFile = testServices.moduleStructure.originalTestDataFiles.first()
|
||||||
val extension =
|
val defaultTxtFile = sourceFile.withExtension(".txt")
|
||||||
if (testServices.defaultsProvider.defaultFrontend == FrontendKinds.FIR && FIR_IDENTICAL !in testServices.moduleStructure.allDirectives) ".fir.txt" else ".txt"
|
val irTxtFile = sourceFile.withSuffixAndExtension("_ir", ".txt")
|
||||||
val defaultTxtFile = sourceFile.withExtension(extension)
|
val firTxtFile = sourceFile.withExtension(".fir.txt")
|
||||||
|
|
||||||
|
val isFir = testServices.defaultsProvider.defaultFrontend == FrontendKinds.FIR
|
||||||
val isIr = testServices.defaultsProvider.defaultTargetBackend?.isIR == true
|
val isIr = testServices.defaultsProvider.defaultTargetBackend?.isIR == true
|
||||||
val txtFile =
|
|
||||||
if (isIr) sourceFile.withSuffixAndExtension("_ir", extension).takeIf(File::exists) ?: defaultTxtFile
|
|
||||||
else defaultTxtFile
|
|
||||||
|
|
||||||
assertions.assertEqualsToFile(txtFile, multiModuleInfoDumper.generateResultingDump())
|
val actualFile = when {
|
||||||
|
isFir -> firTxtFile.takeIf { it.exists() } ?: irTxtFile.takeIf { it.exists() } ?: defaultTxtFile
|
||||||
|
isIr -> irTxtFile.takeIf { it.exists() } ?: defaultTxtFile
|
||||||
|
else -> defaultTxtFile
|
||||||
|
}
|
||||||
|
|
||||||
if (isIr && txtFile != defaultTxtFile) {
|
val goldenFile = when {
|
||||||
if (txtFile.readText() == defaultTxtFile.readText()) assertions.fail {
|
isFir -> irTxtFile.takeIf { it.exists() } ?: defaultTxtFile
|
||||||
"JVM and JVM_IR golden files are identical. Remove $txtFile."
|
else -> defaultTxtFile
|
||||||
|
}
|
||||||
|
|
||||||
|
assertions.assertEqualsToFile(actualFile, multiModuleInfoDumper.generateResultingDump())
|
||||||
|
|
||||||
|
if (actualFile != goldenFile) {
|
||||||
|
if (actualFile.readText().trim() == goldenFile.readText().trim()) assertions.fail {
|
||||||
|
"JVM and JVM_IR golden files are identical. Remove $actualFile."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user