[Native] External tests: Don't clean up test directives
This does not make sense anymore since external test data files are patched during test execution on the fly.
This commit is contained in:
+6
-21
@@ -121,20 +121,9 @@ private class ExtTestDataFile(
|
|||||||
) {
|
) {
|
||||||
private val structure by lazy {
|
private val structure by lazy {
|
||||||
structureFactory.ExtTestDataFileStructure(testDataFile) { line ->
|
structureFactory.ExtTestDataFileStructure(testDataFile) { line ->
|
||||||
if (DIRECTIVE_REGEX.matches(line)) {
|
// Remove all diagnostic parameters from the text. Examples:
|
||||||
// Remove all directives from test files. These directives are not needed anymore as they are already read and stored
|
// <!NO_TAIL_CALLS_FOUND!>, <!NON_TAIL_RECURSIVE_CALL!>, <!>.
|
||||||
// in [settings] property. Moreover, these directives if left in test file can potentially conflict with Native-specific
|
line.replace(DIAGNOSTIC_REGEX) { match -> match.groupValues[1] }
|
||||||
// test directives to be added (see [TestDirectives] for details). Also, they will create unnecessary "noise".
|
|
||||||
// Examples:
|
|
||||||
// // !LANGUAGE: +NewInference
|
|
||||||
// // LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
|
|
||||||
// // !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
|
||||||
null
|
|
||||||
} else {
|
|
||||||
// Remove all diagnostic parameters from the text. Examples:
|
|
||||||
// <!NO_TAIL_CALLS_FOUND!>, <!NON_TAIL_RECURSIVE_CALL!>, <!>.
|
|
||||||
line.replace(DIAGNOSTIC_REGEX) { match -> match.groupValues[1] }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -627,7 +616,6 @@ private class ExtTestDataFile(
|
|||||||
private fun Directives.multiValues(key: String, predicate: (String) -> Boolean = { true }): Set<String> =
|
private fun Directives.multiValues(key: String, predicate: (String) -> Boolean = { true }): Set<String> =
|
||||||
listValues(key)?.flatMap { it.split(' ') }?.filter(predicate)?.toSet().orEmpty()
|
listValues(key)?.flatMap { it.split(' ') }?.filter(predicate)?.toSet().orEmpty()
|
||||||
|
|
||||||
private val DIRECTIVE_REGEX = Regex("^// !?[A-Z_]+(:?\\s+.*|\\s*)$")
|
|
||||||
private val DIAGNOSTIC_REGEX = Regex("<!.*?!>(.*?)<!>")
|
private val DIAGNOSTIC_REGEX = Regex("<!.*?!>(.*?)<!>")
|
||||||
|
|
||||||
private const val THREAD_LOCAL_ANNOTATION = "@kotlin.native.ThreadLocal"
|
private const val THREAD_LOCAL_ANNOTATION = "@kotlin.native.ThreadLocal"
|
||||||
@@ -654,10 +642,7 @@ private typealias SharedModuleCache = (moduleName: String, generator: SharedModu
|
|||||||
private class ExtTestDataFileStructureFactory(parentDisposable: Disposable) : TestDisposable(parentDisposable) {
|
private class ExtTestDataFileStructureFactory(parentDisposable: Disposable) : TestDisposable(parentDisposable) {
|
||||||
private val psiFactory = createPsiFactory(parentDisposable = this)
|
private val psiFactory = createPsiFactory(parentDisposable = this)
|
||||||
|
|
||||||
inner class ExtTestDataFileStructure(
|
inner class ExtTestDataFileStructure(originalTestDataFile: File, initialCleanUpTransformation: (String) -> String) {
|
||||||
originalTestDataFile: File,
|
|
||||||
initialCleanUpTransformation: (String) -> String? // Line -> transformed line (or null if the line should be omitted).
|
|
||||||
) {
|
|
||||||
init {
|
init {
|
||||||
assertNotDisposed()
|
assertNotDisposed()
|
||||||
}
|
}
|
||||||
@@ -818,7 +803,7 @@ private class ExtTestDataFileStructureFactory(parentDisposable: Disposable) : Te
|
|||||||
ExtTestModule(name, dependencies, friends)
|
ExtTestModule(name, dependencies, friends)
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class FilesAndModules(originalTestDataFile: File, initialCleanUpTransformation: (String) -> String?) {
|
private inner class FilesAndModules(originalTestDataFile: File, initialCleanUpTransformation: (String) -> String) {
|
||||||
private val testFileFactory = ExtTestFileFactory()
|
private val testFileFactory = ExtTestFileFactory()
|
||||||
private val generatedFiles = TestFiles.createTestFiles(DEFAULT_FILE_NAME, originalTestDataFile.readText(), testFileFactory)
|
private val generatedFiles = TestFiles.createTestFiles(DEFAULT_FILE_NAME, originalTestDataFile.readText(), testFileFactory)
|
||||||
|
|
||||||
@@ -826,7 +811,7 @@ private class ExtTestDataFileStructureFactory(parentDisposable: Disposable) : Te
|
|||||||
// Clean up contents of every individual test file. Important: This should be done only after parsing testData file,
|
// Clean up contents of every individual test file. Important: This should be done only after parsing testData file,
|
||||||
// because parsing of testData file relies on certain directives which could be removed by the transformation.
|
// because parsing of testData file relies on certain directives which could be removed by the transformation.
|
||||||
generatedFiles.forEach { file ->
|
generatedFiles.forEach { file ->
|
||||||
file.text = file.text.lineSequence().mapNotNull(initialCleanUpTransformation).joinToString("\n")
|
file.text = file.text.lineSequence().joinToString("\n", transform = initialCleanUpTransformation)
|
||||||
}
|
}
|
||||||
|
|
||||||
val modules = generatedFiles.map { it.module }.associateBy { it.name }
|
val modules = generatedFiles.map { it.module }.associateBy { it.name }
|
||||||
|
|||||||
Reference in New Issue
Block a user