[Test] Enable reporting errors from fronted to testdata of codegen tests

This commit is contained in:
Dmitriy Novozhilov
2021-05-14 15:48:34 +03:00
committed by TeamCityServer
parent df60e7368a
commit 47e258ef6e
28 changed files with 116 additions and 23 deletions
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
open class A {
open fun foo(s: String = "OK") = s
@@ -16,4 +17,4 @@ class B : A() {
}
}
fun box() = B().foo("FAIL")
fun box() = B().foo("FAIL")
@@ -1,5 +1,6 @@
// !LANGUAGE: -ProperComputationOrderOfTailrecDefaultParameters
// TARGET_BACKEND: JVM
// IGNORE_FIR_DIAGNOSTICS_DIFF
var counter = 0
fun calc(counter: Int) = if (counter % 2 == 0) "K" else "O"
@@ -13,4 +14,4 @@ fun calc(counter: Int) = if (counter % 2 == 0) "K" else "O"
fun box(): String {
return test(0)
}
}
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
<!NO_TAIL_CALLS_FOUND!>tailrec fun noTails()<!> {
// nothing here
@@ -13,4 +14,4 @@
fun box(): String {
noTails()
return "OK"
}
}
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
tailrec fun badTails(x : Int) : Int {
if (x < 50 && x != 10 && x > 0) {
@@ -22,4 +23,4 @@ tailrec fun badTails(x : Int) : Int {
fun box(): String {
badTails(1000000)
return "OK"
}
}
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
tailrec fun test(counter : Int) : Int? {
if (counter < 0) return null
@@ -15,4 +16,4 @@ tailrec fun test(counter : Int) : Int? {
fun box() : String =
if (test(100000) == 777) "OK"
else "FAIL"
else "FAIL"
@@ -7,6 +7,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
class B {
inner class C {
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
tailrec fun test(x : Int) : Int {
var z = if (x > 3) 3 else x
@@ -19,4 +20,4 @@ tailrec fun test(x : Int) : Int {
return 1
}
fun box() : String = if (test(100000) == 1) "OK" else "FAIL"
fun box() : String = if (test(100000) == 1) "OK" else "FAIL"
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
tailrec fun test(x : Int) : Int {
if (x == 1) {
@@ -20,4 +21,4 @@ tailrec fun test(x : Int) : Int {
return -1
}
fun box() : String = if (test(1000000) == -1) "OK" else "FAIL"
fun box() : String = if (test(1000000) == -1) "OK" else "FAIL"
@@ -7,6 +7,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
<!NO_TAIL_CALLS_FOUND!>tailrec fun foo()<!> {
bar {
@@ -19,4 +20,4 @@ fun bar(a: Any) {}
fun box(): String {
foo()
return "OK"
}
}
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
<!NO_TAIL_CALLS_FOUND!>tailrec fun foo()<!> {
fun bar() {
@@ -15,4 +16,4 @@
fun box(): String {
foo()
return "OK"
}
}
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
tailrec fun test(x : Int) : Int {
return if (x == 1) {
@@ -17,4 +18,4 @@ tailrec fun test(x : Int) : Int {
}
}
fun box() : String = if (test(1000000) == 1) "OK" else "FAIL"
fun box() : String = if (test(1000000) == 1) "OK" else "FAIL"
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
<!NO_TAIL_CALLS_FOUND!>tailrec fun test(counter : Int) : Int<!> {
if (counter == 0) return 0
@@ -16,4 +17,4 @@
}
}
fun box() : String = if (test(3) == 0) "OK" else "FAIL"
fun box() : String = if (test(3) == 0) "OK" else "FAIL"
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
<!NO_TAIL_CALLS_FOUND!>tailrec fun test(counter : Int) : Int<!> {
if (counter == 0) return 0
@@ -16,4 +17,4 @@
}
}
fun box() : String = if (test(3) == 0) "OK" else "FAIL"
fun box() : String = if (test(3) == 0) "OK" else "FAIL"
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
<!NO_TAIL_CALLS_FOUND!>tailrec fun test(counter : Int) : Int<!> {
if (counter == 0) return 0
@@ -20,4 +21,4 @@
return -1
}
fun box() : String = if (test(3) == 0) "OK" else "FAIL"
fun box() : String = if (test(3) == 0) "OK" else "FAIL"
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
<!NO_TAIL_CALLS_FOUND!>tailrec fun test(counter : Int) : Int<!> {
if (counter == 0) return 0
@@ -16,4 +17,4 @@
}
}
fun box() : String = if (test(3) == 0) "OK" else "FAIL"
fun box() : String = if (test(3) == 0) "OK" else "FAIL"
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
tailrec fun test(x : Int) : Int =
if (x == 1) {
@@ -16,4 +17,4 @@ tailrec fun test(x : Int) : Int =
0
}
fun box() : String = if (test(1000000) == 1) "OK" else "FAIL"
fun box() : String = if (test(1000000) == 1) "OK" else "FAIL"
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
tailrec fun test(x : Int) : Int {
if (x == 10) {
@@ -16,4 +17,4 @@ tailrec fun test(x : Int) : Int {
return 0
}
fun box() : String = if (test(1000000) == 1) "OK" else "FAIL"
fun box() : String = if (test(1000000) == 1) "OK" else "FAIL"
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
tailrec fun test(x : Int) : Int {
if (x == 0) {
@@ -17,4 +18,4 @@ tailrec fun test(x : Int) : Int {
}
}
fun box() : String = if (test(1000000) == 1) "OK" else "FAIL"
fun box() : String = if (test(1000000) == 1) "OK" else "FAIL"
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
<!NO_TAIL_CALLS_FOUND!>tailrec fun test(go: Boolean) : Unit<!> {
if (!go) return
@@ -20,4 +21,4 @@
fun box(): String {
test(true)
return "OK"
}
}
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
class A {
tailrec fun f1(c : Int) {
@@ -28,4 +29,4 @@ fun box() : String {
A().f1(1000000)
A().f2(1000000)
return "OK"
}
}
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
tailrec fun test(x : Int) : Unit {
if (x == 1) {
@@ -26,4 +27,4 @@ tailrec fun test(x : Int) : Unit {
fun box() : String {
test(1000000)
return "OK"
}
}
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
tailrec fun withWhen(counter : Int) : Int =
when (counter) {
@@ -13,4 +14,4 @@ tailrec fun withWhen(counter : Int) : Int =
else -> withWhen(counter - 1)
}
fun box() : String = if (withWhen(100000) == 1) "OK" else "FAIL"
fun box() : String = if (withWhen(100000) == 1) "OK" else "FAIL"
@@ -7,6 +7,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
tailrec fun withWhen(counter : Int, d : Any) : Int =
when (counter) {
@@ -18,4 +19,4 @@ tailrec fun withWhen(counter : Int, d : Any) : Int =
else -> withWhen(counter - 1, "else")
}
fun box() : String = if (withWhen(100000, "test") == 1) "OK" else "FAIL"
fun box() : String = if (withWhen(100000, "test") == 1) "OK" else "FAIL"
@@ -5,6 +5,7 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
// IGNORE_FIR_DIAGNOSTICS_DIFF
tailrec fun withWhen2(counter : Int) : Int =
when {
@@ -14,4 +15,4 @@ tailrec fun withWhen2(counter : Int) : Int =
else -> 1
}
fun box() : String = if (withWhen2(100000) == 1) "OK" else "FAIL"
fun box() : String = if (withWhen2(100000) == 1) "OK" else "FAIL"
@@ -91,6 +91,10 @@ object CodegenTestDirectives : SimpleDirectivesContainer() {
description = "Run backend even FIR reported some diagnostics with ERROR severity"
)
val IGNORE_FIR_DIAGNOSTICS_DIFF by directive(
description = "Don't compare diagnostics in testdata for FIR codegen tests"
)
val DUMP_IR by directive(
description = "Dumps generated backend IR (enables ${IrTextDumpHandler::class})"
)
@@ -0,0 +1,36 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.test.frontend.fir
import org.jetbrains.kotlin.test.WrappedException
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.IGNORE_FIR_DIAGNOSTICS
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.IGNORE_FIR_DIAGNOSTICS_DIFF
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
import org.jetbrains.kotlin.test.model.AfterAnalysisChecker
import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.moduleStructure
class FirMetaInfoDiffSuppressor(testServices: TestServices) : AfterAnalysisChecker(testServices) {
override val directives: List<DirectivesContainer>
get() = listOf(CodegenTestDirectives)
override fun suppressIfNeeded(failedAssertions: List<WrappedException>): List<WrappedException> {
val ignoreErrors = testServices.moduleStructure.modules.any { IGNORE_FIR_DIAGNOSTICS in it.directives }
val ignoreDiff = testServices.moduleStructure.modules.any { IGNORE_FIR_DIAGNOSTICS_DIFF in it.directives }
if (!(ignoreErrors || ignoreDiff)) {
return failedAssertions
}
val filteredAssertions = failedAssertions.filterNot { it is WrappedException.FromMetaInfoHandler }
return if (failedAssertions.size == filteredAssertions.size && ignoreDiff) {
failedAssertions + AssertionError(
"Test contains $IGNORE_FIR_DIAGNOSTICS_DIFF directive but no errors was reported. Please remove directive"
).wrap()
} else {
filteredAssertions
}
}
}
@@ -9,9 +9,11 @@ import org.jetbrains.kotlin.test.Constructor
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.backend.ir.JvmIrBackendFacade
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.IGNORE_FIR_DIAGNOSTICS_DIFF
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.USE_PSI_CLASS_FILES_READING
import org.jetbrains.kotlin.test.frontend.fir.Fir2IrResultsConverter
import org.jetbrains.kotlin.test.frontend.fir.FirFrontendFacade
import org.jetbrains.kotlin.test.frontend.fir.FirMetaInfoDiffSuppressor
import org.jetbrains.kotlin.test.frontend.fir.FirOutputArtifact
import org.jetbrains.kotlin.test.frontend.fir.handlers.FirCfgDumpHandler
import org.jetbrains.kotlin.test.frontend.fir.handlers.FirDumpHandler
@@ -45,6 +47,11 @@ open class AbstractFirBlackBoxCodegenTest : AbstractJvmBlackBoxCodegenTestBase<F
::FirCfgDumpHandler,
::FirNoImplicitTypesHandler,
)
useAfterAnalysisCheckers(
::FirMetaInfoDiffSuppressor
)
dumpHandlersForCodegenTest()
}
}
@@ -12,7 +12,12 @@ import org.jetbrains.kotlin.test.backend.handlers.BytecodeListingHandler
import org.jetbrains.kotlin.test.backend.handlers.BytecodeTextHandler
import org.jetbrains.kotlin.test.bind
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.directives.DiagnosticsDirectives.DIAGNOSTICS
import org.jetbrains.kotlin.test.directives.DiagnosticsDirectives.REPORT_ONLY_EXPLICITLY_DEFINED_DEBUG_INFO
import org.jetbrains.kotlin.test.frontend.classic.handlers.ClassicDiagnosticsHandler
import org.jetbrains.kotlin.test.frontend.fir.handlers.FirDiagnosticsHandler
import org.jetbrains.kotlin.test.model.*
import org.jetbrains.kotlin.test.runners.AbstractDiagnosticTest.Companion.DISABLED_BY_DEFAULT_UNUSED_DIAGNOSTICS
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerWithTargetBackendTest
abstract class AbstractJvmBlackBoxCodegenTestBase<R : ResultingArtifact.FrontendOutput<R>>(
@@ -25,9 +30,26 @@ abstract class AbstractJvmBlackBoxCodegenTestBase<R : ResultingArtifact.Frontend
override fun TestConfigurationBuilder.configuration() {
commonConfigurationForCodegenTest(targetFrontend, frontendFacade, frontendToBackendConverter, backendFacade)
useFrontendHandlers(
::ClassicDiagnosticsHandler,
::FirDiagnosticsHandler
)
commonHandlersForBoxTest()
useArtifactsHandlers(::BytecodeListingHandler)
useArtifactsHandlers(::BytecodeTextHandler.bind(true))
useAfterAnalysisCheckers(::BlackBoxCodegenSuppressor)
defaultDirectives {
+REPORT_ONLY_EXPLICITLY_DEFINED_DEBUG_INFO
}
forTestsNotMatching("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/*") {
defaultDirectives {
DIAGNOSTICS with "-warnings"
}
}
enableMetaInfoHandler()
}
}