[Test] Migrate IrTextTestGenerated to new infrastructure

This commit is contained in:
Dmitriy Novozhilov
2021-01-18 18:00:44 +03:00
committed by TeamCityServer
parent 5ae5f660f6
commit aaa3fa5845
14 changed files with 953 additions and 370 deletions
@@ -21,7 +21,13 @@ import javax.tools.ToolProvider
@JvmOverloads
@Throws(IOException::class)
fun compileJavaFiles(files: Collection<File>, options: List<String?>?, javaErrorFile: File? = null, assertions: Assertions): Boolean {
fun compileJavaFiles(
files: Collection<File>,
options: List<String?>?,
javaErrorFile: File? = null,
assertions: Assertions,
ignoreJavaErrors: Boolean = false
): Boolean {
val javaCompiler = ToolProvider.getSystemJavaCompiler()
val diagnosticCollector = DiagnosticCollector<JavaFileObject>()
javaCompiler.getStandardFileManager(diagnosticCollector, Locale.ENGLISH, Charset.forName("utf-8")).use { fileManager ->
@@ -36,7 +42,7 @@ fun compileJavaFiles(files: Collection<File>, options: List<String?>?, javaError
)
val success = task.call() // do NOT inline this variable, call() should complete before errorsToString()
if (javaErrorFile == null || !javaErrorFile.exists()) {
assertions.assertTrue(success) { errorsToString(diagnosticCollector, true) }
assertions.assertTrue(success || ignoreJavaErrors) { errorsToString(diagnosticCollector, true) }
} else {
assertions.assertEqualsToFile(javaErrorFile, errorsToString(diagnosticCollector, false))
}