From c0b4abd81756318c6bfc702a768d7a4f6180bcbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E6=B3=BD=E8=BD=A9?= Date: Thu, 18 Jul 2024 10:14:39 +0800 Subject: [PATCH] work around fsnotify issue on Mac (#648) Signed-off-by: spacewander --- plugins/pkg/file/fs_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/pkg/file/fs_test.go b/plugins/pkg/file/fs_test.go index a49d86c6..d82ae637 100644 --- a/plugins/pkg/file/fs_test.go +++ b/plugins/pkg/file/fs_test.go @@ -16,6 +16,7 @@ package file import ( "os" + "runtime" "sync" "testing" @@ -31,7 +32,13 @@ func TestFileIsChanged(t *testing.T) { assert.Nil(t, err) - tmpfile, _ := os.CreateTemp("", "example") + var tmpfile *os.File + if runtime.GOOS == "darwin" { + // Work around https://github.com/fsnotify/fsnotify/issues/642 + tmpfile, _ = os.CreateTemp("/private/tmp", "example") + } else { + tmpfile, _ = os.CreateTemp("", "example") + } file := Stat(tmpfile.Name())