From b0609202014b9e80c3d951aa97adb895c7902b4e Mon Sep 17 00:00:00 2001 From: Tuomas Katila Date: Fri, 27 Sep 2024 14:54:55 +0300 Subject: [PATCH] labeler: fix false-failure with nfd file removal test Signed-off-by: Tuomas Katila --- cmd/internal/labeler/labeler_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/internal/labeler/labeler_test.go b/cmd/internal/labeler/labeler_test.go index deca2df78..f1e71e8bd 100644 --- a/cmd/internal/labeler/labeler_test.go +++ b/cmd/internal/labeler/labeler_test.go @@ -773,7 +773,11 @@ func TestCreateAndRun(t *testing.T) { // Wait for the labeling timeout to trigger if !waitForFileOp(root, nfdLabelBase, fsnotify.Remove, time.Second*2) { - t.Error("Run didn't remove label file") + // It's possible that removal happened before we started waiting. + // Only fail the test if the file still exists. + if _, err := os.Stat(nfdLabelFile); err == nil { + t.Error("Run didn't remove label file") + } } }) }