diff options
| author | Simon McVittie <smcv@collabora.com> | 2022-01-16 14:15:58 +0000 |
|---|---|---|
| committer | Simon McVittie <smcv@debian.org> | 2022-01-18 01:18:08 +0000 |
| commit | 74f02d1e9569bde9523b9add9e7d3fb5fbfa1e63 (patch) | |
| tree | 6522cdbd1ea25ecdab38b7dcd6ff2fc03950bcc0 | |
| parent | 1dbc175314578954d38615626b7862522b74566a (diff) | |
| download | flatpak-74f02d1e9569bde9523b9add9e7d3fb5fbfa1e63.tar.gz | |
test-override: Assert that only the expected term is negated
We weren't distinguishing here between overrides that should have been
negated (xdg-documents) and overrides that should not have been negated
(everything else).
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 4e3d1d8b7bbd4c0611b6bb44f67c6ad1734d6b7d)
| -rw-r--r-- | tests/libtest.sh | 24 | ||||
| -rwxr-xr-x | tests/test-override.sh | 18 |
2 files changed, 37 insertions, 5 deletions
diff --git a/tests/libtest.sh b/tests/libtest.sh index 1daac333..c6d9ab56 100644 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -597,3 +597,27 @@ trap cleanup EXIT if test -n "${FLATPAK_TESTS_DEBUG:-}"; then set -x fi + +assert_semicolon_list_contains () { + list="$1" + member="$2" + + case ";$list;" in + (*";$member;"*) + ;; + (*) + assert_not_reached "\"$list\" should contain \"$member\"" + ;; + esac +} + +assert_not_semicolon_list_contains () { + local list="$1" + local member="$2" + + case ";$list;" in + (*";$member;"*) + assert_not_reached "\"$list\" should not contain \"$member\"" + ;; + esac +} diff --git a/tests/test-override.sh b/tests/test-override.sh index b8af5521..c7b283ae 100755 --- a/tests/test-override.sh +++ b/tests/test-override.sh @@ -173,11 +173,19 @@ ${FLATPAK} override --user --nofilesystem=xdg-documents org.test.Hello ${FLATPAK} override --user --show org.test.Hello > override assert_file_has_content override "^\[Context\]$" -assert_file_has_content override "^filesystems=.*/media;.*$" -assert_file_has_content override "^filesystems=.*home;.*$" -assert_file_has_content override "^filesystems=.*xdg-documents;.*$" -assert_file_has_content override "^filesystems=.*xdg-desktop/foo:create;.*$" -assert_file_has_content override "^filesystems=.*xdg-config:ro;.*$" +filesystems="$(sed -ne 's/^filesystems=//p' override)" +assert_semicolon_list_contains "$filesystems" "/media" +assert_not_semicolon_list_contains "$filesystems" "!/media" +assert_semicolon_list_contains "$filesystems" "home" +assert_not_semicolon_list_contains "$filesystems" "!home" +assert_not_semicolon_list_contains "$filesystems" "xdg-documents" +assert_semicolon_list_contains "$filesystems" "!xdg-documents" +assert_semicolon_list_contains "$filesystems" "xdg-desktop/foo:create" +assert_not_semicolon_list_contains "$filesystems" "!xdg-desktop/foo" +assert_not_semicolon_list_contains "$filesystems" "!xdg-desktop/foo:create" +assert_semicolon_list_contains "$filesystems" "xdg-config:ro" +assert_not_semicolon_list_contains "$filesystems" "!xdg-config" +assert_not_semicolon_list_contains "$filesystems" "!xdg-config:ro" ok "override --filesystem" |
