diff --git a/src/nightwatch_test.zig b/src/nightwatch_test.zig index 0b33985..a4917ae 100644 --- a/src/nightwatch_test.zig +++ b/src/nightwatch_test.zig @@ -311,9 +311,9 @@ test "renaming a file is reported correctly per-platform" { const th = try TestHandler.init(allocator); defer th.deinit(); - const src_path = try std.fs.path.join(allocator, &.{ tmp, "before.txt" }); + const src_path = try std.fmt.allocPrint(allocator, "{s}/before.txt", .{tmp}); defer allocator.free(src_path); - const dst_path = try std.fs.path.join(allocator, &.{ tmp, "after.txt" }); + const dst_path = try std.fmt.allocPrint(allocator, "{s}/after.txt", .{tmp}); defer allocator.free(dst_path); { @@ -361,7 +361,7 @@ test "an unwatched directory produces no events" { defer watcher.deinit(); try watcher.watch(watched); // only watch the first dir - const file_path = try std.fs.path.join(allocator, &.{ unwatched, "silent.txt" }); + const file_path = try std.fmt.allocPrint(allocator, "{s}/silent.txt", .{unwatched}); defer allocator.free(file_path); { const f = try std.fs.createFileAbsolute(file_path, .{}); @@ -390,7 +390,7 @@ test "unwatch stops delivering events for that directory" { try watcher.watch(tmp); // Create a file while watching - should be reported. - const file1 = try std.fs.path.join(allocator, &.{ tmp, "watched.txt" }); + const file1 = try std.fmt.allocPrint(allocator, "{s}/watched.txt", .{tmp}); defer allocator.free(file1); { const f = try std.fs.createFileAbsolute(file1, .{}); @@ -403,7 +403,7 @@ test "unwatch stops delivering events for that directory" { watcher.unwatch(tmp); const count_before = th.events.items.len; - const file2 = try std.fs.path.join(allocator, &.{ tmp, "after_unwatch.txt" }); + const file2 = try std.fmt.allocPrint(allocator, "{s}/after_unwatch.txt", .{tmp}); defer allocator.free(file2); { const f = try std.fs.createFileAbsolute(file2, .{}); @@ -433,9 +433,7 @@ test "multiple files created sequentially all appear in the event list" { const N = 5; var paths: [N][]u8 = undefined; for (&paths, 0..) |*p, i| { - const name = try std.fmt.allocPrint(allocator, "file{d}.txt", .{i}); - defer allocator.free(name); - p.* = try std.fs.path.join(allocator, &.{ tmp, name }); + p.* = try std.fmt.allocPrint(allocator, "{s}/file{d}.txt", .{ tmp, i }); const f = try std.fs.createFileAbsolute(p.*, .{}); f.close(); } @@ -465,9 +463,9 @@ test "rename: old-name event precedes new-name event" { const th = try TestHandler.init(allocator); defer th.deinit(); - const src_path = try std.fs.path.join(allocator, &.{ tmp, "old.txt" }); + const src_path = try std.fmt.allocPrint(allocator, "{s}/old.txt", .{tmp}); defer allocator.free(src_path); - const dst_path = try std.fs.path.join(allocator, &.{ tmp, "new.txt" }); + const dst_path = try std.fmt.allocPrint(allocator, "{s}/new.txt", .{tmp}); defer allocator.free(dst_path); { @@ -508,9 +506,9 @@ test "rename-then-modify: rename event precedes the subsequent modify event" { const th = try TestHandler.init(allocator); defer th.deinit(); - const src_path = try std.fs.path.join(allocator, &.{ tmp, "original.txt" }); + const src_path = try std.fmt.allocPrint(allocator, "{s}/original.txt", .{tmp}); defer allocator.free(src_path); - const dst_path = try std.fs.path.join(allocator, &.{ tmp, "renamed.txt" }); + const dst_path = try std.fmt.allocPrint(allocator, "{s}/renamed.txt", .{tmp}); defer allocator.free(dst_path); { diff --git a/test_manual.ps1 b/test_manual.ps1 deleted file mode 100644 index 1d65abf..0000000 --- a/test_manual.ps1 +++ /dev/null @@ -1,64 +0,0 @@ -# Manual test for nightwatch CLI. -# Usage: .\test_manual.ps1 [path-to-nightwatch-binary] -# -# Run this in one terminal. It starts nightwatch watching a temp dir, -# performs a sequence of filesystem operations, then exits. -# You should see one event per line on stdout as they happen. - -param( - [string]$NW = ".\zig-out\bin\nightwatch.exe" -) - -if (-not (Test-Path $NW)) { - Write-Error "error: binary not found: $NW" - exit 1 -} - -$TESTDIR = Join-Path $env:TEMP "nightwatch_manual_$PID" -New-Item -ItemType Directory -Path $TESTDIR | Out-Null - -Write-Host "--- watching $TESTDIR ---" -Write-Host "--- starting nightwatch (Ctrl-C to stop early) ---" -Write-Host "" - -# Start nightwatch in background, events go to stdout -$proc = Start-Process -FilePath $NW -ArgumentList $TESTDIR -NoNewWindow -PassThru -Start-Sleep -Milliseconds 500 - -Write-Host "[op] touch file1.txt" -New-Item -ItemType File -Path "$TESTDIR\file1.txt" | Out-Null -Start-Sleep -Milliseconds 400 - -Write-Host "[op] write to file1.txt" -Set-Content -Path "$TESTDIR\file1.txt" -Value "hello nightwatch" -Start-Sleep -Milliseconds 400 - -Write-Host "[op] mkdir subdir" -New-Item -ItemType Directory -Path "$TESTDIR\subdir" | Out-Null -Start-Sleep -Milliseconds 400 - -Write-Host "[op] touch subdir\file2.txt" -New-Item -ItemType File -Path "$TESTDIR\subdir\file2.txt" | Out-Null -Start-Sleep -Milliseconds 400 - -Write-Host "[op] rename file1.txt -> renamed.txt" -Rename-Item -Path "$TESTDIR\file1.txt" -NewName "renamed.txt" -Start-Sleep -Milliseconds 400 - -Write-Host "[op] delete renamed.txt" -Remove-Item -Path "$TESTDIR\renamed.txt" -Start-Sleep -Milliseconds 400 - -Write-Host "[op] delete subdir\file2.txt" -Remove-Item -Path "$TESTDIR\subdir\file2.txt" -Start-Sleep -Milliseconds 400 - -Write-Host "[op] rmdir subdir" -Remove-Item -Path "$TESTDIR\subdir" -Start-Sleep -Milliseconds 500 - -Write-Host "" -Write-Host "--- done, stopping nightwatch ---" -Stop-Process -Id $proc.Id -ErrorAction SilentlyContinue -$proc.WaitForExit() -Remove-Item -Recurse -Force -Path $TESTDIR