test: capture remaining checkout race regressions
ci/woodpecker/pr/ci Pipeline failed

This commit is contained in:
mosaic-coder
2026-07-31 17:50:58 -05:00
parent a0209ee102
commit ece7653ca0
3 changed files with 67 additions and 8 deletions
+20 -8
View File
@@ -3,7 +3,7 @@ import { chmod, mkdir, rm, symlink, utimes, writeFile } from 'node:fs/promises';
import path from 'node:path';
import test from 'node:test';
import { runPreflight } from './preflight.mjs';
import { runPreflight, sourceFingerprint } from './preflight.mjs';
const fixtureRoot = path.join(process.cwd(), '.mosaic-test-work', `preflight-${process.pid}`);
@@ -83,18 +83,13 @@ test('foreign-owned generated Next state is identified separately from source er
assert.match(result.message, /foreign-owned/);
});
test('stale generated Next state is identified separately from source errors', async () => {
test('a generated marker mismatch is identified separately from source errors', async () => {
const root = await fixture('stale-next');
await installRequiredBins(root);
const generated = path.join(root, 'apps', 'web', '.next', 'types', 'validator.ts');
await mkdir(path.dirname(generated), { recursive: true });
await writeFile(generated, 'stale generated output');
const old = new Date('2020-01-01T00:00:00Z');
await utimes(generated, old, old);
const fresh = path.join(root, 'apps', 'web', '.next', 'types', 'routes.ts');
await writeFile(fresh, 'fresh generated output');
const future = new Date('2030-01-01T00:00:00Z');
await utimes(fresh, future, future);
await writeFile(path.join(root, 'apps', 'web', '.next', '.mosaic-source-hash'), 'old-source');
const result = await runPreflight({ root });
assert.equal(result.code, 43);
@@ -102,3 +97,20 @@ test('stale generated Next state is identified separately from source errors', a
assert.match(result.message, /apps\/web\/\.next/);
assert.match(result.message, /pnpm clean:generated/);
});
test('a matching generation marker accepts incremental output with mixed mtimes', async () => {
const root = await fixture('incremental-next');
await installRequiredBins(root);
const generated = path.join(root, 'apps', 'web', '.next', 'types', 'validator.ts');
await mkdir(path.dirname(generated), { recursive: true });
await writeFile(generated, 'unchanged generated output');
await utimes(generated, new Date('2020-01-01T00:00:00Z'), new Date('2020-01-01T00:00:00Z'));
const fresh = path.join(root, 'apps', 'web', '.next', 'types', 'routes.ts');
await writeFile(fresh, 'fresh generated output');
await writeFile(
path.join(root, 'apps', 'web', '.next', '.mosaic-source-hash'),
await sourceFingerprint(root),
);
assert.deepEqual(await runPreflight({ root }), { code: 0, message: 'checkout preflight passed' });
});