!fixup [Gradle] refactor Gradle task assertion utils for clarity
- Rename/update to differentiate between 'executed' tasks vs tasks that are not in the task graph - de-duplicate assertTasksNotExecuted() / assertTasksAreNotInTaskGraph() they both did the same thing - re-use code for verifying all tasks have a specific outcome - add a more helpful failed assertion message if the task isn't found - rename 'tasks' to 'taskPaths' for clarity
This commit is contained in:
committed by
Space Team
parent
ad8341df9b
commit
1661957166
+3
-3
@@ -12,8 +12,8 @@ import kotlin.test.assertNotNull
|
|||||||
/**
|
/**
|
||||||
* Asserts given tasks are not present in the build task graph.
|
* Asserts given tasks are not present in the build task graph.
|
||||||
*
|
*
|
||||||
* (Note this is different from asserting tasks are not executed - Tasks with outcomes
|
* (Note: 'not in task graph' has a different meaning to 'not executed'.
|
||||||
* [TaskOutcome.SKIPPED] and [TaskOutcome.UP_TO_DATE] will be in the task graph, but
|
* Tasks with outcomes [TaskOutcome.SKIPPED] and [TaskOutcome.UP_TO_DATE] will be in the task graph, but
|
||||||
* are not considered 'executed').
|
* are not considered 'executed').
|
||||||
*/
|
*/
|
||||||
fun BuildResult.assertTasksAreNotInTaskGraph(vararg taskPaths: String) {
|
fun BuildResult.assertTasksAreNotInTaskGraph(vararg taskPaths: String) {
|
||||||
@@ -51,7 +51,7 @@ fun BuildResult.assertAnyTaskHasBeenExecuted(taskPaths: Set<String>) {
|
|||||||
taskOutcomes.values.any { it == TaskOutcome.SUCCESS }
|
taskOutcomes.values.any { it == TaskOutcome.SUCCESS }
|
||||||
) {
|
) {
|
||||||
printBuildOutput()
|
printBuildOutput()
|
||||||
"Expected at least one Task of ($taskPaths) had outcome 'SUCCESS', but none did. Actual: $taskOutcomes"
|
"Expected at least one Task of $taskPaths had outcome 'SUCCESS', but none did. Actual outcomes: $taskOutcomes"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user