From f745ed4ee35c6d718c6d208eb8bea2ebe34c3601 Mon Sep 17 00:00:00 2001 From: Morten Lied Johansen Date: Mon, 4 Nov 2019 22:10:41 +0100 Subject: [PATCH] Fix ordering of tasks Correct the execution order of deep dependency trees. Fixes #28. --- bake/bakefile.py | 2 +- tests/ordering.Bakefile | 12 ++++++++++++ tests/ordering.bats | 9 +++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/ordering.Bakefile create mode 100644 tests/ordering.bats diff --git a/bake/bakefile.py b/bake/bakefile.py index 95b3edd..3e531c5 100644 --- a/bake/bakefile.py +++ b/bake/bakefile.py @@ -472,7 +472,7 @@ class TaskScript(BaseAction): # Remove duplicates from the list. _actions = [] - for action in actions: + for action in reversed(actions): if action not in _actions: _actions.append(action) actions = _actions diff --git a/tests/ordering.Bakefile b/tests/ordering.Bakefile new file mode 100644 index 0000000..fdc848e --- /dev/null +++ b/tests/ordering.Bakefile @@ -0,0 +1,12 @@ +build: build/stage + +build/stage: fetch + echo Building stage + +fetch: fetch/consul fetch/s6-overlay + +fetch/consul: + echo Fetching consul + +fetch/s6-overlay: + echo Fetching S6 diff --git a/tests/ordering.bats b/tests/ordering.bats new file mode 100644 index 0000000..c63c634 --- /dev/null +++ b/tests/ordering.bats @@ -0,0 +1,9 @@ +#!/usr/bin/env bats +export BAKEFILE=ordering.Bakefile + +@test "dependencies are resolved correctly" { + run bake + [[ "${status}" -eq 0 ]] + [[ "${lines[0]}" == *"build…"* ]] + [[ "${lines[1]}" == *"fetch/consul, fetch/s6-overlay, fetch, & build/stage."* ]] +}