improve layout of result line for FAILED results

This commit is contained in:
ansgarz 2022-03-22 20:13:10 +01:00
parent a00f0e9de0
commit 14690a089d
3 changed files with 7 additions and 7 deletions

View file

@ -418,7 +418,7 @@ internal data class ResultLine(val level: Int, val method: String?, var provResu
override fun toString(): String { override fun toString(): String {
val provResult = provResult val provResult = provResult
return if (provResult != null) { return if (provResult != null) {
prefix(level) + (if (provResult.success) "Success -- " else "FAILED -- ") + prefix(level) + (if (provResult.success) "Success -- " else "FAILED -- ") +
method + " " + (provResult.cmd ?: "") + method + " " + (provResult.cmd ?: "") +
(if (!provResult.success && provResult.err != null) " -- Error: " + provResult.err.escapeControlChars() else "") (if (!provResult.success && provResult.err != null) " -- Error: " + provResult.err.escapeControlChars() else "")
} else } else

View file

@ -4,11 +4,11 @@ package org.domaindrivenarchitecture.provs.framework.core
/** /**
* Repeats task until it returns success * Repeats task until it returns success
*/ */
fun Prov.repeatTaskUntilSuccess(times: Int, sleepInSec: Int, func: Prov.() -> ProvResult) = requireLast { fun Prov.repeatTaskUntilSuccess(times: Int, sleepInSec: Int, task: Prov.() -> ProvResult) = requireLast {
require(times > 0) require(times > 0)
var result = ProvResult(false, err = "Internal error") // Will only be returned if function is not executed at all, otherwise func's last result is returned var result = ProvResult(false, err = "Internal error") // Will only be returned if function is not executed at all, otherwise func's last result is returned
for (i in 1..times) { for (i in 1..times) {
result = func() result = task()
if (result.success) if (result.success)
return@requireLast result return@requireLast result
Thread.sleep(sleepInSec * 1000L) Thread.sleep(sleepInSec * 1000L)

View file

@ -305,7 +305,7 @@ internal class ProvTest {
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" +
"------> \u001B[92mSuccess\u001B[0m -- cmd [/bin/bash, -c, echo -Start test-]\n" + "------> \u001B[92mSuccess\u001B[0m -- cmd [/bin/bash, -c, echo -Start test-]\n" +
"------> \u001B[92mSuccess\u001B[0m -- cmd [/bin/bash, -c, echo Some output]\n" + "------> \u001B[92mSuccess\u001B[0m -- cmd [/bin/bash, -c, echo Some output]\n" +
@ -346,7 +346,7 @@ internal class ProvTest {
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"
@ -384,8 +384,8 @@ internal class ProvTest {
val expectedOutput = val expectedOutput =
"============================================== SUMMARY (test instance with no progress info) ============================================== \n" + "============================================== SUMMARY (test instance with no progress info) ============================================== \n" +
"> \u001B[92mSuccess\u001B[0m -- prov_prints_correct_output_for_failure_not_taken_into_account (requireLast) \n" + "> \u001B[92mSuccess\u001B[0m -- prov_prints_correct_output_for_failure_that_is_not_taken_into_account (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 -- returns success \n" + "---> \u001B[92mSuccess\u001B[0m -- returns success \n" +
"----------------------------------------------------------------------------------------------------- \n" + "----------------------------------------------------------------------------------------------------- \n" +
"Overall > \u001B[92mSuccess\u001B[0m\n" + "Overall > \u001B[92mSuccess\u001B[0m\n" +