|
|
@ -65,6 +65,14 @@ open class Prov protected constructor(
|
|
|
|
private var runInContainerWithName: String? = null
|
|
|
|
private var runInContainerWithName: String? = null
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Defines a task with a custom name instead of the name of the calling function.
|
|
|
|
|
|
|
|
* Returns success if all subtasks finished with success (same as requireAll).
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
fun task(name: String? = null, a: Prov.() -> ProvResult): ProvResult {
|
|
|
|
|
|
|
|
return handle(ResultMode.ALL, name) { a() }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* defines a task with default success behavior, i.e. returns success if all subtasks finished with success.
|
|
|
|
* defines a task with default success behavior, i.e. returns success if all subtasks finished with success.
|
|
|
|
* Same as requireAll.
|
|
|
|
* Same as requireAll.
|
|
|
@ -243,7 +251,7 @@ open class Prov protected constructor(
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Provides result handling, e.g. gather results for result summary
|
|
|
|
* Provides result handling, e.g. gather results for result summary
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private fun handle(mode: ResultMode, a: Prov.() -> ProvResult): ProvResult {
|
|
|
|
private fun handle(mode: ResultMode, name: String? = null, a: Prov.() -> ProvResult): ProvResult {
|
|
|
|
|
|
|
|
|
|
|
|
// init
|
|
|
|
// init
|
|
|
|
if (level == 0) {
|
|
|
|
if (level == 0) {
|
|
|
@ -255,8 +263,8 @@ open class Prov protected constructor(
|
|
|
|
|
|
|
|
|
|
|
|
// pre-handling
|
|
|
|
// pre-handling
|
|
|
|
val resultIndex = internalResults.size
|
|
|
|
val resultIndex = internalResults.size
|
|
|
|
val method = getCallingMethodName()
|
|
|
|
val taskName = name ?: getCallingMethodName()
|
|
|
|
val internalResult = ResultLine(level, method, null)
|
|
|
|
val internalResult = ResultLine(level, taskName, null)
|
|
|
|
internalResults.add(internalResult)
|
|
|
|
internalResults.add(internalResult)
|
|
|
|
|
|
|
|
|
|
|
|
previousLevel = level
|
|
|
|
previousLevel = level
|
|
|
@ -277,7 +285,7 @@ open class Prov protected constructor(
|
|
|
|
// post-handling
|
|
|
|
// post-handling
|
|
|
|
val returnValue =
|
|
|
|
val returnValue =
|
|
|
|
if (mode == ResultMode.LAST) {
|
|
|
|
if (mode == ResultMode.LAST) {
|
|
|
|
if (internalResultIsLeaf(resultIndex) || method == "cmd")
|
|
|
|
if (internalResultIsLeaf(resultIndex) || taskName == "cmd")
|
|
|
|
res.copy() else ProvResult(res.success)
|
|
|
|
res.copy() else ProvResult(res.success)
|
|
|
|
} else if (mode == ResultMode.ALL) {
|
|
|
|
} else if (mode == ResultMode.ALL) {
|
|
|
|
// leaf
|
|
|
|
// leaf
|
|
|
|