When any XDG_*_HOME or XDG_RUNTIME_DIR variables are set, this causes
test failures.
FAIL: TestConfigPath//home/user/Library/Preferences/aerc/accounts.conf (0.00s)
xdg_test.go:86: got "/Users/vitaly/.config/aerc/accounts.conf"
expected "/home/user/Library/Preferences/aerc/accounts.conf"
Avoid leaking the local user's environment in the unit tests. Always
override the XDG_* variables.
Fixes: fff16640ad7c ("xdg: add functions to deal with user home paths")
Reported-by: Vitaly Ovchinnikov <v@postbox.nz>
Signed-off-by: Robin Jarry <robin@jarry.cc>
---
lib/xdg/xdg_test.go | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/xdg/xdg_test.go b/lib/xdg/xdg_test.go
index 6b8eac35cad2..8ab68e060d4c 100644
--- a/lib/xdg/xdg_test.go
+++ b/lib/xdg/xdg_test.go
@@ -14,6 +14,7 @@ func TestCachePath(t *testing.T) {
}{
{
args: []string{"aerc", "foo", "history"},
+ env: map[string]string{"XDG_CACHE_HOME": ""},
expected: map[string]string{
"": "/home/user/.cache/aerc/foo/history",
"darwin": "/home/user/Library/Caches/aerc/foo/history",
@@ -56,6 +57,7 @@ func TestConfigPath(t *testing.T) {
}{
{
args: []string{"aerc", "accounts.conf"},
+ env: map[string]string{"XDG_CONFIG_HOME": ""},
expected: map[string]string{
"": "/home/user/.config/aerc/accounts.conf",
"darwin": "/home/user/Library/Preferences/aerc/accounts.conf",
@@ -98,6 +100,7 @@ func TestDataPath(t *testing.T) {
}{
{
args: []string{"aerc", "templates"},
+ env: map[string]string{"XDG_DATA_HOME": ""},
expected: map[string]string{
"": "/home/user/.local/share/aerc/templates",
"darwin": "/home/user/Library/Application Support/aerc/templates",
@@ -145,6 +148,7 @@ func TestRuntimePath(t *testing.T) {
}{
{
args: []string{"aerc.sock"},
+ env: map[string]string{"XDG_RUNTIME_DIR": ""},
expected: map[string]string{
"": "/run/user/1000/aerc.sock",
"darwin": "/home/user/Library/Application Support/aerc.sock",
--
2.41.0
Robin Jarry, Aug 29, 2023 at 09:47:
> When any XDG_*_HOME or XDG_RUNTIME_DIR variables are set, this causes
> test failures.
>
> FAIL: TestConfigPath//home/user/Library/Preferences/aerc/accounts.conf (0.00s)
> xdg_test.go:86: got "/Users/vitaly/.config/aerc/accounts.conf"
> expected "/home/user/Library/Preferences/aerc/accounts.conf"
>
> Avoid leaking the local user's environment in the unit tests. Always
> override the XDG_* variables.
>
> Fixes: fff16640ad7c ("xdg: add functions to deal with user home paths")
> Reported-by: Vitaly Ovchinnikov <v@postbox.nz>
> Signed-off-by: Robin Jarry <robin@jarry.cc>
Hi Vitaly,
did you test this on macos?
> did you test this on macos?
Never tried applying a patch before, sorry :)
Got this one a try and can confirm that the current master without the
patch fails `go test ./...` and the patched version passes it.
Tested-by: Vitaly Ovchinnikov <v@postbox.nz>
Is the above line correct?
Vitaly Ovchinnikov, Sep 19, 2023 at 18:06:
> > did you test this on macos?
>
> Never tried applying a patch before, sorry :)
>
> Got this one a try and can confirm that the current master without the
> patch fails `go test ./...` and the patched version passes it.
>
> Tested-by: Vitaly Ovchinnikov <v@postbox.nz>
>
> Is the above line correct?
Yes, perfect :)
Applied. Thanks!