Repository navigation
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
A `diffci.json` declaration whose `tests` names a pytest file selected nothing, so the full-suite fallback it was meant to narrow stayed. `declaredTests` builds its candidates from `knownTestPaths`, which walks `profile.tests` - the test locations the JavaScript runners declare - and from the Go adapter's `goTestPackages`, which DiffCI#83 added for the same reason. The pytest adapter reports its files on `profile.pythonTests`, which neither source reads, so a `tests` glob like `tests/test_prices.py` matched nothing and DiffCI reported the declaration as stale ("Declared input ... selects no tests"). The Python adapter's test files now join the candidates under the same condition the Go ones use: the adapter is present in the profile. Nothing is selected that the declaration did not name - the globs still filter the list. `tests/repo/python-declared-inputs.test.ts` is the Python counterpart of the Go testdata case in `go-runtime-inputs.test.ts`: a pytest file reads `tests/data/prices.csv` by name, a declaration maps the file to the test, and changing the data file must select that test with `DECLARED_INPUT` and no other test, without falling back. A second case keeps the old behaviour honest: with no declaration the same change still falls back to the full suite. The first case fails without the source change (0 selected tests) and passes with it. docs/using-diffci.md gains the Python example next to the JavaScript ones, and the new test file is in release-files.json, which audit:boundary enforces. Verified with npm run typecheck, npm run build and npm run audit:boundary; `npm test` gives 1056 passes and the same 8 Rust/Cargo failures this machine has on unmodified main (link.exe "missing operand after '\377\376'"). Signed-off-by: tyza66 <83948628+tyza66@users.noreply.github.com>
afff2f9 to
3ac972a
Compare
|
Thanks @tyza66, and sorry this one overlapped. Declared inputs already select pytest tests on current I checked by running this PR's Your earlier fallback-naming work (#144, #155, #156) is still credited in the README and on diffci.com/contributors. If you'd like another piece, the open good first issues are a good place to look. |
Closes #162.
The issue's "or" branch applied: declared inputs did not work for pytest, so this PR contains the test that shows it plus the fix.
The bug
declaredTests(src/repo/impact.ts:355) builds its candidate list fromknownTestPaths, which walksprofile.tests— the test locations the JavaScript runners declare — and from the Go adapter'sgoTestPackages, which #83 added for exactly this reason. The pytest adapter reports its files onprofile.pythonTests, which neither reads. So a declaration like{ "inputs": [{ "files": ["tests/data/**"], "tests": ["tests/test_prices.py"] }] }matched no candidate, and the change came back as
Declared input tests/data/prices.csv selects no tests; full validation required.The fix
The Python adapter's test files join the candidates under the same condition the Go ones use (the adapter is in the profile). The globs still filter, so nothing is selected that the declaration did not name.
The test
tests/repo/python-declared-inputs.test.tsis the Python counterpart of the Go testdata case ingo-runtime-inputs.test.ts:pyproject.tomlwith[tool.pytest.ini_options] testpaths = ["tests"], atests/data/prices.csv, atests/test_prices.pythat reads it withopen(...), and an unrelatedtests/test_pricing.py;tests/data/prices.csvmust selecttests/test_prices.pywith reasonDECLARED_INPUT, must not selecttests/test_pricing.py, and must not fall back;Without the source change the first case reports 0 selected tests; with it, both pass.
docs/using-diffci.mdnow has the Python example beside the JavaScript ones under "Declare inputs the graph can't see". The new test file is inrelease-files.json, whichaudit:boundaryenforces (379 files).Verification
npm run typecheck,npm run build,npm run audit:boundary: clean.npm test: 1056 pass, 4 skipped, and the same 8 Rust/Cargo tests that fail on unmodifiedmainon this Windows machine (link.exe "missing operand after '\377\376'"while linking the generated fixture crates).npx tsx --test tests/repo/python-declared-inputs.test.ts: 2 pass.Commits are signed off (
git commit -s).