From f884f73297a87f3a89202d5cedc7ea7d6e7096d4 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Wed, 4 Aug 2021 00:57:31 +0200 Subject: [PATCH] TESTSFIX: t0000-config.sh may unintentionally pick up existing user config in $XDG_CONFIG_HOME/todo/config (#349) * TESTSFIX: t0000-config.sh may unintentionally pick up existing user config in `$XDG_CONFIG_HOME/todo/config` This corner case was missed when the XDG alternative config location was introduced, likely because the variable isn't set by default on Ubuntu or Mac OS, and none of the developers had a config there. HOME is already redirected to the current working directory; as `XDG_CONFIG_HOME` is just a config alternative that has a fallback to `$HOME/.config`, simply unset it. Fixes #347 * TESTSFIX: User add-ons that override built-in actions may break tests If `TODO_ACTIONS_DIR` is already defined, the defaulting in todo.sh are skipped. The user may have custom add-ons that override built-in actions; any incompatible behavior would negatively affect the tests then. By setting the variable to the first default location, we avoid this interference. --- tests/test-lib.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test-lib.sh b/tests/test-lib.sh index 18655bc..499f9c7 100644 --- a/tests/test-lib.sh +++ b/tests/test-lib.sh @@ -693,6 +693,13 @@ cd -P "$test" || exit 1 # but use something specified by the framework. HOME=$(pwd) export HOME +# Unset XDG_CONFIG_HOME as that is used as a config alternative. +unset XDG_CONFIG_HOME +# User add-ons may override built-in commands; these could have incompatible +# behavior that makes the tests fail. Avoid picking up user add-ons by +# explicitly configuring the first default location (which with the redirected +# HOME lies within the test directory and usually does not exist). +export TODO_ACTIONS_DIR="$HOME/.todo/actions" this_test=${0##*/} this_test=${this_test%%-*}