Use platform-independent line separator in jspecify tests handler

This commit is contained in:
Victor Petukhov
2021-05-01 09:43:48 +03:00
parent 2a2fa31577
commit 9eaec8d919
4 changed files with 5 additions and 5 deletions
@@ -30,7 +30,7 @@ class JspecifyDiagnosticComplianceHandler(testServices: TestServices) : ClassicF
val jspecifyMark = diagnosticsToJspecifyMarks.getValue(jspecifyMode)[metaInfo.diagnostic.factory] ?: continue
val fileLines = ktFile.text.lines()
val fileLinePositions =
fileLines.map { it.length }.runningReduce { sumLength, length -> sumLength + length + System.lineSeparator().length }
fileLines.map { it.length }.runningReduce { sumLength, length -> sumLength + length + 1 }
val lineIndexToPasteJspecifyMark = fileLinePositions.indexOfLast { it < metaInfo.start }
val positionToPasteJspecifyMark = fileLinePositions[lineIndexToPasteJspecifyMark]
val offset = fileLines[lineIndexToPasteJspecifyMark + 1].takeWhile { it == ' ' }.length
@@ -14,6 +14,6 @@ class JspecifyMarksCleanupPreprocessor(testServices: TestServices) : SourceFileP
companion object {
private val jspecifyMarks = diagnosticsToJspecifyMarks.values.map { it.values }.flatten().joinToString("|")
private val regexToCleanup = Regex("""[ ]*// ($jspecifyMarks)(, ($jspecifyMarks))*${System.lineSeparator()}""")
private val regexToCleanup = Regex("""[ ]*// ($jspecifyMarks)(, ($jspecifyMarks))*\n""")
}
}
@@ -87,8 +87,8 @@ abstract class AbstractForeignAnnotationsTestBase : AbstractKotlinCompilerTest()
}
forTestsMatching("compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/*") {
// useFrontendHandlers(::JspecifyDiagnosticComplianceHandler)
// useSourcePreprocessor(::JspecifyMarksCleanupPreprocessor)
useFrontendHandlers(::JspecifyDiagnosticComplianceHandler)
useSourcePreprocessor(::JspecifyMarksCleanupPreprocessor)
}
}
}
@@ -121,7 +121,7 @@ object MockLibraryUtil {
add("-d")
add(classesDir.path)
if (useJava9) {
if (useJava9 && extraModulepath.isNotEmpty()) {
add("--module-path")
add(extraModulepath.joinToString(File.pathSeparator))
}