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 4e3d1d8b7b)
This commit is contained in:
Simon McVittie
2022-01-16 14:15:58 +00:00
committed by Simon McVittie
parent 1dbc175314
commit 74f02d1e95
2 changed files with 37 additions and 5 deletions

View File

@@ -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
}

View File

@@ -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"