Files
HealthLog/src/__tests__/fast-check-runs-factor.test.ts
T
Marc-André Bombeck 298515d156 ci: fail the mutation floors step, and scale nightly property runs by a factor
The floors step piped scripts/mutation-floors.mjs into tee without
pipefail, so it took tee's exit status and a module under its floor could
never fail the run. It now runs under bash with pipefail, as do the other
steps that pipe into tee, and a guard reads every workflow and fails on a
tee pipe without it. The other piped steps were checked: each either
validates what the pipe produced or pipes a command that cannot fail.

The nightly runs set FC_NUM_RUNS, an absolute count that replaced every
property's own: the database backup round trip, which states twelve cases
for its cost, ran a hundred times against a timeout sized for twelve.
FC_RUNS_FACTOR now multiplies each property's count (five for the unit
suite, four for integration), propertyTimeout grows a test's timeout by
the same factor, and the backup round trip uses it.
2026-10-22 19:04:20 +02:00

40 lines
1.4 KiB
TypeScript

/**
* The nightly property runs multiply each property's own case count instead
* of replacing it. A nightly count of 100 for every property ran the backup
* round trip, which states twelve cases for its cost, eight times over
* against a timeout sized for twelve.
*/
import { afterEach, describe, expect, it, vi } from "vitest";
async function loadWith(factor: string | undefined) {
vi.resetModules();
if (factor === undefined) vi.stubEnv("FC_RUNS_FACTOR", "");
else vi.stubEnv("FC_RUNS_FACTOR", factor);
return import("../../tests/property/fast-check");
}
afterEach(() => {
vi.unstubAllEnvs();
});
describe("FC_RUNS_FACTOR", () => {
it("keeps each property's own count on a pull request", async () => {
const { propertyParameters, propertyTimeout } = await loadWith(undefined);
expect(propertyParameters(12).numRuns).toBe(12);
expect(propertyParameters().numRuns).toBe(100);
expect(propertyTimeout(60_000)).toBe(60_000);
});
it("multiplies each property's count and the timeout it was given", async () => {
const { propertyParameters, propertyTimeout } = await loadWith("4");
expect(propertyParameters(12).numRuns).toBe(48);
expect(propertyParameters(300).numRuns).toBe(1200);
expect(propertyTimeout(60_000)).toBe(240_000);
});
it("ignores a value that is not a positive number", async () => {
const { propertyParameters } = await loadWith("-3");
expect(propertyParameters(12).numRuns).toBe(12);
});
});