add return value to result of subtask evaluation
This commit is contained in:
parent
29300d20ca
commit
94bb87ce0a
2 changed files with 44 additions and 6 deletions
|
@ -274,7 +274,7 @@ open class Prov protected constructor(
|
||||||
level++
|
level++
|
||||||
|
|
||||||
// call the actual function
|
// call the actual function
|
||||||
val res = if (!exit) {
|
val sublevelResult = if (!exit) {
|
||||||
progress(internalResult)
|
progress(internalResult)
|
||||||
@Suppress("UNUSED_EXPRESSION") // false positive
|
@Suppress("UNUSED_EXPRESSION") // false positive
|
||||||
a()
|
a()
|
||||||
|
@ -291,20 +291,20 @@ open class Prov protected constructor(
|
||||||
// for a leaf (task with mo subtask) or tasks "cmd" resp. "repeatUntilTrue" provide also out and err of original results
|
// for a leaf (task with mo subtask) or tasks "cmd" resp. "repeatUntilTrue" provide also out and err of original results
|
||||||
// because results of cmd and leafs are not included in the reporting
|
// because results of cmd and leafs are not included in the reporting
|
||||||
// and the caller of repeatUntilTrue might need to see the complete result (incl. out and err) and not only success value
|
// and the caller of repeatUntilTrue might need to see the complete result (incl. out and err) and not only success value
|
||||||
res.copy()
|
sublevelResult.copy()
|
||||||
} else {
|
} else {
|
||||||
// just pass success value, no other data of the original result
|
// just pass success value, no other data of the original result
|
||||||
ProvResult(res.success)
|
ProvResult(sublevelResult.success)
|
||||||
}
|
}
|
||||||
} else if (mode == ResultMode.ALL) {
|
} else if (mode == ResultMode.ALL) {
|
||||||
// leaf
|
// leaf
|
||||||
if (internalResultIsLeaf(resultIndex)) res.copy()
|
if (internalResultIsLeaf(resultIndex)) sublevelResult.copy()
|
||||||
// evaluate subcalls' results
|
// evaluate subcalls' results
|
||||||
else ProvResult(cumulativeSuccessSublevel(resultIndex) ?: false)
|
else ProvResult((cumulativeSuccessSublevel(resultIndex) ?: false) && sublevelResult.success)
|
||||||
} else if (mode == ResultMode.NONE) {
|
} else if (mode == ResultMode.NONE) {
|
||||||
ProvResult(true)
|
ProvResult(true)
|
||||||
} else if (mode == ResultMode.FAILEXIT) {
|
} else if (mode == ResultMode.FAILEXIT) {
|
||||||
return if (res.success) {
|
return if (sublevelResult.success) {
|
||||||
ProvResult(true)
|
ProvResult(true)
|
||||||
} else {
|
} else {
|
||||||
exit = true
|
exit = true
|
||||||
|
|
|
@ -406,6 +406,44 @@ internal class ProvTest {
|
||||||
assertEquals(ProvResult(true), res)
|
assertEquals(ProvResult(true), res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun task_with_subtask_and_failed_result_fails() {
|
||||||
|
// given
|
||||||
|
fun Prov.inner() {
|
||||||
|
addResultToEval(ProvResult(true))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Prov.outer() = task {
|
||||||
|
inner()
|
||||||
|
ProvResult(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
// when
|
||||||
|
val res = testLocal().outer()
|
||||||
|
|
||||||
|
//then
|
||||||
|
assertEquals(ProvResult(false), res)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun task_with_failing_subtask_and_successful_result_fails() {
|
||||||
|
// given
|
||||||
|
fun Prov.inner() = task {
|
||||||
|
ProvResult(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Prov.outer() = task {
|
||||||
|
inner()
|
||||||
|
ProvResult(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// when
|
||||||
|
val res = testLocal().outer()
|
||||||
|
|
||||||
|
//then
|
||||||
|
assertEquals(ProvResult(false), res)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun addResultToEval_failure() {
|
fun addResultToEval_failure() {
|
||||||
// given
|
// given
|
||||||
|
|
Loading…
Reference in a new issue