diff --git a/test/black-box/layers-checkout/__layers/bar/2/recipes/bar.yaml b/test/black-box/layers-checkout/__layers/bar/2/recipes/bar.yaml new file mode 100644 index 00000000..6f7962ee --- /dev/null +++ b/test/black-box/layers-checkout/__layers/bar/2/recipes/bar.yaml @@ -0,0 +1,3 @@ +packageScript: "/bin/true" +provideVars: + BAR_VERSION: "2" diff --git a/test/black-box/layers-checkout/__layers/baz/1/recipes/baz.yaml b/test/black-box/layers-checkout/__layers/baz/1/recipes/baz.yaml new file mode 100644 index 00000000..1413c580 --- /dev/null +++ b/test/black-box/layers-checkout/__layers/baz/1/recipes/baz.yaml @@ -0,0 +1,3 @@ +packageScript: "/bin/true" +provideVars: + BAZ_VERSION: "1" diff --git a/test/black-box/layers-checkout/__layers/baz/2/recipes/baz.yaml b/test/black-box/layers-checkout/__layers/baz/2/recipes/baz.yaml new file mode 100644 index 00000000..7e1f8635 --- /dev/null +++ b/test/black-box/layers-checkout/__layers/baz/2/recipes/baz.yaml @@ -0,0 +1,3 @@ +packageScript: "/bin/true" +provideVars: + BAZ_VERSION: "2" diff --git a/test/black-box/layers-checkout/__layers/foo/config.yaml b/test/black-box/layers-checkout/__layers/foo/config.yaml new file mode 100644 index 00000000..bce8c082 --- /dev/null +++ b/test/black-box/layers-checkout/__layers/foo/config.yaml @@ -0,0 +1,9 @@ +layers: + - bar: + checkoutSCM: + scm: import + url: "__layers/bar/2" + - baz: + checkoutSCM: + scm: import + url: "__layers/baz/1" diff --git a/test/black-box/layers-checkout/__layers/foo/recipes/foo.yaml b/test/black-box/layers-checkout/__layers/foo/recipes/foo.yaml new file mode 100644 index 00000000..7f85f00e --- /dev/null +++ b/test/black-box/layers-checkout/__layers/foo/recipes/foo.yaml @@ -0,0 +1,2 @@ +buildScript: "true" +packageScript: "true" diff --git a/test/black-box/layers-checkout/config.yaml b/test/black-box/layers-checkout/config.yaml new file mode 100644 index 00000000..ac95374d --- /dev/null +++ b/test/black-box/layers-checkout/config.yaml @@ -0,0 +1,9 @@ +layers: + - name: foo + scm: git + url: "file://${FOO_DIR}" + commit: "${FOO_COMMIT}" + - name: bar + scm: git + url: "file://${BAR_DIR}" + commit: "${BAR_1_COMMIT}" diff --git a/test/black-box/layers-checkout/layers_overrides.yaml b/test/black-box/layers-checkout/layers_overrides.yaml new file mode 100644 index 00000000..232d26f0 --- /dev/null +++ b/test/black-box/layers-checkout/layers_overrides.yaml @@ -0,0 +1,8 @@ +layersScmOverrides: + - + match: + url: "file://${FOO_DIR}" + del: [branch, tag, commit] + set: + branch: "branch_override" + diff --git a/test/black-box/layers-checkout/recipes/root.yaml b/test/black-box/layers-checkout/recipes/root.yaml new file mode 100644 index 00000000..80970720 --- /dev/null +++ b/test/black-box/layers-checkout/recipes/root.yaml @@ -0,0 +1,11 @@ +root: True + +depends: + - name: bar + use: [environment] + +buildVars: [BAR_VERSION] +buildScript: | + echo "${BAR_VERSION}" > bar +packageScript: | + cp $1/bar . diff --git a/test/black-box/layers-checkout/run.sh b/test/black-box/layers-checkout/run.sh new file mode 100755 index 00000000..32281681 --- /dev/null +++ b/test/black-box/layers-checkout/run.sh @@ -0,0 +1,174 @@ +#!/bin/bash -e +. ../../test-lib.sh 2>/dev/null || { echo "Must run in script directory!" ; exit 1 ; } + +foo_dir=$(mktemp -d) +bar_dir=$(mktemp -d) +baz_dir=$(mktemp -d) +trap 'rm -rf "$foo_dir" "$bar_dir" "$baz_dir" layers layers.attic log-status.txt' EXIT +cleanup + +# build the git layer bar/1 +pushd ${bar_dir} +mkdir recipes +cat > recipes/bar.yaml << EOF +packageScript: "/bin/true" +provideVars: + BAR_VERSION: "1" +EOF +git init . +git config user.email "bob@bob.bob" +git config user.name est + +git add . +git commit -m "first commit" +bar_c0=$(git rev-parse HEAD) + +sed -i 's/BAR_VERSION: "1"/BAR_VERSION: "3"/g' recipes/bar.yaml +git commit -a -m "bump bar" +bar_c1=$(git rev-parse HEAD) +popd # ${bar_dir} + +pushd ${foo_dir} +cat > config.yaml << 'EOF' +layers: + - name: bar + scm: git + url: "file://${BAR_DIR}" + commit: "${BAR_2_COMMIT}" + - name: baz + scm: git + url: "file://${BAZ_DIR}" + commit: "${BAZ_COMMIT}" + - name: baz1 + scm: git + url: "file://${BAZ_DIR}" + commit: "${BAZ1_COMMIT}" + +EOF +mkdir recipes +cat > recipes/foo.yaml << EOF +buildScript: "true" +packageScript: "true" +EOF +git init . +git config user.email "bob@bob.bob" +git config user.name est + +git add . +git commit -m "first commit" +foo_c0=$(git rev-parse HEAD) + +cat > config.yaml << 'EOF' +layers: + - name: bar + scm: git + url: "file://${BAR_DIR}" + commit: "${BAR_2_COMMIT}" +EOF +git add . +git commit -m "remove baz" +foo_c1=$(git rev-parse HEAD) + +git checkout -b branch_override +echo "override" > override +git add . +git commit -m "override" +popd # $foo_dir + +pushd ${baz_dir} +mkdir recipes +cat > recipes/baz.yaml << EOF +buildScript: "true" +packageScript: "true" +provideVars: + BAZ_VERSION: "1" +EOF +git init . +git config user.email "bob@bob.bob" +git config user.name est +git add . +git commit -m "first commit" +baz_c0=$(git rev-parse HEAD) +cat > recipes/baz.yaml << EOF +buildScript: "true" +packageScript: "true" +provideVars: + BAZ_VERSION: "2" +EOF +git commit -a -m "bump" +baz_c1=$(git rev-parse HEAD) + +mv recipes/baz.yaml recipes/baz1.yaml +git commit -a -m "rename" +baz_c2=$(git rev-parse HEAD) + +popd # $baz_dir + +# just build the root recipe. Layer should be fetched automatically. +run_bob dev root -DBAR_1_COMMIT=${bar_c0} -DBAR_2_COMMIT=${bar_c1} -DBAR_DIR=${bar_dir} \ + -DBAZ_DIR=${baz_dir} -DBAZ_COMMIT="${baz_c0}" \ + -DBAZ1_COMMIT="${baz_c2}" \ + -DFOO_DIR=${foo_dir} -DFOO_COMMIT="${foo_c0}" -vvv + +# run update +run_bob layers update -DBAR_1_COMMIT=${bar_c0} -DBAR_2_COMMIT=${bar_c1} -DBAR_DIR=${bar_dir} \ + -DBAZ_DIR=${baz_dir} -DBAZ_COMMIT="${baz_c0}" \ + -DBAZ1_COMMIT="${baz_c2}" \ + -DFOO_DIR=${foo_dir} -DFOO_COMMIT="${foo_c0}" + +# remove layers + clean +cleanup +rm -rf layers + +# if the layer already exists we fail +mkdir -p layers/bar + +expect_fail run_bob layers update -DBAR_1_COMMIT=${bar_c0} -DBAR_2_COMMIT=${bar_c1} -DBAR_DIR=${bar_dir} \ + -DBAZ_DIR=${baz_dir} -DBAZ_COMMIT="${baz_c0}" \ + -DBAZ1_COMMIT="${baz_c2}" \ + -DFOO_DIR=${foo_dir} -DFOO_COMMIT="${foo_c0}" + +rm -rf layers/bar + +# run update +run_bob layers update -DBAR_1_COMMIT=${bar_c0} -DBAR_2_COMMIT=${bar_c1} -DBAR_DIR=${bar_dir} \ + -DBAZ_DIR=${baz_dir} -DBAZ_COMMIT="${baz_c0}" \ + -DBAZ1_COMMIT="${baz_c2}" \ + -DFOO_DIR=${foo_dir} -DFOO_COMMIT="${foo_c0}" + +# make some changes in layers +echo "#foo" >> layers/bar/recipes/bar.yaml + +run_bob layers status -DBAR_1_COMMIT=${bar_c0} -DBAR_2_COMMIT=${bar_c1} -DBAR_DIR=${bar_dir} \ + -DBAZ_DIR=${baz_dir} -DBAZ_COMMIT="${baz_c0}" \ + -DBAZ1_COMMIT="${baz_c2}" \ + -DFOO_DIR=${foo_dir} -DFOO_COMMIT="${foo_c0}" | tee log-status.txt +grep -q 'STATUS.\+M.\+[/\]bar' log-status.txt + +# update bar to new revision (bar will be moved to attic) +run_bob layers update -DBAR_1_COMMIT=${bar_c1} -DBAR_2_COMMIT=${bar_c1} -DBAR_DIR=${bar_dir} \ + -DBAZ_DIR=${baz_dir} -DBAZ_COMMIT="${baz_c0}" \ + -DBAZ1_COMMIT="${baz_c2}" \ + -DFOO_DIR=${foo_dir} -DFOO_COMMIT="${foo_c0}" +expect_exist layers.attic/*_bar + +bar_now=$(git -C layers/bar rev-parse HEAD) +expect_equal ${bar_c1} ${bar_now} + +rm layers.attic -rf +# checkout new foo where the baz* layers have been removed. they should go to attic +run_bob layers update -DBAR_1_COMMIT=${bar_c1} -DBAR_2_COMMIT=${bar_c1} -DBAR_DIR=${bar_dir} \ + -DFOO_DIR=${foo_dir} -DFOO_COMMIT="${foo_c1}" + +expect_exist layers.attic/*_baz +expect_exist layers.attic/*_baz1 + +# test layersScmOverrides +run_bob layers update -DBAR_1_COMMIT=${bar_c1} -DBAR_2_COMMIT=${bar_c1} -DBAR_DIR=${bar_dir} \ + -DFOO_DIR=${foo_dir} -DFOO_COMMIT="${foo_c1}" \ + -lc layers_overrides -vv +expect_exist layers/foo/override + +# remove layers + clean +cleanup +rm -rf layers