aboutsummaryrefslogtreecommitdiffstats
path: root/watcher_test.go
diff options
context:
space:
mode:
authorBernhard Guillon <Bernhard.Guillon@begu.org>2026-07-07 09:03:31 +0200
committerBernhard Guillon <Bernhard.Guillon@begu.org>2026-07-07 09:03:31 +0200
commita0d157d45c5b4c63afc2cfc82bde3ae3207bc455 (patch)
treec6152cf56c437945359a3b80fc16b76e9ba7332a /watcher_test.go
parente4c2f78abe427d9fdbfb46bb205f2210a03704fa (diff)
downloadsourcewatch-a0d157d45c5b4c63afc2cfc82bde3ae3207bc455.tar.gz
sourcewatch-a0d157d45c5b4c63afc2cfc82bde3ae3207bc455.zip
Add Windows native watcher with Unix socket IPC
Architecture: - Windows binary: watches files via ReadDirectoryChangesW (fsnotify), sends events as newline-delimited JSON over Unix domain socket - Container: performs initial sync, then listens on socket for events from Windows watcher New files: - cmd_windows.go: Windows serve command (watcher + socket server) - cmd_linux.go: Linux socket client + event listener - types.go: shared FileEvent, FileMeta, Manifest types - watcher_test_helper.go: inotify-based watcher for integration tests Changes: - main.go: simplified to just call run() - watcher.go: removed fsnotify dependency, extracted Watcher interface - sync.go: removed duplicate type definitions - watcher_test.go: uses watchForTests() helper Usage: sourcewatch.exe -dir C:\myproject -socket D:\sourcewatch.sock docker run -v D:\sourcewatch.sock:/run/sourcewatch.sock \ -v C:\myproject:/host:ro -v mydata:/data sourcewatch
Diffstat (limited to 'watcher_test.go')
-rw-r--r--watcher_test.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/watcher_test.go b/watcher_test.go
index df16930..56f9697 100644
--- a/watcher_test.go
+++ b/watcher_test.go
@@ -20,7 +20,7 @@ func TestWatcher_Create(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
- go watch(ctx, host, data, manifest, stack, false)
+ go watchForTests(ctx, host, data, manifest, stack, false)
time.Sleep(100 * time.Millisecond)
@@ -42,7 +42,7 @@ func TestWatcher_CreateInSubdir(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
- go watch(ctx, host, data, manifest, stack, false)
+ go watchForTests(ctx, host, data, manifest, stack, false)
time.Sleep(100 * time.Millisecond)
@@ -66,7 +66,7 @@ func TestWatcher_Write(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
- go watch(ctx, host, data, manifest, stack, false)
+ go watchForTests(ctx, host, data, manifest, stack, false)
time.Sleep(100 * time.Millisecond)
@@ -90,7 +90,7 @@ func TestWatcher_Remove(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
- go watch(ctx, host, data, manifest, stack, false)
+ go watchForTests(ctx, host, data, manifest, stack, false)
time.Sleep(100 * time.Millisecond)
@@ -114,7 +114,7 @@ func TestWatcher_Rename(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
- go watch(ctx, host, data, manifest, stack, false)
+ go watchForTests(ctx, host, data, manifest, stack, false)
time.Sleep(100 * time.Millisecond)
@@ -139,7 +139,7 @@ func TestWatcher_IgnoredFileEvents(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
- go watch(ctx, host, data, manifest, stack, false)
+ go watchForTests(ctx, host, data, manifest, stack, false)
time.Sleep(100 * time.Millisecond)
@@ -167,7 +167,7 @@ func TestWatcher_Debouncing(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
- go watch(ctx, host, data, manifest, stack, false)
+ go watchForTests(ctx, host, data, manifest, stack, false)
time.Sleep(100 * time.Millisecond)
@@ -199,7 +199,7 @@ func TestWatcher_CreateDirectory(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
- go watch(ctx, host, data, manifest, stack, false)
+ go watchForTests(ctx, host, data, manifest, stack, false)
time.Sleep(100 * time.Millisecond)
@@ -229,7 +229,7 @@ func TestWatcher_RemoveDirectory(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
- go watch(ctx, host, data, manifest, stack, false)
+ go watchForTests(ctx, host, data, manifest, stack, false)
time.Sleep(100 * time.Millisecond)
@@ -255,7 +255,7 @@ func TestWatcher_VerifyManifestUpdated(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
- go watch(ctx, host, data, manifest, stack, false)
+ go watchForTests(ctx, host, data, manifest, stack, false)
time.Sleep(100 * time.Millisecond)
@@ -282,7 +282,7 @@ func TestWatcher_NestedGitignore_CreateIgnored(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
- go watch(ctx, host, data, manifest, stack, false)
+ go watchForTests(ctx, host, data, manifest, stack, false)
time.Sleep(100 * time.Millisecond)
@@ -310,7 +310,7 @@ func TestWatcher_NestedGitignore_CreateUnignore(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
- go watch(ctx, host, data, manifest, stack, false)
+ go watchForTests(ctx, host, data, manifest, stack, false)
time.Sleep(100 * time.Millisecond)
@@ -332,7 +332,7 @@ func TestWatcher_CreateSymlink(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
- go watch(ctx, host, data, manifest, stack, false)
+ go watchForTests(ctx, host, data, manifest, stack, false)
time.Sleep(100 * time.Millisecond)
@@ -382,7 +382,7 @@ func TestWatcher_UpdateSymlinkTarget(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
- go watch(ctx, host, data, manifest, stack, false)
+ go watchForTests(ctx, host, data, manifest, stack, false)
time.Sleep(100 * time.Millisecond)
@@ -421,7 +421,7 @@ func TestWatcher_RemoveSymlink(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
- go watch(ctx, host, data, manifest, stack, false)
+ go watchForTests(ctx, host, data, manifest, stack, false)
time.Sleep(100 * time.Millisecond)
@@ -447,7 +447,7 @@ func TestWatcher_ModifySymlinkTargetFile(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
- go watch(ctx, host, data, manifest, stack, false)
+ go watchForTests(ctx, host, data, manifest, stack, false)
time.Sleep(100 * time.Millisecond)