mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-11-18 09:43:04 +00:00
fix: exclude retry tests from scenario traces
This commit is contained in:
parent
bb2c01a470
commit
9e61adb2d5
4 changed files with 58 additions and 8 deletions
|
|
@ -89,6 +89,31 @@ import {
|
|||
const temps: string[] = [];
|
||||
|
||||
describe('trace selection', () => {
|
||||
it.each(['none', 'possible-duplicates', 'all'] as const)(
|
||||
'excludes configured retries from %s traces even when coverage passed',
|
||||
(mutation) => {
|
||||
const pairs = [
|
||||
{ a: 'a', b: 'b' },
|
||||
{ a: 'a', b: 'retry' },
|
||||
{ a: 'a', b: 'failed' },
|
||||
{ a: 'a', b: 'failed-retry' },
|
||||
];
|
||||
expect(
|
||||
passingTracePairs(
|
||||
[
|
||||
{ id: 'a', state: 'passed', retry: 0 },
|
||||
{ id: 'b', state: 'passed' },
|
||||
{ id: 'retry', state: 'passed', retry: 1 },
|
||||
{ id: 'failed', state: 'failed' },
|
||||
{ id: 'failed-retry', state: 'failed', retry: 2 },
|
||||
],
|
||||
pairs,
|
||||
mutation,
|
||||
),
|
||||
).toEqual(mutation === 'all' ? [pairs[0], pairs[2]] : [pairs[0]]);
|
||||
},
|
||||
);
|
||||
|
||||
it('keeps non-passing coverage tests out of the shared trace without losing valid pairs', () => {
|
||||
const pairs = [
|
||||
{ a: 'a', b: 'b' },
|
||||
|
|
|
|||
|
|
@ -351,6 +351,20 @@ describe('isNativeEntry', () => {
|
|||
});
|
||||
|
||||
describe('buildWorkFile: concurrent and unrun tests', () => {
|
||||
it.each([
|
||||
{ retry: undefined, expected: 0 },
|
||||
{ retry: 0, expected: 0 },
|
||||
{ retry: 1, expected: 1 },
|
||||
{ retry: { count: 2 }, expected: 2 },
|
||||
{ retry: {}, expected: 0 },
|
||||
])(
|
||||
'records configured retries ($retry) independently of observed attempts',
|
||||
({ retry, expected }) => {
|
||||
const file = work([], [rt('t', 't', 3, { retry })]);
|
||||
expect(file.tests[0]).toMatchObject({ state: 'passed', retry: expected, attempts: 0 });
|
||||
},
|
||||
);
|
||||
|
||||
const record = new FileRun()
|
||||
.load()
|
||||
.start('c1', ['f'], [], true)
|
||||
|
|
|
|||
|
|
@ -141,6 +141,8 @@ export interface CoverageTest {
|
|||
location: TestLocation | null;
|
||||
state: TestState;
|
||||
concurrent: boolean;
|
||||
/** Configured retries, even if no retry ran; absent in older version 1 work files. */
|
||||
retry?: number;
|
||||
attempts: number;
|
||||
blocks: number[];
|
||||
suiteBlocks: number[];
|
||||
|
|
@ -173,6 +175,7 @@ export interface RuntimeTest {
|
|||
location: TestLocation | undefined;
|
||||
state: TestState;
|
||||
concurrent: boolean;
|
||||
retry?: number | { count?: number };
|
||||
}
|
||||
|
||||
/** One test file's collected tests, in collection order. */
|
||||
|
|
@ -367,6 +370,7 @@ export function buildWorkFile(input: WorkFileInput): CoverageWorkFile {
|
|||
location: test.location ?? null,
|
||||
state: test.state,
|
||||
concurrent,
|
||||
retry: typeof test.retry === 'number' ? test.retry : (test.retry?.count ?? 0),
|
||||
attempts,
|
||||
};
|
||||
if (raw === undefined || rawTest === undefined || attempts === 0) {
|
||||
|
|
@ -691,6 +695,7 @@ export async function runCoverage(options: CoverageOptions): Promise<CoverageRun
|
|||
location: test.location,
|
||||
state: test.result().state,
|
||||
concurrent: test.options.concurrent === true,
|
||||
retry: test.options.retry,
|
||||
})),
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -3006,13 +3006,21 @@ export interface ValueFlowStageOptions {
|
|||
concurrency: number | null;
|
||||
}
|
||||
|
||||
/** A failed Layer 1 test already makes its fingerprint pairs inconclusive. */
|
||||
/**
|
||||
* Retries make a trace inconclusive even when coverage passed. Full mutation runs still admit
|
||||
* non-passing tests to investigate order dependence; fingerprint runs cannot promote them.
|
||||
*/
|
||||
export function passingTracePairs<T extends { a: string; b: string }>(
|
||||
tests: readonly Pick<CoverageTest, 'id' | 'state'>[],
|
||||
tests: readonly Pick<CoverageTest, 'id' | 'state' | 'retry'>[],
|
||||
pairs: readonly T[],
|
||||
mutation: MutationScope = 'none',
|
||||
): T[] {
|
||||
const passed = new Set(tests.filter((test) => test.state === 'passed').map((test) => test.id));
|
||||
return pairs.filter((pair) => passed.has(pair.a) && passed.has(pair.b));
|
||||
const eligible = new Set(
|
||||
tests
|
||||
.filter((test) => (mutation === 'all' || test.state === 'passed') && (test.retry ?? 0) === 0)
|
||||
.map((test) => test.id),
|
||||
);
|
||||
return pairs.filter((pair) => eligible.has(pair.a) && eligible.has(pair.b));
|
||||
}
|
||||
|
||||
/** The value-flow stage; see the module comment. */
|
||||
|
|
@ -3129,11 +3137,9 @@ export async function runValueFlowStage(
|
|||
}
|
||||
|
||||
const traceStarted = ctx.now();
|
||||
// Full mutation runs still investigate order-dependent tests that fail Layer 1's repeats.
|
||||
// Fingerprint runs cannot promote those pairs; do not let them invalidate every other trace.
|
||||
const tracePairs = plan.mutation === 'all' ? equal : passingTracePairs(work.tests, equal);
|
||||
const tracePairs = passingTracePairs(work.tests, equal, plan.mutation);
|
||||
log(
|
||||
`value-flow: tracing ${tracePairs.length} pairs (${equal.length - tracePairs.length} non-passing pairs left inconclusive)`,
|
||||
`value-flow: tracing ${tracePairs.length} pairs (${equal.length - tracePairs.length} ineligible pairs left inconclusive)`,
|
||||
);
|
||||
const trace = await runTrace({
|
||||
repoRoot,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue