improve output layout for info texts

This commit is contained in:
ansgarz 2022-06-16 22:34:11 +02:00
parent f47a8a4986
commit bcd43a95be
2 changed files with 19 additions and 18 deletions

View file

@ -345,13 +345,14 @@ open class Prov protected constructor(
private val ANSI_BRIGHT_RED = "\u001B[91m" private val ANSI_BRIGHT_RED = "\u001B[91m"
private val ANSI_BRIGHT_YELLOW = "\u001B[93m" private val ANSI_BRIGHT_YELLOW = "\u001B[93m"
private val ANSI_BRIGHT_GREEN = "\u001B[92m" private val ANSI_BRIGHT_GREEN = "\u001B[92m"
private val ANSI_BRIGHT_BLUE = "\u001B[94m"
private val ANSI_GRAY = "\u001B[90m" private val ANSI_GRAY = "\u001B[90m"
private fun printResults() { private fun printResults() {
println( println(
"============================================== SUMMARY " + "============================================== SUMMARY " +
(if (instanceName != null) "(" + instanceName + ") " else "") + (if (instanceName != null) "(" + instanceName + ") " else "") +
"============================================== " "============================================="
) )
val successPerLevel = arrayListOf<Boolean>() val successPerLevel = arrayListOf<Boolean>()
for (result in internalResults) { for (result in internalResults) {
@ -370,11 +371,11 @@ open class Prov protected constructor(
println(result.toString().escapeControlChars().formattedAsResultLine(successOfLevelsAbove)) println(result.toString().escapeControlChars().formattedAsResultLine(successOfLevelsAbove))
} }
if (internalResults.size > 1) { if (internalResults.size > 1) {
println("----------------------------------------------------------------------------------------------------- ") println("----------------------------------------------------------------------------------------------------")
println("Overall " + internalResults[0].toString().take(10).formattedAsResultLine()) println("Overall " + internalResults[0].toString().take(10).formattedAsResultLine())
} }
printInfoTexts() printInfoTexts()
println("============================================ SUMMARY END ============================================ " + newline()) println("============================================ SUMMARY END ===========================================" + newline())
} }
private fun levelsAboveContainsSuccess(successPerLevel: ArrayList<Boolean>, currentLevel: Int): Boolean { private fun levelsAboveContainsSuccess(successPerLevel: ArrayList<Boolean>, currentLevel: Int): Boolean {
@ -423,7 +424,7 @@ open class Prov protected constructor(
private fun printInfoTexts() { private fun printInfoTexts() {
if (infoTexts.isNotEmpty()) { if (infoTexts.isNotEmpty()) {
println("----------------------------------------------------------------------------------------------------- ") println("+++++++++++++++++++++++++++++++++++ ${ANSI_BRIGHT_BLUE}Additional information$ANSI_RESET +++++++++++++++++++++++++++++++++++++++")
for (text in infoTexts) { for (text in infoTexts) {
println(text) println(text)
} }

View file

@ -301,7 +301,7 @@ internal class ProvTest {
println(outContent.toString()) println(outContent.toString())
val expectedOutput = val expectedOutput =
"============================================== SUMMARY (test instance with no progress info) ============================================== \n" + "============================================== SUMMARY (test instance with no progress info) =============================================\n" +
"> \u001B[92mSuccess\u001B[0m -- methodThatProvidesSomeOutput (requireLast) \n" + "> \u001B[92mSuccess\u001B[0m -- methodThatProvidesSomeOutput (requireLast) \n" +
"---> \u001B[93mFAILED\u001B[0m -- checkPrereq_evaluateToFailure (requireLast) -- Error: This is a test error.\n" + "---> \u001B[93mFAILED\u001B[0m -- checkPrereq_evaluateToFailure (requireLast) -- Error: This is a test error.\n" +
"---> \u001B[92mSuccess\u001B[0m -- sh \n" + "---> \u001B[92mSuccess\u001B[0m -- sh \n" +
@ -309,9 +309,9 @@ internal class ProvTest {
"------> \u001B[92mSuccess\u001B[0m -- cmd [/bin/bash, -c, echo Some output]\n" + "------> \u001B[92mSuccess\u001B[0m -- cmd [/bin/bash, -c, echo Some output]\n" +
"---> \u001B[92mSuccess\u001B[0m -- sh \n" + "---> \u001B[92mSuccess\u001B[0m -- sh \n" +
"------> \u001B[92mSuccess\u001B[0m -- cmd [/bin/bash, -c, echo -End test-]\n" + "------> \u001B[92mSuccess\u001B[0m -- cmd [/bin/bash, -c, echo -End test-]\n" +
"----------------------------------------------------------------------------------------------------- \n" + "----------------------------------------------------------------------------------------------------\n" +
"Overall > \u001B[92mSuccess\u001B[0m\n" + "Overall > \u001B[92mSuccess\u001B[0m\n" +
"============================================ SUMMARY END ============================================ \n" + "============================================ SUMMARY END ===========================================\n" +
"\n" "\n"
assertEquals(expectedOutput, outContent.toString().replace("\r", "")) assertEquals(expectedOutput, outContent.toString().replace("\r", ""))
@ -343,9 +343,9 @@ internal class ProvTest {
println(outContent.toString()) println(outContent.toString())
val expectedOutput = val expectedOutput =
"============================================== SUMMARY (test instance with no progress info) ============================================== \n" + "============================================== SUMMARY (test instance with no progress info) =============================================\n" +
"> \u001B[91mFAILED\u001B[0m -- checkPrereq_evaluateToFailure (requireLast) -- Error: This is a test error.\n" + "> \u001B[91mFAILED\u001B[0m -- checkPrereq_evaluateToFailure (requireLast) -- Error: This is a test error.\n" +
"============================================ SUMMARY END ============================================ \n" + "============================================ SUMMARY END ===========================================\n" +
"\n" "\n"
assertEquals(expectedOutput, outContent.toString().replace("\r", "")) assertEquals(expectedOutput, outContent.toString().replace("\r", ""))
@ -384,14 +384,14 @@ internal class ProvTest {
println(outContent.toString()) println(outContent.toString())
val expectedOutput = val expectedOutput =
"============================================== SUMMARY (test instance with no progress info) ============================================== \n" + "============================================== SUMMARY (test instance with no progress info) =============================================\n" +
"> \u001B[92mSuccess\u001B[0m -- taskA \n" + "> \u001B[92mSuccess\u001B[0m -- taskA \n" +
"---> \u001B[92mSuccess\u001B[0m -- prov_marks_failed_output_yellow_if_optional (optional) \n" + "---> \u001B[92mSuccess\u001B[0m -- prov_marks_failed_output_yellow_if_optional (optional) \n" +
"------> \u001B[93mFAILED\u001B[0m -- taskB \n" + "------> \u001B[93mFAILED\u001B[0m -- taskB \n" +
"---------> \u001B[93mFAILED\u001B[0m -- taskC \n" + "---------> \u001B[93mFAILED\u001B[0m -- taskC \n" +
"----------------------------------------------------------------------------------------------------- \n" + "----------------------------------------------------------------------------------------------------\n" +
"Overall > \u001B[92mSuccess\u001B[0m\n" + "Overall > \u001B[92mSuccess\u001B[0m\n" +
"============================================ SUMMARY END ============================================ \n" + "============================================ SUMMARY END ===========================================\n" +
"\n" "\n"
assertEquals(expectedOutput, outContent.toString().replace("\r", "")) assertEquals(expectedOutput, outContent.toString().replace("\r", ""))
@ -454,12 +454,12 @@ internal class ProvTest {
println(outContent.toString()) println(outContent.toString())
val expectedOutput = val expectedOutput =
"============================================== SUMMARY (test instance) ============================================== \n" + "============================================== SUMMARY (test instance) =============================================\n" +
"> \u001B[92mSuccess\u001B[0m -- TaskB \n" + "> \u001B[92mSuccess\u001B[0m -- TaskB \n" +
"---> \u001B[92mSuccess\u001B[0m -- taskC \n" + "---> \u001B[92mSuccess\u001B[0m -- taskC \n" +
"----------------------------------------------------------------------------------------------------- \n" + "----------------------------------------------------------------------------------------------------\n" +
"Overall > \u001B[92mSuccess\u001B[0m\n" + "Overall > \u001B[92mSuccess\u001B[0m\n" +
"============================================ SUMMARY END ============================================ \n" + "============================================ SUMMARY END ===========================================\n" +
"\n" "\n"
assertEquals(expectedOutput, outContent.toString().replace("\r", "")) assertEquals(expectedOutput, outContent.toString().replace("\r", ""))
@ -618,13 +618,13 @@ internal class ProvTest {
println(outContent.toString()) println(outContent.toString())
val expectedOutput = val expectedOutput =
"============================================== SUMMARY (test instance with no progress info) ============================================== \n" + "============================================== SUMMARY (test instance with no progress info) =============================================\n" +
"> \u001B[92mSuccess\u001B[0m -- infoText_is_printed_correctly \n" + "> \u001B[92mSuccess\u001B[0m -- infoText_is_printed_correctly \n" +
"----------------------------------------------------------------------------------------------------- \n" + "+++++++++++++++++++++++++++++++++++ \u001B[94mAdditional information\u001B[0m +++++++++++++++++++++++++++++++++++++++\n" +
"Text1\n" + "Text1\n" +
"Text2\n" + "Text2\n" +
"with newline\n" + "with newline\n" +
"============================================ SUMMARY END ============================================ \n" + "============================================ SUMMARY END ===========================================\n" +
"\n" "\n"
assertEquals(expectedOutput, outContent.toString().replace("\r", "")) assertEquals(expectedOutput, outContent.toString().replace("\r", ""))