mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
b15121ffc8
* test(ios): add snapshot convergence evidence harness * fix(ios): satisfy benchmark CI guards * fix(ios): constrain benchmark proxy routes * fix(ios-benchmark): enforce cell admission evidence * fix(ios-benchmark): protect benchmark state ownership * fix(ios-benchmark): use proxy port flag * fix(ios-benchmark): let proxy choose an ephemeral port * test(ios-benchmark): keep CLI process seam local * fix(ios-benchmark): parse proxy startup envelope * fix(ios-benchmark): bind proxy lease to simulator * fix(ios-benchmark): keep fresh proxy CLI sessions isolated * fix(ios-benchmark): preserve async timeout evidence * docs(ios-benchmark): retain exact-head evidence * test(ios): reveal offscreen alert fixture controls * test(ios): reset alert between relaunch samples * test(ios): admit native alert snapshots * docs(ios): publish snapshot convergence corpus * chore(ios): format benchmark evidence * fix(ios-benchmark): admit proxy fixture anchors * docs(ios): republish exact-head benchmark corpus * fix(size): make publish asset evidence hermetic * style(size): format package evidence test * test(size): update publish preparation contracts * fix: retire stale utils layering zone * test: pin shared publish asset owner * test: verify preserved size reporter closure * fix: move mutation ownership to snapshot module * test(ios): add snapshot convergence evidence harness * fix(ios): satisfy benchmark CI guards * fix(ios): constrain benchmark proxy routes * fix(ios-benchmark): enforce cell admission evidence * fix(ios-benchmark): protect benchmark state ownership * fix(ios-benchmark): use proxy port flag * fix(ios-benchmark): let proxy choose an ephemeral port * test(ios-benchmark): keep CLI process seam local * fix(ios-benchmark): parse proxy startup envelope * fix(ios-benchmark): bind proxy lease to simulator * fix(ios-benchmark): keep fresh proxy CLI sessions isolated * fix(ios-benchmark): preserve async timeout evidence * docs(ios-benchmark): retain exact-head evidence * test(ios): reveal offscreen alert fixture controls * test(ios): reset alert between relaunch samples * test(ios): admit native alert snapshots * docs(ios): publish snapshot convergence corpus * chore(ios): format benchmark evidence * fix(ios-benchmark): admit proxy fixture anchors * docs(ios): republish exact-head benchmark corpus * fix(size): make publish asset evidence hermetic * test(size): update publish preparation contracts * fix: keep git-state gates out of mutation sandboxes
95 lines
4.0 KiB
TypeScript
95 lines
4.0 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { test } from 'node:test';
|
|
import { fileURLToPath } from 'node:url';
|
|
import {
|
|
affectedModules,
|
|
ALL_MODULE_IDS,
|
|
isKernelTestFile,
|
|
KERNEL_MODULES,
|
|
moduleForFile,
|
|
mutateGlobs,
|
|
shardMatrix,
|
|
} from './modules.ts';
|
|
|
|
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
|
|
|
|
test('every enumerated kernel path exists', () => {
|
|
for (const module of KERNEL_MODULES) {
|
|
for (const owned of module.owns) {
|
|
assert.ok(
|
|
fs.existsSync(path.join(repoRoot, owned)),
|
|
`${module.id} owns a path that no longer exists: ${owned}`,
|
|
);
|
|
}
|
|
}
|
|
});
|
|
|
|
test('changed sources map onto the module that owns them', () => {
|
|
assert.equal(moduleForFile('packages/kernel/src/errors.ts'), 'kernel-errors');
|
|
assert.equal(moduleForFile('./src/daemon/ref-frame.ts'), 'daemon-ref-frame');
|
|
assert.equal(moduleForFile('packages/selectors/src/internal/parse.ts'), 'selectors');
|
|
// Selector tests live under the owned prefix; every other kernel's tests are
|
|
// attributed by ownership.ts, not by this path match.
|
|
assert.equal(moduleForFile('packages/selectors/src/internal/resolve.test.ts'), 'selectors');
|
|
assert.equal(moduleForFile('packages/kernel/src/rect.ts'), undefined);
|
|
assert.equal(moduleForFile('README.md'), undefined);
|
|
});
|
|
|
|
test('affected selection is deduplicated and registry-ordered', () => {
|
|
assert.deepEqual(
|
|
affectedModules([
|
|
'packages/selectors/src/internal/parse.ts',
|
|
'packages/selectors/src/internal/match.ts',
|
|
'packages/kernel/src/errors.ts',
|
|
'docs/agents/testing.md',
|
|
]),
|
|
['kernel-errors', 'selectors'],
|
|
);
|
|
assert.deepEqual(affectedModules(['docs/agents/testing.md']), []);
|
|
});
|
|
|
|
test('mutate globs default to every module and narrow on request', () => {
|
|
assert.deepEqual(mutateGlobs(), mutateGlobs(ALL_MODULE_IDS));
|
|
assert.deepEqual(mutateGlobs(['kernel-errors']), ['packages/kernel/src/errors.ts']);
|
|
});
|
|
|
|
// One job per module is only affordable while a module fits the lane's budget;
|
|
// the shard count is registry data so the workflows and the runner agree on it.
|
|
test('the shard matrix slices only the modules that declare shards', () => {
|
|
assert.deepEqual(shardMatrix(['kernel-errors']), [
|
|
{ name: 'kernel-errors', module: 'kernel-errors' },
|
|
]);
|
|
assert.deepEqual(shardMatrix(['selectors']), [
|
|
{ name: 'selectors-1', module: 'selectors', shard: '1/4' },
|
|
{ name: 'selectors-2', module: 'selectors', shard: '2/4' },
|
|
{ name: 'selectors-3', module: 'selectors', shard: '3/4' },
|
|
{ name: 'selectors-4', module: 'selectors', shard: '4/4' },
|
|
]);
|
|
assert.equal(shardMatrix().length, ALL_MODULE_IDS.length + 3);
|
|
// Every registry module reaches the matrix: an unsharded sweep is not a sweep.
|
|
for (const id of ALL_MODULE_IDS) {
|
|
assert.ok(
|
|
shardMatrix().some((spec) => spec.module === id),
|
|
`${id} has no shard`,
|
|
);
|
|
}
|
|
});
|
|
|
|
test('a kernel test is reachable only under root or package src', () => {
|
|
// Load-bearing for where repository-structure gates live. They measure the repository's own
|
|
// tracked files and Git history, which Stryker's sandbox copy cannot answer, so they sit in
|
|
// `scripts/__tests__/` (explicitly included by `unit-core`) and this predicate keeps them out of
|
|
// every mutation lane. Widening the pattern to scripts/ would silently pull them back in and
|
|
// fail every dry run.
|
|
assert.ok(isKernelTestFile('src/daemon/__tests__/ref-frame.test.ts'));
|
|
assert.ok(isKernelTestFile('packages/selectors/src/parse.test.ts'));
|
|
assert.ok(!isKernelTestFile('scripts/__tests__/test-file-size-ratchet.test.ts'));
|
|
assert.ok(!isKernelTestFile('scripts/__tests__/eager-closure-budgets.test.ts'));
|
|
assert.ok(fs.existsSync(path.join(repoRoot, 'scripts/__tests__/eager-closure-budgets.test.ts')));
|
|
assert.ok(!fs.existsSync(path.join(repoRoot, 'src/__tests__/eager-closure-budgets.test.ts')));
|
|
assert.ok(!isKernelTestFile('test/integration/daemon.test.ts'));
|
|
assert.ok(!isKernelTestFile('src/daemon/ref-frame.ts'));
|
|
});
|