From baa8cb3bc41f9afd649e29de2e75438864e5ce83 Mon Sep 17 00:00:00 2001 From: benedict Date: Sun, 10 Sep 2023 05:43:19 +0700 Subject: [PATCH] random file for RoundTripFileWithNoSheetCols test In my test, RoundTripFileWithNoSheetCols fails with error `e"remove testdocs/after_write.xlsx: no such file or directory"` This is most likely due to the parallel test runs called by csRunO that try to write and remove the files concurrently. By choosing a random filename, each test create/write and removes its own file, the test passed as expected. --- lib_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib_test.go b/lib_test.go index 4975c148..045554a2 100644 --- a/lib_test.go +++ b/lib_test.go @@ -3,7 +3,9 @@ package xlsx import ( "bytes" "encoding/xml" + "math/rand" "os" + "strconv" "strings" "testing" @@ -1357,11 +1359,12 @@ func TestLib(t *testing.T) { csRunO(c, "RoundTripFileWithNoSheetCols", func(c *qt.C, option FileOption) { originalXlFile, err := OpenFile("testdocs/original.xlsx", option) c.Assert(err, qt.IsNil) - err = originalXlFile.Save("testdocs/after_write.xlsx") + destFile := "testdocs/" + strconv.Itoa(rand.Int()) + ".xlsx" + err = originalXlFile.Save(destFile) c.Assert(err, qt.IsNil) - _, err = OpenFile("testdocs/after_write.xlsx", option) + _, err = OpenFile(destFile) c.Assert(err, qt.IsNil) - err = os.Remove("testdocs/after_write.xlsx") + err = os.Remove(destFile) c.Assert(err, qt.IsNil) })