From a3464bebb7d87537aeed26fa8f535c077ab124db Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 21 Oct 2021 18:38:29 +0100 Subject: tests: Check that we handle XDG_foo_HOME as intended Signed-off-by: Simon McVittie --- tests/test-run.sh | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/test-run.sh b/tests/test-run.sh index 4f785f9d..6e84a507 100644 --- a/tests/test-run.sh +++ b/tests/test-run.sh @@ -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 @@ -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$" -- cgit v1.2.1