Skip to content

Commit

Permalink
revive dev server tests. we need to be running these
Browse files Browse the repository at this point in the history
  • Loading branch information
paperclover committed Feb 10, 2025
1 parent 14b93e2 commit 989af93
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
10 changes: 4 additions & 6 deletions src/bake/DevServer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -561,12 +561,10 @@ pub fn init(options: Options) bun.JSOOM!*DevServer {
break :router try FrameworkRouter.initEmpty(dev.root, types.items, allocator);
};

if (options.frontend_only) {
// TODO: move scanning to be one tick after server startup. this way the
// line saying the server is ready shows quicker, and route errors show up
// after that line.
try dev.scanInitialRoutes();
}
// TODO: move scanning to be one tick after server startup. this way the
// line saying the server is ready shows quicker, and route errors show up
// after that line.
try dev.scanInitialRoutes();

if (bun.FeatureFlags.bake_debugging_features and dev.has_pre_crash_handler)
try bun.crash_handler.appendPreCrashHandler(DevServer, dev, dumpStateDueToCrash);
Expand Down
2 changes: 1 addition & 1 deletion src/bun.js/api/server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7571,7 +7571,7 @@ pub fn NewServer(comptime NamespaceType: type, comptime ssl_enabled_: bool, comp
bun.assert(this.config.onRequest != .zero);
app.any("/*", *ThisServer, this, onRequest);
} else if (this.config.onRequest != .zero) {
// The HTML catch all recieves GET, HEAD, and OPTIONS
// The HTML catch-all receives GET, HEAD, and OPTIONS
app.post("/*", *ThisServer, this, onRequest);
app.put("/*", *ThisServer, this, onRequest);
app.patch("/*", *ThisServer, this, onRequest);
Expand Down
18 changes: 10 additions & 8 deletions test/bake/dev-server-harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,11 @@ function snapshotCallerLocation(): string {
let i = 1;
for (; i < lines.length; i++) {
const line = lines[i].replaceAll("\\", "/");
if (line.includes(import.meta.path.replaceAll("\\", "/"))) {
if (line.includes(import.meta.dir.replaceAll("\\", "/")) && !line.includes("dev-server-harness.ts")) {
return line;
}
}
throw new Error("Couldn't find caller location in stack trace");
throw new Error("Couldn't find caller location in stack trace:\n" + stack);
}
function stackTraceFileName(line: string): string {
let result = line.trim();
Expand Down Expand Up @@ -333,7 +333,9 @@ class OutputLineStream extends EventEmitter {
let match;
if ((match = line.match(regex))) {
reset();
resolve(match);
setTimeout(() => {
resolve(match);
}, 50);
}
};
const onClose = () => {
Expand Down Expand Up @@ -369,11 +371,11 @@ export function devTest<T extends DevServerTest>(description: string, options: T
const basename = path.basename(caller, ".test" + path.extname(caller));
const count = (counts[basename] = (counts[basename] ?? 0) + 1);

// TODO: Tests are flaky on all platforms. Disable
if (isCI) {
jest.test.todo(`DevServer > ${basename}.${count}: ${description}`);
return options;
}
// // TODO: Tests are flaky on all platforms. Disable
// if (isWindows) {
// jest.test.todo(`DevServer > ${basename}.${count}: ${description}`);
// return options;
// }

jest.test(`DevServer > ${basename}.${count}: ${description}`, async () => {
const root = path.join(tempDir, basename + count);
Expand Down

0 comments on commit 989af93

Please sign in to comment.