Skip to content

Commit

Permalink
fix(spread): set expected failures for core24 tests
Browse files Browse the repository at this point in the history
This commit does the equivalent of pytest's "xfail(strict=True)": all
core24 tests are currently fail because no Snapcraft command has been
implemented yet, so the test checks that the tool fails with the
expected message, and then exits successfully.

The idea is that once a command is implemented the corresponding spread
tests will start to fail - we can then scrutinize each test to validate
the new behavior.
  • Loading branch information
tigarmo committed Feb 6, 2024
1 parent a9a3961 commit 4fb3c6b
Show file tree
Hide file tree
Showing 36 changed files with 210 additions and 74 deletions.
18 changes: 14 additions & 4 deletions tests/spread/core24/architectures/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ environment:
prepare: |
#shellcheck source=tests/spread/tools/snapcraft-yaml.sh
. "$TOOLS_DIR/snapcraft-yaml.sh"
set_base "./snaps/$SNAP/snap/snapcraft.yaml"
# set_base "./snaps/$SNAP/snap/snapcraft.yaml"
restore: |
cd "./snaps/$SNAP"
snapcraft clean
# If this next line fails, delete it and replace it with the one following it
snapcraft clean 2>&1 | MATCH '"clean" command is not implemented for core24!'; exit 0
# snapcraft clean
rm -f ./*.snap
#shellcheck source=tests/spread/tools/snapcraft-yaml.sh
Expand All @@ -29,15 +31,23 @@ execute: |
# if the environmental variable file exists, then call snapcraft with the environmental variables
if [[ -e "environmental-variables.txt" ]]; then
# If this next line fails, delete it and replace it with the one following it
# shellcheck disable=SC2046
eval $(cat "environmental-variables.txt") snapcraft pack --destructive-mode 2>&1 | MATCH '"pack" command is not implemented for core24!'; exit 0
# shellcheck disable=SC2046
eval $(cat "environmental-variables.txt") snapcraft pack --destructive-mode
# if the arguments variable file exists, then call snapcraft with the arguments
elif [[ -e "arguments.txt" ]]; then
# If this next line fails, delete it and replace it with the one following it
# shellcheck disable=SC2046
snapcraft pack --destructive-mode $(cat "arguments.txt") 2>&1 | MATCH '"pack" command is not implemented for core24!'; exit 0
# shellcheck disable=SC2046
eval snapcraft pack --destructive-mode $(cat "arguments.txt")
eval snapcraft pack --destructive-mode $(cat "arguments.txt")
# otherwise, just call `snapcraft pack`
else
snapcraft pack --destructive-mode
# If this next line fails, delete it and replace it with the one following it
snapcraft pack --destructive-mode 2>&1 | MATCH '"pack" command is not implemented for core24!'; exit 0
# snapcraft pack --destructive-mode
fi
# confirm the snaps with the expected architectures were built
Expand Down
8 changes: 6 additions & 2 deletions tests/spread/core24/chisel-base/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ environment:
SNAPCRAFT_BUILD_ENVIRONMENT: ""

restore: |
snapcraft clean
# If this next line fails, delete it and replace it with the one following it
snapcraft clean 2>&1 | MATCH '"clean" command is not implemented for core24!'; exit 0
# snapcraft clean
rm -f ./*.snap
execute: |
snapcraft pack
# If this next line fails, delete it and replace it with the one following it
snapcraft pack 2>&1 | MATCH '"pack" command is not implemented for core24!'; exit 0
# snapcraft pack
snap install core2x_*.snap --dangerous
# verify that the chisel packages made it to the base
Expand Down
4 changes: 3 additions & 1 deletion tests/spread/core24/clean/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ execute: |
# Unset SNAPCRAFT_BUILD_ENVIRONMENT=host.
unset SNAPCRAFT_BUILD_ENVIRONMENT
snapcraft pack
# If this next line fails, delete it and replace it with the one following it
snapcraft pack 2>&1 | MATCH '"pack" command is not implemented for core24!'; exit 0
# snapcraft pack
snapcraft clean part1
lxc --project=snapcraft list | grep snapcraft-clean
Expand Down
4 changes: 3 additions & 1 deletion tests/spread/core24/craftctl/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ restore: |
execute: |
cd "$SNAP"
snapcraft --verbose --destructive-mode
# If this next line fails, delete it and replace it with the one following it
snapcraft --verbose --destructive-mode 2>&1 | MATCH 'command is not implemented for core24!'; exit 0
# snapcraft --verbose --destructive-mode
TESTBIN="${SNAP##*test-}"
snap install craftctl-*.snap --dangerous
$TESTBIN | grep hello
10 changes: 7 additions & 3 deletions tests/spread/core24/environment/paths/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ environment:
prepare: |
#shellcheck source=tests/spread/tools/snapcraft-yaml.sh
. "$TOOLS_DIR/snapcraft-yaml.sh"
set_base "../snaps/$SNAP/snap/snapcraft.yaml"
# set_base "../snaps/$SNAP/snap/snapcraft.yaml"
restore: |
cd "../snaps/$SNAP"
snapcraft clean
# If this next line fails, delete it and replace it with the one following it
snapcraft clean 2>&1 | MATCH '"clean" command is not implemented for core24!'; exit 0
# snapcraft clean
rm -f ./*.snap
#shellcheck source=tests/spread/tools/snapcraft-yaml.sh
Expand All @@ -23,7 +25,9 @@ restore: |
execute: |
cd "../snaps/$SNAP"
snapcraft prime --destructive-mode
# If this next line fails, delete it and replace it with the one following it
snapcraft prime --destructive-mode 2>&1 | MATCH '"prime" command is not implemented for core24!'; exit 0
# snapcraft prime --destructive-mode
if ! diff -U10 prime/meta/snap.yaml expected_snap.yaml; then
echo "The formatting for snap.yaml is incorrect"
Expand Down
8 changes: 5 additions & 3 deletions tests/spread/core24/environment/test-variables/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ environment:
prepare: |
#shellcheck source=tests/spread/tools/snapcraft-yaml.sh
. "$TOOLS_DIR/snapcraft-yaml.sh"
set_base "../snaps/$SNAP/snap/snapcraft.yaml"
# set_base "../snaps/$SNAP/snap/snapcraft.yaml"
restore: |
cd "../snaps/$SNAP"
Expand Down Expand Up @@ -41,8 +41,10 @@ execute: |
grep -q "$exp" < "$file"
done
}
snapcraft pull
# If this next line fails, delete it and replace it with the one following it
snapcraft pull 2>&1 | MATCH '"pull" command is not implemented for core24!'; exit 0
# snapcraft pull
check_vars pull.txt
snapcraft build
Expand Down
8 changes: 6 additions & 2 deletions tests/spread/core24/invalid-utf8/task.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
summary: Handle invalid utf-8 text during the build

restore: |
snapcraft clean
# If this next line fails, delete it and replace it with the one following it
snapcraft clean 2>&1 | MATCH '"clean" command is not implemented for core24!'; exit 0
# snapcraft clean
rm -f ./*.snap
execute: |
snapcraft pack -v 2>&1 | MATCH ":: hi � bye"
# If this next line fails, delete it and replace it with the one following it
snapcraft pack -v 2>&1 | MATCH '"pack" command is not implemented for core24!'; exit 0
# snapcraft pack -v 2>&1 | MATCH ":: hi � bye"
8 changes: 6 additions & 2 deletions tests/spread/core24/linters/classic-libc/task.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
summary: Test classic linter output

restore: |
snapcraft clean
# If this next line fails, delete it and replace it with the one following it
snapcraft clean 2>&1 | MATCH '"clean" command is not implemented for core24!'; exit 0
# snapcraft clean
rm -f ./*.snap ./*.txt
execute: |
snapcraft 2> output.txt
# If this next line fails, delete it and replace it with the one following it
snapcraft 2>&1 | MATCH '"pack" command is not implemented for core24!'; exit 0
# snapcraft 2> output.txt
test -f classic-linter-test_0.1_*.snap
Expand Down
8 changes: 6 additions & 2 deletions tests/spread/core24/linters/classic/task.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
summary: Test classic linter output

restore: |
snapcraft clean
# If this next line fails, delete it and replace it with the one following it
snapcraft clean 2>&1 | MATCH '"clean" command is not implemented for core24!'; exit 0
# snapcraft clean
rm -f ./*.snap ./*.txt
execute: |
snapcraft 2> output.txt
# If this next line fails, delete it and replace it with the one following it
snapcraft 2>&1 | MATCH '"pack" command is not implemented for core24!'; exit 0
# snapcraft 2> output.txt
test -f classic-linter-test_0.1_*.snap
Expand Down
8 changes: 6 additions & 2 deletions tests/spread/core24/linters/library-ignore-missing/task.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
summary: Ignore missing library linter issues

restore: |
snapcraft clean
# If this next line fails, delete it and replace it with the one following it
snapcraft clean 2>&1 | MATCH '"clean" command is not implemented for core24!'; exit 0
# snapcraft clean
rm -f ./*.snap ./*.txt
execute: |
snapcraft 2> output.txt
# If this next line fails, delete it and replace it with the one following it
snapcraft 2>&1 | MATCH '"pack" command is not implemented for core24!'; exit 0
# snapcraft 2> output.txt
test -f library-ignore-missing_0.1_*.snap
Expand Down
8 changes: 6 additions & 2 deletions tests/spread/core24/linters/library-ignore-unused/task.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
summary: Ignore unused library linter issues

restore: |
snapcraft clean
# If this next line fails, delete it and replace it with the one following it
snapcraft clean 2>&1 | MATCH '"clean" command is not implemented for core24!'; exit 0
# snapcraft clean
rm -f ./*.snap ./*.txt
execute: |
snapcraft 2> output.txt
# If this next line fails, delete it and replace it with the one following it
snapcraft 2>&1 | MATCH '"pack" command is not implemented for core24!'; exit 0
# snapcraft 2> output.txt
test -f library-ignore-unused_0.1_*.snap
Expand Down
8 changes: 6 additions & 2 deletions tests/spread/core24/linters/library-ignored-mixed/task.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
summary: Ignore mixed library linter issues

restore: |
snapcraft clean
# If this next line fails, delete it and replace it with the one following it
snapcraft clean 2>&1 | MATCH '"clean" command is not implemented for core24!'; exit 0
# snapcraft clean
rm -f ./*.snap ./*.txt
execute: |
snapcraft 2> output.txt
# If this next line fails, delete it and replace it with the one following it
snapcraft 2>&1 | MATCH '"pack" command is not implemented for core24!'; exit 0
# snapcraft 2> output.txt
test -f library-ignore-mixed_0.1_*.snap
Expand Down
8 changes: 6 additions & 2 deletions tests/spread/core24/linters/library-missing/task.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
summary: Raise linter warnings for missing libraries

restore: |
snapcraft clean
# If this next line fails, delete it and replace it with the one following it
snapcraft clean 2>&1 | MATCH '"clean" command is not implemented for core24!'; exit 0
# snapcraft clean
rm -f ./*.snap ./*.txt
execute: |
snapcraft 2> output.txt
# If this next line fails, delete it and replace it with the one following it
snapcraft 2>&1 | MATCH '"pack" command is not implemented for core24!'; exit 0
# snapcraft 2> output.txt
test -f library-missing_0.1_*.snap
Expand Down
8 changes: 6 additions & 2 deletions tests/spread/core24/linters/library-unused/task.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
summary: Raise linter warnings for unused libraries.

restore: |
snapcraft clean
# If this next line fails, delete it and replace it with the one following it
snapcraft clean 2>&1 | MATCH '"clean" command is not implemented for core24!'; exit 0
# snapcraft clean
rm -f ./*.snap ./*.txt
execute: |
snapcraft 2> output.txt
# If this next line fails, delete it and replace it with the one following it
snapcraft 2>&1 | MATCH '"pack" command is not implemented for core24!'; exit 0
# snapcraft 2> output.txt
test -f library-unused_0.1_*.snap
Expand Down
8 changes: 6 additions & 2 deletions tests/spread/core24/linters/library/task.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
summary: Test library linter output

restore: |
snapcraft clean
# If this next line fails, delete it and replace it with the one following it
snapcraft clean 2>&1 | MATCH '"clean" command is not implemented for core24!'; exit 0
# snapcraft clean
rm -f ./*.snap ./*.txt
execute: |
snapcraft 2> output.txt
# If this next line fails, delete it and replace it with the one following it
snapcraft 2>&1 | MATCH '"pack" command is not implemented for core24!'; exit 0
# snapcraft 2> output.txt
test -f gnome-calculator_*.snap
Expand Down
4 changes: 3 additions & 1 deletion tests/spread/core24/linters/lint-file/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ restore: |
execute: |
# build the test snap destructively to save time
snapcraft
# If this next line fails, delete it and replace it with the one following it
snapcraft 2>&1 | MATCH '"pack" command is not implemented for core24!'; exit 0
# snapcraft
# test the linter using a build provider
unset SNAPCRAFT_BUILD_ENVIRONMENT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
summary: Check linter warnings ros2-humble extension plus user ignores.

restore: |
snapcraft clean
# If this next line fails, delete it and replace it with the one following it
snapcraft clean 2>&1 | MATCH '"clean" command is not implemented for core24!'; exit 0
# snapcraft clean
rm -f ./*.snap ./*.txt
execute: |
snapcraft 2> output.txt
# If this next line fails, delete it and replace it with the one following it
snapcraft 2>&1 | MATCH '"pack" command is not implemented for core24!'; exit 0
# snapcraft 2> output.txt
test -f linter-ros2-humble-mixed_1.0_*.snap
Expand Down
8 changes: 6 additions & 2 deletions tests/spread/core24/linters/linter-ros2-humble/task.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
summary: Ignore unused library linter issues

restore: |
snapcraft clean
# If this next line fails, delete it and replace it with the one following it
snapcraft clean 2>&1 | MATCH '"clean" command is not implemented for core24!'; exit 0
# snapcraft clean
rm -f ./*.snap ./*.txt
execute: |
snapcraft 2> output.txt
# If this next line fails, delete it and replace it with the one following it
snapcraft 2>&1 | MATCH '"pack" command is not implemented for core24!'; exit 0
# snapcraft 2> output.txt
test -f linter-ros2-humble_1.0_*.snap
Expand Down
8 changes: 6 additions & 2 deletions tests/spread/core24/manifest/manifest-creation/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ prepare: |
snap install review-tools
restore: |
snapcraft clean
# If this next line fails, delete it and replace it with the one following it
snapcraft clean 2>&1 | MATCH '"clean" command is not implemented for core24!'; exit 0
# snapcraft clean
rm -f ./*.snap
rm -f ~/manifest_0.1_*.snap
execute: |
$CMD
# If this next line fails, delete it and replace it with the one following it
$CMD 2>&1 | MATCH 'command is not implemented for core24!'; exit 0
# $CMD
test -f manifest_0.1_*.snap
test -f prime/snap/manifest.yaml
Expand Down
8 changes: 6 additions & 2 deletions tests/spread/core24/manifest/manifest-info-cmdline/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ prepare: |
snap install review-tools
restore: |
snapcraft clean
# If this next line fails, delete it and replace it with the one following it
snapcraft clean 2>&1 | MATCH '"clean" command is not implemented for core24!'; exit 0
# snapcraft clean
rm -f ./*.snap
rm -f ~/manifest_0.1_*.snap
execute: |
unset SNAPCRAFT_BUILD_ENVIRONMENT
snapcraft --use-lxd --enable-manifest --manifest-image-information='{"test-var": "value"}'
# If this next line fails, delete it and replace it with the one following it
snapcraft --use-lxd --enable-manifest --manifest-image-information='{"test-var": "value"}' 2>&1 | MATCH '"pack" command is not implemented for core24!'; exit 0
# snapcraft --use-lxd --enable-manifest --manifest-image-information='{"test-var": "value"}'
unsquashfs manifest_0.1_*.snap
grep '^ test-var: value' squashfs-root/snap/manifest.yaml
Expand Down
9 changes: 7 additions & 2 deletions tests/spread/core24/manifest/manifest-info-envvars/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ prepare: |
snap install review-tools
restore: |
snapcraft clean
# If this next line fails, delete it and replace it with the one following it
snapcraft clean 2>&1 | MATCH '"clean" command is not implemented for core24!'; exit 0
# snapcraft clean
rm -f ./*.snap
rm -f ~/manifest_0.1_*.snap
execute: |
export SNAPCRAFT_BUILD_INFO=1
export SNAPCRAFT_IMAGE_INFO='{"test-var": "value"}'
snapcraft --use-lxd
# If this next line fails, delete it and replace it with the one following it
snapcraft --use-lxd 2>&1 | MATCH '"pack" command is not implemented for core24!'; exit 0
# snapcraft --use-lxd
unsquashfs manifest_0.1_*.snap
grep '^ test-var: value' squashfs-root/snap/manifest.yaml
Expand Down

0 comments on commit 4fb3c6b

Please sign in to comment.