diff --git a/test/bake/dev/vim-file-swap.test.ts b/test/bake/dev/vim-file-swap.test.ts index 639a821e8c..8a14b8940b 100644 --- a/test/bake/dev/vim-file-swap.test.ts +++ b/test/bake/dev/vim-file-swap.test.ts @@ -2,10 +2,14 @@ import { expect } from "bun:test"; import * as fs from "node:fs"; import * as path from "node:path"; import { devTest } from "../bake-harness"; +import { isWindows } from "harness"; -devTest("vim file swap hot reload for entrypoints", { - files: { - "index.html": ` +// skip on windows due to EPERM issues since we use libuv for uv_fs_rename and +// it doesn't appaer to use posix semantics +if (!isWindows) { + devTest("vim file swap hot reload for entrypoints", { + files: { + "index.html": ` Test @@ -13,20 +17,20 @@ devTest("vim file swap hot reload for entrypoints", {

Test foo

`, - "index.ts": ``, - }, - async test(dev) { - await using c = await dev.client("/"); + "index.ts": ``, + }, + async test(dev) { + await using c = await dev.client("/"); - // Verify initial load works - const initialResponse = await dev.fetch("/"); - expect(initialResponse.status).toBe(200); - const initialText = await initialResponse.text(); - expect(initialText).toContain("Test foo"); + // Verify initial load works + const initialResponse = await dev.fetch("/"); + expect(initialResponse.status).toBe(200); + const initialText = await initialResponse.text(); + expect(initialText).toContain("Test foo"); - // Simulate vim-style file editing multiple times to increase reliability - for (let i = 0; i < 3; i++) { - const updatedContent = ` + // Simulate vim-style file editing multiple times to increase reliability + for (let i = 0; i < 3; i++) { + const updatedContent = ` Test @@ -35,25 +39,26 @@ devTest("vim file swap hot reload for entrypoints", { `; - // Step 1: Create .index.html.swp file with new content - const swapFile = path.join(dev.rootDir, ".index.html.swp"); - await Bun.file(swapFile).write(updatedContent); + // Step 1: Create .index.html.swp file with new content + const swapFile = path.join(dev.rootDir, ".index.html.swp"); + await Bun.file(swapFile).write(updatedContent); - // Step 2: Delete original index.html - const originalFile = path.join(dev.rootDir, "index.html"); - fs.unlinkSync(originalFile); + // Step 2: Delete original index.html + const originalFile = path.join(dev.rootDir, "index.html"); + fs.unlinkSync(originalFile); - // Step 3: Rename .index.html.swp to index.html (atomic operation) - fs.renameSync(swapFile, originalFile); + // Step 3: Rename .index.html.swp to index.html (atomic operation) + fs.renameSync(swapFile, originalFile); - // Wait a bit for file watcher to detect changes - await new Promise(resolve => setTimeout(resolve, 100)); + // Wait a bit for file watcher to detect changes + await new Promise(resolve => setTimeout(resolve, 100)); - // Verify the content was updated - const response = await dev.fetch("/"); - expect(response.status).toBe(200); - const text = await response.text(); - expect(text).toContain(`Test bar ${i + 1}`); - } - }, -}); + // Verify the content was updated + const response = await dev.fetch("/"); + expect(response.status).toBe(200); + const text = await response.text(); + expect(text).toContain(`Test bar ${i + 1}`); + } + }, + }); +}