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

@ -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

@ -384,7 +384,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 -- 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" +