diff --git a/src/executor.spec.ts b/src/executor.spec.ts index 11281d2..28766ef 100644 --- a/src/executor.spec.ts +++ b/src/executor.spec.ts @@ -6,6 +6,7 @@ import * as executor from "./executor"; import { createConverter } from "./converter"; import { createConverterWithFileWatcher, + isPerformanceUnstableEnv, isTsWatchBroken, runInTmpAsync, WaitFileEventFunc, @@ -392,8 +393,9 @@ describe("execute", () => { end = Date.now(); let t1 = end - start; expect(ex.locals.got).toBe(want); - expect(t1 / t0).toBeGreaterThan(0.5); - expect(t0 / t1).toBeGreaterThan(0.5); + const threshold = isPerformanceUnstableEnv() ? 0.1 : 0.5; + expect(t1 / t0).toBeGreaterThan(threshold); + expect(t0 / t1).toBeGreaterThan(threshold); }); it("overhead", async () => { diff --git a/src/testutil.ts b/src/testutil.ts index dd8aace..23fb38e 100644 --- a/src/testutil.ts +++ b/src/testutil.ts @@ -87,3 +87,11 @@ export function createConverterWithFileWatcher(): { export function isTsWatchBroken(): boolean { return os.platform() === "darwin" && process.env.GITHUB_ACTIONS === "true"; } + +/** + * Performance tests on Mac eivnronment on GitHub Actions sometimes fail. + * @returns + */ +export function isPerformanceUnstableEnv(): boolean { + return os.platform() === "darwin" && process.env.GITHUB_ACTIONS === "true"; +}