Closed xxxserxxx closed 3 years ago
Do you have XDG_CONFIG_HOME
set in Arch and is there also a $XDG_CONFIG_HOME/todo/config
configuration? The test driver redirects $HOME
but doesn't do the same for XDG_CONFIG_HOME
, so that could explain the problem. On Ubuntu and Mac OS (where the CI runs), this isn't set, so it did not get detected.
If I'm right, the tests should pass if you unset XDG_CONFIG_HOME
first.
Yes, that was it. I'll close this.
I don't remember setting up ~/.config/todo/config
, I must have at one point. Is having one incorrect? If it's not an invalid set-up, should the test script unset that env var before running tests if having it set causes false failures?
I'll update the AUR -- even if it isn't changed here, the PKGBUILD should be able to unset it. AFAIK, it's a common setting.
This can easily be fixed in Arch Linux.
But if HOME is isolated during todotxt tests (in test-lib.sh), why not do the same for XDG_CONFIG_HOME?
UnsettingXDG_CONFIG_HOME
should have been done in the test library; that was an oversight. Apparently no other developer is using that variable together with a config, so you were the first ones to stumble over it.
It's great that you can easily fix this in Arch, but as it's a general potential problem in our test suite, I'd (also) like to fix this here, via #349. Thanks for reporting this, and for confirming that the suggested fix works!
The original reporter has found that more environment variables influence the unit tests. He needed to do:
unset XDG_CONFIG_HOME
unset TODO_DIR
unset TODOTXT_FINAL_FILTER
unset TODO_ACTIONS_DIR
unset TODO_NOTES_DIR
unset TODO_NOTE_TAG
unset TODOTXT_SORT_COMMAND
unset TODO_CONF_DIR
unset TODO_FILE
unset TODO_NOTE_EXT
in order to have all the make test
tests pass.
Ah, interesting; thanks for sharing that with us!
I've tried to make the tests fail by setting various variables to intentionally bad values:
$ export TODOTXT_FINAL_FILTER='tr a-z A-Z'
$ export TODO_DIR=/dev/null
$ export TODO_FILE=/dev/null
$ export TODOTXT_SORT_COMMAND=cat
$ export TODO_ACTIONS_DIR=/dev/null
But none of those affected the tests at all! In fact, I found this code in test-lib.sh that already unsets TODOTXT_CFG_FILE
, any variable starting with TODOTXT_
, and TODO_FILE
, DONE_FILE
, REPORT_FILE
, TMP_FILE
. This happens at the top of the test library, and the library itself is sourced at the very beginning of each test script. So I can't reproduce or explain the behavior that the original reported has seen.
Also, variables like TODO_NOTES_DIR
and TODO_NOTE_TAG
clearly belong to add-ons; however, a custom TODO_ACTIONS_DIR
can indeed negatively affect the tests because the built-in defaulting (which in the tests point to within the test directory) then does not happen. I was able to break the tests via a custom action dir that overrides the built-in ls
command and mangles the output. I've pushed https://github.com/todotxt/todo.txt-cli/pull/349/commits/8f8a0689749074188ce086e6a8b316a5b055ca62 to address this.
Hopefully, that's all that's required to make the tests succeed for you and the original reporter as well, and all the other variables were false positives.
Do you want to request a feature or report a bug? Bug
What is the current behavior?
This was first identified when the Arch AUR package for todotxt failed because of the test failures. Another user reported the same failure; I pulled this repo and got the same results:
make test
fails tests.Reference: https://aur.archlinux.org/packages/todotxt/#comment-817888
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
Ensure no environment variables are set that might interfere with tests:
Start with a clean clone:
Make and make test the project:
What is the expected behavior?
Unit tests pass.
Which versions todo.sh are you using? N/A
Which Operating System are you using? Linux Arch 5.12.12-arch1-1
Which version of bash are you using? GNU bash, version 5.1.8(1)-release (x86_64-pc-linux-gnu)