Skip to content

test(tests): drop repeated dry-run guards and twin cases - #5138

Merged
dan-petty merged 2 commits into
mainfrom
test/4731-dry-run-family
Nov 12, 2026
Merged

dan-petty merged 2 commits into
mainfrom
test/4731-dry-run-family

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

The dry-run tests ran each request-plan command a second time under the root --dry-run, checked the gaps file again in 14 files, and copied blocks for programs, DNS and hosts that the floor of the suite already refuses.

The root --dry-run is now tested once, in tests/commands/test_global_dry_run.py, on a table of argv shapes through a stub command: options with values, positionals, --, a nested group and a flag given twice. The ratchet keeps each classified command out of the gaps file, so the 14 copies of that check go, and the prefix rule of the review commands stays. One fixture, refuse_requests, is the network block of dry runs: it also refuses a request that a fake would answer. Seven files check their dry-run classes with one helper, misclassified. docs/TESTING.md states the pattern.

Closes #4731

Change: openspec/changes/archive/2026-11-12-4731-drop-repeated-guards-and-twin-cases/

The root --dry-run is tested once, on a table of argv shapes through a
stub command, in place of a run of each request-plan command under the
root flag. The gaps tests whose list is within their class table go,
because the ratchet keeps each classified command out of the gaps file.
The subprocess, DNS and per-file network blocks go, because the floor
refuses them; one fixture, refuse_requests, refuses a request that a
fake would answer. Seven files check their dry-run classes with one
helper, misclassified.

Closes #4731
@dan-petty dan-petty added type/test Type test: a new or changed test scope/tests The test suite, its fixtures, fakes and floor labels Nov 12, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Measurements

The family is tests/commands/*dry_run*.py and tests/github/*dry_run*.py. Base: origin/main at a04e7a9. Host: devcontainer, taskset -c 0-3, pytest -n 4, three interleaved rounds.

Base This change
Tests 662 557
CPU time (user + sys), mean 142.8 s 108.7 s
Wall time, mean 42.9 s 34.1 s
Duplicate lines (pylint symilar 4.0.2, -d 8) 276 of 6,511 (4.24%) 32 of 5,528 (0.58%)

Rounds (user + sys / wall): base 148.3 / 45.5, 146.2 / 43.1, 133.8 / 40.1; change 102.3 / 31.9, 114.1 / 36.0, 109.6 / 34.4.

Command of the duplicate share: uvx --from pylint==4.0.2 symilar -d 8 tests/commands/*dry_run*.py tests/github/*dry_run*.py.

Evidence

  • Gaps tests: a one-time pytest check resolved each name of the 14 deleted gaps lists to its Click command, and found its callback in the class table of the same file. Result: 14 of 14 lists, no name outside the table. Criterion 2 of tests/invariants/test_dry_run_class_ratchet.py keeps each classified command out of tests/fixtures/dry_run_gaps.json.
  • Root-flag table: three mutations of resolve_proxy_dry_run each fail the new table. --dry-run at the end of argv fails separator. --dry-run at a fixed depth fails nested-group. A token scan in place of the parsed value fails option-value-that-is-the-flag and separator.
  • Floor: refuse_real_programs, prevent_external_network_calls and unexpected_loopback_connects in tests/conftest.py refuse and record each program but git, each external connect and each DNS query, so the deleted blocks repeated them.

Checks run locally

  • uv run devops ci --only lint,format,test-tree,constructs: pass.
  • uv run pytest -n 4 tests/commands/*dry_run*.py tests/github/*dry_run*.py tests/invariants/test_dry_run_class_ratchet.py: 568 passed.
  • uv run pytest -n 4 tests/invariants: 799 passed.
  • uv run devops openspec check and uv run devops ci docs: pass.

This is a test-only change, not a fix, so it has no fail-to-pass run. The change touches no path under src/, so the typecheck row does not apply.

@dan-petty
dan-petty marked this pull request as ready for review November 12, 2026 16:22
@dan-petty
dan-petty merged commit 2cb9e7b into main Nov 12, 2026
23 checks passed
@dan-petty
dan-petty deleted the test/4731-dry-run-family branch November 12, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/tests The test suite, its fixtures, fakes and floor type/test Type test: a new or changed test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(dry-run): drop repeated guards and twin cases

1 participant