-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add layers-checkout blackbox test
- Loading branch information
Showing
9 changed files
with
222 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
test/black-box/layers-checkout/__layers/bar/2/recipes/bar.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
packageScript: "/bin/true" | ||
provideVars: | ||
BAR_VERSION: "2" |
3 changes: 3 additions & 0 deletions
3
test/black-box/layers-checkout/__layers/baz/1/recipes/baz.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
packageScript: "/bin/true" | ||
provideVars: | ||
BAZ_VERSION: "1" |
3 changes: 3 additions & 0 deletions
3
test/black-box/layers-checkout/__layers/baz/2/recipes/baz.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
packageScript: "/bin/true" | ||
provideVars: | ||
BAZ_VERSION: "2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
layers: | ||
- bar: | ||
checkoutSCM: | ||
scm: import | ||
url: "__layers/bar/2" | ||
- baz: | ||
checkoutSCM: | ||
scm: import | ||
url: "__layers/baz/1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
buildScript: "true" | ||
packageScript: "true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
layersScmOverrides: | ||
- | ||
match: | ||
url: "file://${FOO_DIR}" | ||
del: [branch, tag, commit] | ||
set: | ||
branch: "branch_override" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root: True | ||
|
||
depends: | ||
- name: bar | ||
use: [environment] | ||
|
||
buildVars: [BAR_VERSION] | ||
buildScript: | | ||
echo "${BAR_VERSION}" > bar | ||
packageScript: | | ||
cp $1/bar . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "[email protected]" | ||
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 "[email protected]" | ||
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 "[email protected]" | ||
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 |