Skip to content

Commit

Permalink
deflake test
Browse files Browse the repository at this point in the history
  • Loading branch information
mceachen committed Jan 9, 2025
1 parent 5144026 commit 33acf40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/async.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { jest } from "@jest/globals";
import { times } from "./array.js";
import { delay, mapConcurrent, TimeoutError, withTimeout } from "./async.js";
import { isArm } from "./platform.js";
import { DayMs, HourMs } from "./units.js";

describe("async", () => {
Expand Down Expand Up @@ -395,7 +396,8 @@ describe("async", () => {
maxConcurrency,
});
expect(results).toEqual(times(10, (i) => i * 2));
expect(Date.now() - start).toBeLessThan(200); // Should complete concurrently
// This should complete in ~100ms, but GHA runners are slow -- the alpine ARM runner took 243ms (!!)
expect(Date.now() - start).toBeLessThan(isArm ? 250 : 200);
});

it("should maintain proper order even with varying execution times", async () => {
Expand Down
10 changes: 5 additions & 5 deletions src/platform.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// src/platform.ts

import { platform } from "node:os";
import { arch, platform } from "node:process";

const p = platform();
export const isLinux = platform === "linux";
export const isWindows = platform === "win32";
export const isMacOS = platform === "darwin";

export const isLinux = p === "linux";
export const isWindows = p === "win32";
export const isMacOS = p === "darwin";
export const isArm = isLinux && arch.startsWith("arm");

0 comments on commit 33acf40

Please sign in to comment.