Content-Length: 318174 | pFad | http://github.com/coder/coder/pull/19081/files

4E chore(agent/agentcontainers): skip part of test if on `darwin` by DanielleMaywood · Pull Request #19081 · coder/coder · GitHub
Skip to content

chore(agent/agentcontainers): skip part of test if on darwin #19081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 28 additions & 17 deletions agent/agentcontainers/watcher/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"os"
"path/filepath"
"runtime"
"testing"

"github.com/fsnotify/fsnotify"
Expand Down Expand Up @@ -88,24 +89,34 @@ func TestFSNotifyWatcher(t *testing.T) {
break
}

err = os.WriteFile(testFile+".atomic", []byte(`{"test": "atomic"}`), 0o600)
require.NoError(t, err, "write new atomic test file failed")

err = os.Rename(testFile+".atomic", testFile)
require.NoError(t, err, "rename atomic test file failed")

// Verify that we receive the event we want.
for {
event, err := wut.Next(ctx)
require.NoError(t, err, "next event failed")
require.NotNil(t, event, "want non-nil event")
if !event.Has(fsnotify.Create) {
t.Logf("Ignoring event: %s", event)
continue
// TODO(DanielleMaywood):
// Unfortunately it appears this atomic-rename phase of the test is flakey on macOS.
//
// This test flake could be indicative of an issue that may present itself
// in a running environment. Fortunately, we only use this (as of 2025-07-29)
// for our dev container integration. We do not expect the host workspace
// (where this is used), to ever be run on macOS, as containers are a linux
// paradigm.
if runtime.GOOS != "darwin" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe fail-fast approach?

if runtime.GOOS == "darwin" {
    err = wut.Remove(testFile)
    require.NoError(t, err, "remove file from watcher failed")
    return
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies, I hit the green button a little quick.

I can see the benefit to the suggestion, although I think I prefer indenting the flakey code instead as this isn't a permanent change.

err = os.WriteFile(testFile+".atomic", []byte(`{"test": "atomic"}`), 0o600)
require.NoError(t, err, "write new atomic test file failed")

err = os.Rename(testFile+".atomic", testFile)
require.NoError(t, err, "rename atomic test file failed")

// Verify that we receive the event we want.
for {
event, err := wut.Next(ctx)
require.NoError(t, err, "next event failed")
require.NotNil(t, event, "want non-nil event")
if !event.Has(fsnotify.Create) {
t.Logf("Ignoring event: %s", event)
continue
}
require.Truef(t, event.Has(fsnotify.Create), "want create event: %s", event.String())
require.Equal(t, event.Name, testFile, "want event for test file")
break
}
require.Truef(t, event.Has(fsnotify.Create), "want create event: %s", event.String())
require.Equal(t, event.Name, testFile, "want event for test file")
break
}

// Test removing the file from the watcher.
Expand Down
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/coder/coder/pull/19081/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy