test(cloud): base-list skip is an exact whole-line filter with a unit test; off-list tests stay selected

filter-base-list-tests.sh is the one place premerge drops base-list tests (logged to stderr). The test covers:
a base-list test is dropped and logged while an off-list test is still selected; shared prefix/suffix/folder
never skips; entries are literal (no regex) and comments are ignored; a missing list keeps everything.
This commit is contained in:
Neil
2026-11-11 07:17:49 -08:00
parent 0e9eb6201c
commit 8b7b51394e
3 changed files with 88 additions and 10 deletions
+15
View File
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
# usage: filter-base-list-tests.sh <base-list-file> < test-paths
# Prints each test path from stdin that is NOT an exact line of the base list (stdout), and logs every path it drops
# as "premerge: skipping base-list test <path>" (stderr). Matching is whole-line and literal, so a path that merely
# shares a prefix, a directory or a suffix with a base-list entry is kept. A missing base list drops nothing.
set -euo pipefail
base_list=${1:?usage: filter-base-list-tests.sh <base-list-file> < test-paths}
while IFS= read -r t; do
if [[ -z "$t" ]]; then continue; fi
if [[ -f "$base_list" ]] && grep -qxF -- "$t" "$base_list"; then
echo "premerge: skipping base-list test $t" >&2
else
printf '%s\n' "$t"
fi
done
@@ -0,0 +1,69 @@
import { spawnSync } from 'node:child_process'
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import path from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
const script = path.join(import.meta.dirname, 'filter-base-list-tests.sh')
const roots = []
afterEach(() => {
for (const root of roots.splice(0)) {
rmSync(root, { recursive: true, force: true })
}
})
function run(baseListLines, testPaths) {
const root = mkdtempSync(path.join(tmpdir(), 'base-list-'))
roots.push(root)
const baseList = path.join(root, 'base-list.txt')
if (baseListLines !== null) {
writeFileSync(baseList, `${baseListLines.join('\n')}\n`)
}
const r = spawnSync('bash', [script, baseList], {
input: `${testPaths.join('\n')}\n`,
encoding: 'utf8'
})
return {
status: r.status,
kept: r.stdout.split('\n').filter(Boolean),
log: r.stderr.split('\n').filter(Boolean)
}
}
const ON_LIST = 'src/main/agent-hooks/server/testing/replay/spool.test.ts'
const OFF_LIST =
'src/renderer/src/components/orca-cloud/cloud-workspace-archive-delete-race.test.ts'
describe('premerge base-list filter', () => {
it('drops a base-list test and logs the skip, while a test off the list is still selected', () => {
const r = run(['# comment', ON_LIST], [ON_LIST, OFF_LIST])
expect(r.status).toBe(0)
expect(r.kept).toEqual([OFF_LIST])
expect(r.log).toEqual([`premerge: skipping base-list test ${ON_LIST}`])
})
it('matches whole lines only: a shared prefix, suffix or folder never skips a test', () => {
const r = run(
[ON_LIST],
[
'src/main/agent-hooks/server/testing/replay/spool.test.tsx',
'src/main/agent-hooks/server/testing/replay/other-spool.test.ts',
'src/main/agent-hooks/server/testing/replay/spool.extra.test.ts',
'x/src/main/agent-hooks/server/testing/replay/spool.test.ts'
]
)
expect(r.kept).toHaveLength(4)
expect(r.log).toEqual([])
})
it('treats list entries literally (no regex) and ignores comment lines', () => {
const r = run(['src/main/a.test.ts', '.*', `# ${OFF_LIST}`], ['src/main/a_test.ts', OFF_LIST])
expect(r.kept).toEqual(['src/main/a_test.ts', OFF_LIST])
})
it('keeps everything when the base list is missing', () => {
const r = run(null, [ON_LIST, OFF_LIST])
expect(r.status).toBe(0)
expect(r.kept).toEqual([ON_LIST, OFF_LIST])
})
})
@@ -56,16 +56,10 @@ else
esac
done < <(git diff --name-only --diff-filter=AMR "$base"...HEAD -- 'src/*')
if ((${#tests[@]} > 0)); then
tests=($(printf "%s\n" "${tests[@]}" | sort -u)) # repo paths have no spaces
# Skip files on the full-suite base list: they fail on upstream too (this Mac's environment), so they would only block.
base_list=config/scripts/cloud-integration/full-suite-base-list.txt
if [[ -f "$base_list" ]]; then
kept=()
for t in "${tests[@]}"; do
if grep -qxF "$t" "$base_list"; then echo "premerge: skipping base-list test $t"; else kept+=("$t"); fi
done
tests=(${kept[@]+"${kept[@]}"})
fi
# Skip files on the full-suite base list: they fail on upstream too (this Mac's environment), so they would only
# block. Exact whole-line matches only (filter-base-list-tests.sh, unit-tested); repo paths have no spaces.
tests=($(printf "%s\n" "${tests[@]}" | sort -u |
bash config/scripts/cloud-integration/filter-base-list-tests.sh config/scripts/cloud-integration/full-suite-base-list.txt))
echo "premerge: ${#tests[@]} targeted test file(s):"
fi
if ((${#tests[@]} > 0)); then