mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Fix task ordering bug.
Fixes https://github.com/cbeust/kobalt/issues/276
This commit is contained in:
parent
1ec704e297
commit
4a1fbf2f9c
2 changed files with 22 additions and 4 deletions
|
@ -274,6 +274,17 @@ class TaskManager @Inject constructor(val args: Args,
|
|||
val newToProcess = arrayListOf<T>()
|
||||
val seen = hashSetOf<String>()
|
||||
|
||||
|
||||
// Make each task depend on the previous one, so that command line tasks are executed in the
|
||||
// order the user specified them
|
||||
passedTasks.zip(passedTasks.drop(1)).forEach { pair ->
|
||||
nodeMap[pair.first.taskName].forEach { first ->
|
||||
nodeMap[pair.second.taskName].forEach { second ->
|
||||
result.addEdge(second, first)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Reverse the always map so that tasks can be looked up.
|
||||
//
|
||||
|
|
|
@ -101,12 +101,19 @@ class BuildOrderTest @Inject constructor(val taskManager: TaskManager) {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldBuildInRightOrder3() {
|
||||
@DataProvider
|
||||
fun tasks3(): Array<Array<out Any>> {
|
||||
return arrayOf(
|
||||
arrayOf(listOf("exec", "run"), listOf("p1:exec", "p1:run")),
|
||||
arrayOf(listOf("run", "exec"), listOf("p1:run", "p1:exec"))
|
||||
)
|
||||
}
|
||||
|
||||
@Test(dataProvider = "tasks3")
|
||||
fun shouldBuildInRightOrder3(tasks: List<String>, expectedTasks: List<String>) {
|
||||
val p1 = project { name = "p1" }
|
||||
val expectedTasks = listOf("p1:run", "p1:exec")
|
||||
with(taskManager) {
|
||||
with(calculateDependentTaskNames(listOf("run", "exec"), listOf(p1))) {
|
||||
with(calculateDependentTaskNames(tasks, listOf(p1))) {
|
||||
assertThat(this.map { it.id }).isEqualTo(expectedTasks)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue