Skip to content

Commit

Permalink
tests: Check that we handle XDG_foo_HOME as intended
Browse files Browse the repository at this point in the history
Signed-off-by: Simon McVittie <smcv@collabora.com>
  • Loading branch information
smcv committed Oct 21, 2021
1 parent 5497d02 commit a43e0fd
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion tests/test-run.sh
Expand Up @@ -24,7 +24,7 @@ set -euo pipefail
skip_without_bwrap
skip_revokefs_without_fuse

echo "1..19"
echo "1..20"

# Use stable rather than master as the branch so we can test that the run
# command automatically finds the branch correctly
Expand Down Expand Up @@ -83,6 +83,40 @@ assert_file_has_content value-in-sandbox "^/run/user/$(id -u)\$"

ok "XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR not inherited"

assert_streq "$XDG_CACHE_HOME" "${TEST_DATA_DIR}/home/cache"
run_sh org.test.Hello 'echo "$XDG_CACHE_HOME"' > value-in-sandbox
head value-in-sandbox >&2
assert_file_has_content value-in-sandbox "^${TEST_DATA_DIR}/home/\\.var/app/org\\.test\\.Hello/cache\$"
run_sh org.test.Hello 'echo "$HOST_XDG_CACHE_HOME"' > host-value-in-sandbox
head host-value-in-sandbox >&2
assert_file_has_content host-value-in-sandbox "^${TEST_DATA_DIR}/home/cache\$"

assert_streq "$XDG_CONFIG_HOME" "${TEST_DATA_DIR}/home/config"
run_sh org.test.Hello 'echo "$XDG_CONFIG_HOME"' > value-in-sandbox
head value-in-sandbox >&2
assert_file_has_content value-in-sandbox "^${TEST_DATA_DIR}/home/\\.var/app/org\\.test\\.Hello/config\$"
run_sh org.test.Hello 'echo "$HOST_XDG_CONFIG_HOME"' > host-value-in-sandbox
head host-value-in-sandbox >&2
assert_file_has_content host-value-in-sandbox "^${TEST_DATA_DIR}/home/config\$"

assert_streq "$XDG_DATA_HOME" "${TEST_DATA_DIR}/home/share"
run_sh org.test.Hello 'echo "$XDG_DATA_HOME"' > value-in-sandbox
head value-in-sandbox >&2
assert_file_has_content value-in-sandbox "^${TEST_DATA_DIR}/home/\\.var/app/org\\.test\\.Hello/data\$"
run_sh org.test.Hello 'echo "$HOST_XDG_DATA_HOME"' > host-value-in-sandbox
head host-value-in-sandbox >&2
assert_file_has_content host-value-in-sandbox "^${TEST_DATA_DIR}/home/share\$"

assert_streq "$XDG_STATE_HOME" "${TEST_DATA_DIR}/home/state"
run_sh org.test.Hello 'echo "$XDG_STATE_HOME"' > value-in-sandbox
head value-in-sandbox >&2
assert_file_has_content value-in-sandbox "^${TEST_DATA_DIR}/home/\\.var/app/org\\.test\\.Hello/\\.local/state\$"
run_sh org.test.Hello 'echo "$HOST_XDG_STATE_HOME"' > host-value-in-sandbox
head host-value-in-sandbox >&2
assert_file_has_content host-value-in-sandbox "^${TEST_DATA_DIR}/home/state\$"

ok "XDG_foo_HOME work as expected"

run_sh org.test.Platform cat /.flatpak-info >runtime-fpi
assert_file_has_content runtime-fpi "[Runtime]"
assert_file_has_content runtime-fpi "^runtime=runtime/org\.test\.Platform/$ARCH/stable$"
Expand Down

0 comments on commit a43e0fd

Please sign in to comment.