Skip to content

test: the CLI scoring test makes its package a repository of its own - #126

Merged
jmf-pobox merged 1 commit into
mainfrom
fix/test-path-inside-checkout
Dec 2, 2026
Merged

jmf-pobox merged 1 commit into
mainfrom
fix/test-path-inside-checkout

Conversation

@jmf-pobox

Copy link
Copy Markdown
Contributor

What changed

tests/oo/test_oo_scoring_domain.py::TestCharacterization::test_cli_exit_code_and_table now runs git init in its tmp_path, so the fixture package is a project of its own. This is a test-only change.

Why

punt release 0.9.0 stopped in pre-flight. It runs make check with the shell's TMPDIR, which the workspace .envrc sets inside the checkout. With TMPDIR there, separate_project (tests/conftest.py) makes pytest's scratch root a repository, and the gate names files from the repository root. The test asserted the exact text ERROR: pkg/broken.py, so it failed:

AssertionError: assert 'ERROR: pkg/broken.py could not be parsed' in
'... ERROR: test_cli_exit_code_and_table0/pkg/broken.py could not be parsed ...'

The gate's behaviour was correct: exit 2, with the file named. CI never saw this, because its TMPDIR is outside any repository.

How it was proven

  • Before: the test fails with TMPDIR inside the checkout (the output above).
  • After: tests/oo/test_oo_scoring_domain.py passes, 7 tests.
  • A full make check is running under the same condition. Its result will be posted below.

No source change, so no demo applies: every commit touches only tests/.

punt release runs make check with the shell's TMPDIR, which the workspace
.envrc puts inside the checkout. separate_project then makes pytest's scratch
root a repository, and the gate names the broken file from that root, so
test_cli_exit_code_and_table failed the 0.9.0 release pre-flight:

Before (TMPDIR inside the checkout):
  AssertionError: assert 'ERROR: pkg/broken.py could not be parsed' in
  '... ERROR: test_cli_exit_code_and_table0/pkg/broken.py could not be parsed ...'
After: tests/oo/test_oo_scoring_domain.py passes (7 passed).
@qodo-code-review

qodo-code-review Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

test: make CLI scoring fixture its own git repository

🐞 Bug fix 🧪 Tests 🕐 Less than 10 minutes

Grey Divider

AI Description

• Runs git init in the CLI test's tmp_path, so the fixture package is its own repository.
• Fixes an assertion that failed when TMPDIR sat inside a checkout, making the scratch root a
 repo.
• Test-only change; no source code or demo impact.
Merge Risk 🟢 Low

Blast radius 🟢 Low 💥 0 capabilities

  • No production behavior changes identified.
Behavioral complexity 🟢 Low 🧩 Assessed behavior

  • No production behavior changes identified.
Potential damage 🟢 Low 🩹 Assessed behavior

  • No production behavior changes identified.
Assessed commit b7d0125
Diagram

graph TD
  T["test_cli_exit_code_and_table"] --> G["git init in tmp_path"] --> R["tmp_path as repo root"] --> D["dispatch oo pkg"] --> M["ERROR: pkg/broken.py"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Set TMPDIR outside the checkout in the test or Makefile
  • ➕ Keeps the test code unchanged
  • ➕ Fixes the environment for all tests
  • ➖ Relies on the developer's shell configuration
  • ➖ Does not fix the test's dependence on the scratch root being a non-repo
2. Assert on the basename or a path suffix instead of the full path
  • ➕ Smaller change
  • ➕ Works regardless of the repository root
  • ➖ Weakens the assertion
  • ➖ Still depends on the gate reporting a relative path

Recommendation: The PR's approach is sound. It makes the fixture match its stated meaning, a project of its own, so the gate's repo-relative output is what the test should expect. It does not change the environment or weaken the assertion. The alternatives either depend on developer shell setup or loosen the test. Note that the test now needs the git binary on PATH, which CI already has.

Files changed (1) +6 / -0

Bug fix (1) +6 / -0
test_oo_scoring_domain.pyInitialize fixture as a git repository in CLI exit-code test +6/-0

Initialize fixture as a git repository in CLI exit-code test

• Adds a 'subprocess' import and runs 'git init -q' in 'tmp_path' before 'monkeypatch.chdir', so the gate reports paths from the fixture root. A comment explains that when TMPDIR is inside a checkout, 'separate_project' would otherwise make the scratch root the repository.

tests/oo/test_oo_scoring_domain.py

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo Fixer

No findings are available for this PR yet. Findings appear here once Qodo has reviewed the PR.

@jmf-pobox

Copy link
Copy Markdown
Contributor Author

verified: b7d0125

make check passes with TMPDIR inside the checkout, which is the condition punt release runs under:

  • tests: 3577 passed, 4 skipped;
  • suppressions: unchanged;
  • layers: 274 modules, none new;
  • every goal target met.

CI is green on b7d0125 (Python 3.13 and 3.14, plus check). Qodo found no issues. Every commit touches only tests/, so no demo applies.

@jmf-pobox
jmf-pobox merged commit 23322c4 into main Dec 2, 2026
3 checks passed
@jmf-pobox
jmf-pobox deleted the fix/test-path-inside-checkout branch December 2, 2026 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant