Test(compose): fix assumption on environment variables

The test `test_from_locale` fails when there is a user-defined compose
file, e.g. ~/.XCompose.

Indeed, the function `xkb_compose_table_new_from_locale` use various
environment variables to determine the location of the compose file.

Ensure no environment variables but the required ones are set, in order
to have robust tests.
master
Pierre Le Marre 2023-06-26 12:19:49 +02:00 committed by Wismill
parent de9d82077c
commit fc25e0f0f7
1 changed files with 16 additions and 0 deletions

View File

@ -588,6 +588,22 @@ main(int argc, char *argv[])
ctx = test_get_context(CONTEXT_NO_FLAG);
assert(ctx);
/*
* Ensure no environment variables but top_srcdir is set. This ensures
* that user Compose file paths are unset before the tests and set
* explicitely when necessary.
*/
#ifdef __linux__
const char *srcdir = getenv("top_srcdir");
clearenv();
setenv("top_srcdir", srcdir, 1);
#else
unsetenv("XCOMPOSEFILE");
unsetenv("XDG_CONFIG_HOME");
unsetenv("HOME");
unsetenv("XLOCALEDIR");
#endif
test_seqs(ctx);
test_conflicting(ctx);
test_XCOMPOSEFILE(ctx);