From e7c4121e6785d1ac4cd7633066b4662ea3a23248 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 16 Dec 2020 11:17:01 +0300 Subject: [PATCH] [TEST] Add muting tests with .fail file for js box tests --- .../jetbrains/kotlin/js/test/BasicBoxTest.kt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt index 8360f5f456e..82c87d9937a 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt @@ -11,6 +11,7 @@ import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.vfs.StandardFileSystems import com.intellij.openapi.vfs.VirtualFileManager import com.intellij.psi.PsiManager +import com.intellij.testFramework.assertEqualsToFile import junit.framework.TestCase import org.jetbrains.kotlin.checkers.CompilerTestLanguageVersionSettings import org.jetbrains.kotlin.checkers.parseLanguageVersionSettings @@ -97,11 +98,24 @@ abstract class BasicBoxTest( protected open val testChecker get() = if (runTestInNashorn) NashornJsTestChecker else V8JsTestChecker fun doTest(filePath: String) { - doTest(filePath, "OK", MainCallParameters.noCall()) + doTestWithIgnoringByFailFile(filePath, coroutinesPackage = "") } fun doTestWithCoroutinesPackageReplacement(filePath: String, coroutinesPackage: String) { - doTest(filePath, "OK", MainCallParameters.noCall(), coroutinesPackage) + doTestWithIgnoringByFailFile(filePath, coroutinesPackage) + } + + fun doTestWithIgnoringByFailFile(filePath: String, coroutinesPackage: String) { + val failFile = File("$filePath.fail") + try { + doTest(filePath, "OK", MainCallParameters.noCall(), coroutinesPackage) + } catch (e: Throwable) { + if (failFile.exists()) { + KotlinTestUtils.assertEqualsToFile(failFile, e.message ?: "") + } else { + throw e + } + } } open fun doTest(filePath: String, expectedResult: String, mainCallParameters: MainCallParameters, coroutinesPackage: String = "") {