From 2d5338f0b57f285f4f2c9e8850305a78d1c83e3e Mon Sep 17 00:00:00 2001 From: "John K. Luebs" Date: Sat, 7 Oct 2023 21:05:19 -0500 Subject: [PATCH] Fix TestEntryExcludeByAttribute on linux Modern linux distros often make /tmp a tmpfs which does not support xattrs, so this test will fail. --- src/duplicacy_entry_test.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/duplicacy_entry_test.go b/src/duplicacy_entry_test.go index 7b07910..c87259e 100644 --- a/src/duplicacy_entry_test.go +++ b/src/duplicacy_entry_test.go @@ -249,10 +249,16 @@ func TestEntryExcludeByAttribute(t *testing.T) { t.Skip("skipping test, not darwin, linux, freebsd, or netbsd") } - testDir := filepath.Join(os.TempDir(), "duplicacy_test") - - os.RemoveAll(testDir) - os.MkdirAll(testDir, 0700) + tmpDir := "" + // on linux TempDir is usually a tmpfs which does not support xattrs + if runtime.GOOS == "linux" { + tmpDir = "." + } + testDir, err := os.MkdirTemp(tmpDir, "duplicacy_test") + if err != nil { + t.Errorf("Mkdirtmp() failed: %v", err) + return + } // Files or folders named with "exclude" below will have the exclusion attribute set on them // When ListEntries is called with excludeByAttribute true, they should be excluded. @@ -356,10 +362,9 @@ func TestEntryExcludeByAttribute(t *testing.T) { } - if !t.Failed() { + if tmpDir != "" || !t.Failed() { os.RemoveAll(testDir) } - } func TestEntryEncoding(t *testing.T) {