From 6c8802a9fbfbd7b5bf4655a772bc47c644f62ef7 Mon Sep 17 00:00:00 2001 From: dafuga Date: Mon, 30 Nov 2026 18:27:31 +0000 Subject: [PATCH 1/6] fix: reproduce test script markers in excluded Vitest paths --- .../execution-runtimes/with-mac-heavy-test-lane.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/utils/execution-runtimes/with-mac-heavy-test-lane.test.ts b/test/utils/execution-runtimes/with-mac-heavy-test-lane.test.ts index 212d4139ad8..e175a0a350d 100644 --- a/test/utils/execution-runtimes/with-mac-heavy-test-lane.test.ts +++ b/test/utils/execution-runtimes/with-mac-heavy-test-lane.test.ts @@ -25,7 +25,11 @@ test('recognizes the standard suite commands without queuing routine type checks ['/bin/sh', '-c', 'vitest run --exclude "test/**/*.e2e.test.ts" test/queue.test.ts'], ['sh', '-c', "vitest run --exclude='test/desktop e2e/*.e2e.test.ts' test/queue.test.ts"], ['vitest', 'run', '--exclude', 'test/desktop e2e/*.e2e.test.ts', 'test/queue.test.ts'], - ['vitest', 'run', '--exclude=test/**/*.e2e.test.ts', 'test/queue.test.ts'] + ['vitest', 'run', '--exclude=test/**/*.e2e.test.ts', 'test/queue.test.ts'], + ['vitest', 'run', '--exclude', 'test/fixtures/test:e2e/*.test.ts', 'test/queue.test.ts'], + ['vitest', 'run', '--exclude=test/fixtures/test:e2e/*.test.ts', 'test/queue.test.ts'], + ['sh', '-c', 'vitest run --exclude "test/fixtures/test:e2e/*.test.ts" test/queue.test.ts'], + ['/bin/sh', '-c', "vitest run --exclude='test/fixtures/test:e2e/*.test.ts' test/queue.test.ts"] ]; for (const command of unitCommands) expect(isHeavyTestCommand(command), command.join(' ')).toBe(false); From 3fbd15af2e3949736e5a22c51d843acbb1ca5fec Mon Sep 17 00:00:00 2001 From: dafuga Date: Mon, 30 Nov 2026 18:28:27 +0000 Subject: [PATCH 2/6] fix: ignore excluded paths before classifying heavy test commands --- .../withMacHeavyTestLane.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/utils/execution-runtimes/withMacHeavyTestLane.ts b/src/utils/execution-runtimes/withMacHeavyTestLane.ts index f303a00f36c..e022879e39c 100644 --- a/src/utils/execution-runtimes/withMacHeavyTestLane.ts +++ b/src/utils/execution-runtimes/withMacHeavyTestLane.ts @@ -25,16 +25,16 @@ const shellExclusion = /(^|\s)--exclude(?:=|[ \t]+)(?:"[^"\n]*"|'[^'\n]*'|[^\s;& export function isHeavyTestCommand(args: readonly string[]): boolean { if (args[0] === 'bun' && args[1] === 'scripts/run-checks.ts') return true; - if ((args[0] === 'sh' || args[0] === '/bin/sh') && args[1] === '-c') { - const script = args[2] ?? ''; - return heavyRunner.test(script) || vitestE2e.test(script.replace(shellExclusion, '$1')); - } - if (heavyRunner.test(args.join(' '))) return true; - const filters = args.filter( - (arg, index) => - arg !== '--exclude' && !arg.startsWith('--exclude=') && args[index - 1] !== '--exclude' - ); - return vitestE2e.test(filters.join(' ')); + const shell = (args[0] === 'sh' || args[0] === '/bin/sh') && args[1] === '-c'; + const command = shell + ? (args[2] ?? '').replace(shellExclusion, '$1') + : args + .filter( + (arg, index) => + arg !== '--exclude' && !arg.startsWith('--exclude=') && args[index - 1] !== '--exclude' + ) + .join(' '); + return heavyRunner.test(command) || vitestE2e.test(command); } /** Apply the same lane budget across worktrees and resource homes for the OS account. */ From 55b0b27fb72397300b0fe945f1a11de655bfa4f6 Mon Sep 17 00:00:00 2001 From: dafuga Date: Mon, 30 Nov 2026 18:33:26 +0000 Subject: [PATCH 3/6] fix: reproduce quoted Vitest exclusion options --- .../with-mac-heavy-test-lane.test.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/utils/execution-runtimes/with-mac-heavy-test-lane.test.ts b/test/utils/execution-runtimes/with-mac-heavy-test-lane.test.ts index e175a0a350d..578379e3abc 100644 --- a/test/utils/execution-runtimes/with-mac-heavy-test-lane.test.ts +++ b/test/utils/execution-runtimes/with-mac-heavy-test-lane.test.ts @@ -16,6 +16,7 @@ test('recognizes the standard suite commands without queuing routine type checks ['sh', '-c', 'bun run --cwd packages/hub check && bun run --cwd packages/hub test:e2e'], ['vitest', 'run', 'test/resources-cli.e2e.test.ts'], ['/bin/sh', '-c', "vitest run --exclude='test/desktop e2e/*.e2e.test.ts' test/cli.e2e.test.ts"], + ['sh', '-c', "vitest run '--exclude=*.e2e.test.ts' 'test/cli.e2e.test.ts'"], ['vitest', 'run', '--exclude', 'test/**/*.e2e.test.ts', 'test/cli.e2e.test.ts'] ]; expect(commands.every(isHeavyTestCommand)).toBe(true); @@ -29,7 +30,14 @@ test('recognizes the standard suite commands without queuing routine type checks ['vitest', 'run', '--exclude', 'test/fixtures/test:e2e/*.test.ts', 'test/queue.test.ts'], ['vitest', 'run', '--exclude=test/fixtures/test:e2e/*.test.ts', 'test/queue.test.ts'], ['sh', '-c', 'vitest run --exclude "test/fixtures/test:e2e/*.test.ts" test/queue.test.ts'], - ['/bin/sh', '-c', "vitest run --exclude='test/fixtures/test:e2e/*.test.ts' test/queue.test.ts"] + ['/bin/sh', '-c', "vitest run --exclude='test/fixtures/test:e2e/*.test.ts' test/queue.test.ts"], + ['sh', '-c', 'vitest run "--exclude=**/*.e2e.test.ts" test/queue.test.ts'], + [ + '/bin/sh', + '-c', + "vitest run '--exclude' 'test/fixtures/test:e2e/*.test.ts' test/queue.test.ts" + ], + ['sh', '-c', "vitest run '--exclude='test/fixtures/test:e2e/*.test.ts test/queue.test.ts"] ]; for (const command of unitCommands) expect(isHeavyTestCommand(command), command.join(' ')).toBe(false); From ed8747dd78fc8bfa6f675116a862dc23a7dd16a2 Mon Sep 17 00:00:00 2001 From: dafuga Date: Mon, 30 Nov 2026 18:34:18 +0000 Subject: [PATCH 4/6] fix: normalize quoted shell exclusions before test lane admission --- .../withMacHeavyTestLane.ts | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/utils/execution-runtimes/withMacHeavyTestLane.ts b/src/utils/execution-runtimes/withMacHeavyTestLane.ts index e022879e39c..5a2c85de217 100644 --- a/src/utils/execution-runtimes/withMacHeavyTestLane.ts +++ b/src/utils/execution-runtimes/withMacHeavyTestLane.ts @@ -21,22 +21,32 @@ const lockBusy = 75; // The runner argv and shell scripts used by Harness package commands. const heavyRunner = /\bplaywright\s+test\b|\btest:(?:e2e|native|package|all)\b/; const vitestE2e = /\bvitest\s+run\b[^;\n&|]*\.e2e\.test\./; -const shellExclusion = /(^|\s)--exclude(?:=|[ \t]+)(?:"[^"\n]*"|'[^'\n]*'|[^\s;&|]+)/g; +const shellToken = /(?:\\.|"(?:\\.|[^"\\])*"|'[^']*'|[^\s"'\\;&|])+|[\n;&|]/g; +const shellQuotes = /\\(.)|"((?:\\.|[^"\\])*)"|'([^']*)'/g; export function isHeavyTestCommand(args: readonly string[]): boolean { if (args[0] === 'bun' && args[1] === 'scripts/run-checks.ts') return true; const shell = (args[0] === 'sh' || args[0] === '/bin/sh') && args[1] === '-c'; - const command = shell - ? (args[2] ?? '').replace(shellExclusion, '$1') - : args - .filter( - (arg, index) => - arg !== '--exclude' && !arg.startsWith('--exclude=') && args[index - 1] !== '--exclude' - ) - .join(' '); + const words = shell ? shellCommandWords(args[2] ?? '') : args; + const command = words + .filter( + (word, index) => + word !== '--exclude' && !word.startsWith('--exclude=') && words[index - 1] !== '--exclude' + ) + .join(' '); return heavyRunner.test(command) || vitestE2e.test(command); } +// Normalize static shell words without evaluating expansions or dropping command separators. +function shellCommandWords(script: string): string[] { + return (script.match(shellToken) ?? []).map((word) => + word.replace( + shellQuotes, + (_match, escaped, doubleQuoted, singleQuoted) => escaped ?? doubleQuoted ?? singleQuoted + ) + ); +} + /** Apply the same lane budget across worktrees and resource homes for the OS account. */ export async function withMacHeavyTestLane( { From 75e90bda6bf2c12d9714e8ebd70c194201c485f1 Mon Sep 17 00:00:00 2001 From: dafuga Date: Mon, 30 Nov 2026 18:37:42 +0000 Subject: [PATCH 5/6] fix: reproduce continued shell exclusions in test lane classification --- .../execution-runtimes/with-mac-heavy-test-lane.test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/utils/execution-runtimes/with-mac-heavy-test-lane.test.ts b/test/utils/execution-runtimes/with-mac-heavy-test-lane.test.ts index 578379e3abc..b633f6e013e 100644 --- a/test/utils/execution-runtimes/with-mac-heavy-test-lane.test.ts +++ b/test/utils/execution-runtimes/with-mac-heavy-test-lane.test.ts @@ -17,6 +17,7 @@ test('recognizes the standard suite commands without queuing routine type checks ['vitest', 'run', 'test/resources-cli.e2e.test.ts'], ['/bin/sh', '-c', "vitest run --exclude='test/desktop e2e/*.e2e.test.ts' test/cli.e2e.test.ts"], ['sh', '-c', "vitest run '--exclude=*.e2e.test.ts' 'test/cli.e2e.test.ts'"], + ['sh', '-c', 'vitest run --exclude "*.e2e.test.ts" test/queue.test.ts\nbun run test:e2e'], ['vitest', 'run', '--exclude', 'test/**/*.e2e.test.ts', 'test/cli.e2e.test.ts'] ]; expect(commands.every(isHeavyTestCommand)).toBe(true); @@ -37,7 +38,13 @@ test('recognizes the standard suite commands without queuing routine type checks '-c', "vitest run '--exclude' 'test/fixtures/test:e2e/*.test.ts' test/queue.test.ts" ], - ['sh', '-c', "vitest run '--exclude='test/fixtures/test:e2e/*.test.ts test/queue.test.ts"] + ['sh', '-c', "vitest run '--exclude='test/fixtures/test:e2e/*.test.ts test/queue.test.ts"], + [ + '/bin/sh', + '-c', + "vitest run --exclude \\\n 'test/fixtures/test:e2e/*.test.ts' test/queue.test.ts" + ], + ['sh', '-c', 'vitest run "--exclu\\\nde=**/*.e2e.test.ts" test/queue.test.ts'] ]; for (const command of unitCommands) expect(isHeavyTestCommand(command), command.join(' ')).toBe(false); From c4b8fcbaa6868cd23d836014114db625a055e1a6 Mon Sep 17 00:00:00 2001 From: dafuga Date: Mon, 30 Nov 2026 18:38:50 +0000 Subject: [PATCH 6/6] fix: preserve POSIX line continuations in test lane arguments --- .../withMacHeavyTestLane.ts | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/utils/execution-runtimes/withMacHeavyTestLane.ts b/src/utils/execution-runtimes/withMacHeavyTestLane.ts index 5a2c85de217..409b1a11035 100644 --- a/src/utils/execution-runtimes/withMacHeavyTestLane.ts +++ b/src/utils/execution-runtimes/withMacHeavyTestLane.ts @@ -21,8 +21,9 @@ const lockBusy = 75; // The runner argv and shell scripts used by Harness package commands. const heavyRunner = /\bplaywright\s+test\b|\btest:(?:e2e|native|package|all)\b/; const vitestE2e = /\bvitest\s+run\b[^;\n&|]*\.e2e\.test\./; -const shellToken = /(?:\\.|"(?:\\.|[^"\\])*"|'[^']*'|[^\s"'\\;&|])+|[\n;&|]/g; -const shellQuotes = /\\(.)|"((?:\\.|[^"\\])*)"|'([^']*)'/g; +const shellToken = /(?:\\[\s\S]|"(?:\\[\s\S]|[^"\\])*"|'[^']*'|[^\s"'\\;&|])+|[\n;&|]/g; +const shellQuotes = /\\([\s\S])|"((?:\\[\s\S]|[^"\\])*)"|'([^']*)'/g; +const shellContinuation = '\\\n'; export function isHeavyTestCommand(args: readonly string[]): boolean { if (args[0] === 'bun' && args[1] === 'scripts/run-checks.ts') return true; @@ -39,12 +40,23 @@ export function isHeavyTestCommand(args: readonly string[]): boolean { // Normalize static shell words without evaluating expansions or dropping command separators. function shellCommandWords(script: string): string[] { - return (script.match(shellToken) ?? []).map((word) => - word.replace( - shellQuotes, - (_match, escaped, doubleQuoted, singleQuoted) => escaped ?? doubleQuoted ?? singleQuoted - ) - ); + return (script.match(shellToken) ?? []) + .filter((word) => !/^(?:\\\n)+$/.test(word)) + .map((word) => + word.replace( + shellQuotes, + (match, escaped, doubleQuoted: string | undefined, singleQuoted) => { + if (escaped !== undefined) return escaped === '\n' ? '' : escaped; + return ( + doubleQuoted?.replace(/\\[\s\S]/g, (pair) => + pair === shellContinuation ? '' : pair + ) ?? + singleQuoted ?? + match + ); + } + ) + ); } /** Apply the same lane budget across worktrees and resource homes for the OS account. */