mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Fix the task ordering bug.
This commit is contained in:
parent
699d9e99e7
commit
e99c277700
2 changed files with 20 additions and 0 deletions
|
@ -200,6 +200,16 @@ class TaskManager @Inject constructor(val args: Args,
|
|||
val seen = HashSet(allTaskInfos)
|
||||
val newTasks = hashSetOf<TaskInfo>()
|
||||
|
||||
// If at least two tasks were given, preserve the ordering by making each task depend on the
|
||||
// previous one, e.g. for "task1 task2 task3", add the edges "task2 -> task1" and "task3 -> task2"
|
||||
if (taskNames.size >= 2) {
|
||||
projects.forEach { project ->
|
||||
taskNames.zip(taskNames.subList(1, taskNames.size)).forEach { pair ->
|
||||
addEdge(TaskInfo(project.name, pair.second), TaskInfo(project.name, pair.first))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun maybeAdd(taskInfo: TaskInfo) {
|
||||
if (!seen.contains(taskInfo)) {
|
||||
newTasks.add(taskInfo)
|
||||
|
|
|
@ -101,4 +101,14 @@ class BuildOrderTest @Inject constructor(val taskManager: TaskManager) {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun shouldBuildInRightOrder3() {
|
||||
val p1 = project { name = "p1" }
|
||||
val expectedTasks = listOf("p1:run", "p1:exec")
|
||||
with(taskManager) {
|
||||
with(calculateDependentTaskNames(listOf("run", "exec"), listOf(p1))) {
|
||||
assertThat(this.map { it.id }).isEqualTo(expectedTasks)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue