tests: always log to file during tests

And set the cachedir (for logging and other things) to a random tmpdir.
This commit is contained in:
Dirk-Jan C. Binnema 2023-04-09 14:43:36 +03:00
parent 8e9579055f
commit c78435a6fe
2 changed files with 5 additions and 1 deletions

View File

@ -93,7 +93,10 @@ black_hole(void)
void
Mu::mu_test_init(int *argc, char ***argv)
{
const auto tmpdir{test_random_tmpdir()};
g_setenv("MU_TEST", "yes", TRUE);
g_setenv("XDG_CACHE_HOME", tmpdir.c_str(), TRUE);
g_test_init(argc, argv, NULL);

View File

@ -104,7 +104,6 @@ main(int argc, char* argv[])
* there's a subcommand
*/
/*
* set up logging
*/
@ -113,6 +112,8 @@ main(int argc, char* argv[])
lopts |= Logger::Options::StdOutErr;
if (opts->debug)
lopts |= Logger::Options::Debug;
if (g_getenv("MU_TEST"))
lopts |= Logger::Options::File;
const auto logger = Logger::make(opts->runtime_path(RuntimePath::LogFile),
lopts);