-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Remove the bin/ dir that was created as a side-effect of grab.
'stacker grab' was creating a 'bin/' dir in the current working directory. This fixes that and adds a test to ensure that neither grab nor build have side effects. Fixes #566. Signed-off-by: Scott Moser <smoser@brickies.net>
- Loading branch information
Showing
3 changed files
with
123 additions
and
7 deletions.
There are no files selected for viewing
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
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,49 @@ | ||
load helpers | ||
|
||
function setup() { | ||
stacker_setup | ||
} | ||
|
||
function teardown() { | ||
cleanup | ||
} | ||
|
||
# do a build and a grab in an empty directory and | ||
# verify that no unexpected files are created. | ||
@test "grab has no side-effects" { | ||
cat > stacker.yaml <<EOF | ||
layer1: | ||
from: | ||
type: oci | ||
url: $BUSYBOX_OCI | ||
imports: | ||
- myfile.txt | ||
run: | | ||
cp /stacker/imports/myfile.txt /my-file | ||
EOF | ||
startdir="$PWD" | ||
wkdir="$PWD/work-dir" | ||
bdir="$PWD/build-dir" | ||
grabdir="$PWD/grab-dir" | ||
mkdir "$wkdir" "$grabdir" "$bdir" | ||
give_user_ownership "$wkdir" "$grabdir" "$bdir" | ||
|
||
echo "hello world" > myfile.txt | ||
expected_sha=$(sha myfile.txt) | ||
|
||
cd "$bdir" | ||
stacker "--work-dir=$wkdir" build "--stacker-file=$startdir/stacker.yaml" | ||
dir_is_empty . || | ||
test_error "build dir had unexpected files: $_RET_EXTRA" | ||
|
||
cd "$grabdir" | ||
stacker "--work-dir=$wkdir" grab layer1:/my-file | ||
[ -f my-file ] | ||
found_sha=$(sha my-file) | ||
[ "${expected_sha}" = "${found_sha}" ] | ||
|
||
dir_has_only . my-file || | ||
test_error "grab produced extra files." \ | ||
"missing=${_RET_MISSING} extra=${_RET_EXTRA}" | ||
} | ||
|
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