Minor: check output with errors in scratch tests

This commit is contained in:
Natalia Selezneva
2019-07-01 12:35:54 +03:00
parent 784cc17d21
commit 85f07927c9
2 changed files with 16 additions and 6 deletions
@@ -106,7 +106,7 @@ abstract class AbstractScratchRunActionTest : FileEditorManagerTestCase() {
fileName.replace(".kts", ".comp.after")
}
val expectedFile = File(testDataPath, expectedFileName)
KotlinTestUtils.assertEqualsToFile(expectedFile, actualOutput.toString())
KotlinTestUtils.assertEqualsToFile(expectedFile, actualOutput)
}
protected fun String.inlinePropertiesValues(
@@ -116,7 +116,7 @@ abstract class AbstractScratchRunActionTest : FileEditorManagerTestCase() {
return replace("~REPL_MODE~", isRepl.toString()).replace("~INTERACTIVE_MODE~", isInteractiveMode.toString())
}
private fun getFileTextWithInlays(): StringBuilder {
protected fun getFileTextWithInlays(): String {
val doc = myFixture.getDocument(myFixture.file) ?: error("Document for ${myFixture.file.name} is null")
val actualOutput = StringBuilder(myFixture.file.text)
for (line in doc.lineCount - 1 downTo 0) {
@@ -130,7 +130,7 @@ abstract class AbstractScratchRunActionTest : FileEditorManagerTestCase() {
)
}
}
return actualOutput
return actualOutput.toString().trim()
}
protected fun getInlays(start: Int = 0, end: Int = myFixture.file.textLength): List<InlayScratchFileRenderer> {
@@ -17,11 +17,21 @@ import org.junit.runner.RunWith
class CustomScratchRunActionTest : AbstractScratchRunActionTest() {
fun testLongCommandLineWithRepl() {
assertEquals("RESULT: res0: kotlin.Int = 1", getOutput(true))
assertEquals(
"""|// REPL_MODE: true
|// INTERACTIVE_MODE: false
|1 // RESULT: res0: kotlin.Int = 1""".trimMargin(),
getOutput(true)
)
}
fun testLongCommandLine() {
assertEquals("RESULT: 1", getOutput(false))
assertEquals(
"""|// REPL_MODE: false
|// INTERACTIVE_MODE: false
|1 // RESULT: 1""".trimMargin(),
getOutput(false)
)
}
private fun getOutput(isRepl: Boolean): String {
@@ -31,7 +41,7 @@ class CustomScratchRunActionTest : AbstractScratchRunActionTest() {
launchScratch()
waitUntilScratchFinishes()
return getInlays().joinToString().trim()
return getFileTextWithInlays()
}
private val library: Library by lazy {