Skip to content

Commit

Permalink
test: add blackbox tests for bob layers
Browse files Browse the repository at this point in the history
  • Loading branch information
rhubert committed Jun 3, 2024
1 parent a317c20 commit a57b4b7
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
packageScript: "/bin/true"
provideVars:
BAR_VERSION: "2"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
packageScript: "/bin/true"
provideVars:
BAZ_VERSION: "1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
packageScript: "/bin/true"
provideVars:
BAZ_VERSION: "2"
9 changes: 9 additions & 0 deletions test/black-box/layers-checkout/__layers/foo/config.yaml
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"
2 changes: 2 additions & 0 deletions test/black-box/layers-checkout/__layers/foo/recipes/foo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
buildScript: "true"
packageScript: "true"
10 changes: 10 additions & 0 deletions test/black-box/layers-checkout/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
layers:
- foo:
checkoutSCM:
scm: import
url: "__layers/foo"
- bar:
checkoutSCM:
scm: git
url: "file://${BAR_DIR}"
commit: "${BAR_COMMIT}"
11 changes: 11 additions & 0 deletions test/black-box/layers-checkout/recipes/root.yaml
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 .
53 changes: 53 additions & 0 deletions test/black-box/layers-checkout/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash -e
. ../../test-lib.sh 2>/dev/null || { echo "Must run in script directory!" ; exit 1 ; }

bar_dir=$(mktemp -d)
trap 'rm -rf "$bar_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}

# just build the root recipe. Layer should be fetched automatically.
run_bob dev root -DBAR_COMMIT=${bar_c0} -DBAR_DIR=${bar_dir}

# run update
run_bob layers update -DBAR_COMMIT=${bar_c0} -DBAR_DIR=${bar_dir}

# remove layers + clean
cleanup
rm -rf layers

# run update - should fetch layers
run_bob layers update -DBAR_COMMIT=${bar_c0} -DBAR_DIR=${bar_dir}

# make some changes in layers
echo "#foo" >> layers/bar/recipes/bar.yaml

run_bob layers status -DBAR_COMMIT=${bar_c0} -DBAR_DIR=${bar_dir} | 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_COMMIT=${bar_c1} -DBAR_DIR=${bar_dir}
expect_exist layers.attic

bar_now=$(git -C layers/bar rev-parse HEAD)
expect_equal ${bar_c1} ${bar_now}

0 comments on commit a57b4b7

Please sign in to comment.