[Test] Fix FileNotFoundException in removeDirectiveFromFile
This happened when a FIR test didn't have a .fir.kt file.
This commit is contained in:
committed by
Space Team
parent
59c61cdd07
commit
cfc5bb74ef
@@ -27,6 +27,8 @@ fun File.isDirectiveDefined(directive: String): Boolean = this.useLines { line -
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun File.removeDirectiveFromFile(directive: Directive) {
|
fun File.removeDirectiveFromFile(directive: Directive) {
|
||||||
|
if (!exists()) return
|
||||||
|
|
||||||
val directiveName = directive.name
|
val directiveName = directive.name
|
||||||
val directiveRegexp = "^// $directiveName(:.*)?$(\n)?".toRegex(RegexOption.MULTILINE)
|
val directiveRegexp = "^// $directiveName(:.*)?$(\n)?".toRegex(RegexOption.MULTILINE)
|
||||||
val text = readText()
|
val text = readText()
|
||||||
@@ -34,4 +36,4 @@ fun File.removeDirectiveFromFile(directive: Directive) {
|
|||||||
?: error("Directive $directiveName was not found in $this")
|
?: error("Directive $directiveName was not found in $this")
|
||||||
val textWithoutDirective = text.removeRange(directiveRange)
|
val textWithoutDirective = text.removeRange(directiveRange)
|
||||||
writeText(textWithoutDirective)
|
writeText(textWithoutDirective)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user