Skip to content

test: select every orphaned test module in CI and guard the selection - #4748

Merged
Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
danielmeppiel-fix-4736-orphan-tests
Nov 22, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
danielmeppiel-fix-4736-orphan-tests

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

17 test modules were selected by no CI job: the 16 top-level tests/test_*.py modules from the issue, plus tests/acceptance/test_logging_acceptance.py. Failures in them went unnoticed. This PR moves them under tests/unit/<area>/, triages what they surface, and adds a guard so an unselected module cannot reappear.

Moves (git mv, history kept):

  • models/: test_apm_package_models.py
  • deps/: test_apm_resolver.py, test_github_downloader*.py, test_lockfile.py, test_virtual_package_multi_install.py
  • adapters/: the three empty-string and Codex modules
  • core/: test_collision_integration.py, test_runnable_prompts.py, test_token_manager.py
  • compilation/: test_distributed_compilation.py
  • primitives/: test_enhanced_discovery.py
  • runtime/: test_runtime_manager_token_precedence.py
  • install/: test_logging_acceptance.py
  • test_gitlab_git_transport.py goes to tests/integration/ (component), not tests/unit/, because it spawns git (taxonomy tm006 rejects process-spawning unit modules). The hermetic integration run selects it.
  • Repo-root lookups move to Path(__file__).resolve().parents[3], and the obsolete sys.path inserts are dropped.

Triage (pytest -n 2 over all 17 modules on main 899d17b, then in place under tests/unit):

Failure Verdict Change
test_apm_resolver.py x3, resolve_marketplace_plugin expected call stale: the call gained enforce_ref_pins / accept_ref_change expected calls pin the default enforce_ref_pins=True, accept_ref_change=False
test_logging_acceptance.py::test_dry_run_shows_dry_run_label stale: the fixture apm.yml lacked the required version fixture adds version: 1.0.0
test_lockfile.py::test_write_parses_legacy_lockfile_once (assert 3 == 1) product: _same_document re-parses the on-disk text that write() already parsed; parsing the new serialization is legitimate test narrowed to parses of the on-disk text (2 == 1), strict xfail citing #4742 (filed, 0.38.0; one owner agreed with PERF)
Codex adapter modules wrote .codex/config.toml into the repo cwd test hygiene autouse monkeypatch.chdir(tmp_path)
test_token_manager.py::test_empty_string_invalid exact duplicate of tests/unit/core/test_token_manager_lifecycle.py::test_empty_string_is_invalid (AST body hash) deleted

No other exact duplicates were found: every function was AST-hashed against tests/unit.

Guard: tests/unit/test_ci_test_selection_coverage.py reads the test roots that each workflow's pytest, scripts.ci_sharding and scripts.ci_selections lines name, plus scripts/ci_selections.SELECTIONS. It fails on any test module those roots do not cover. Out of scope are tests/integration, tests/lifecycle, tests/benchmarks and tests/perf, which have their own jobs. Two negative controls pin the detector, so a paths: filter or an echo does not count as a selection. Red check: a temporary tests/test_tmp_orphan.py makes it fail with test modules no CI job selects ...: ['tests/test_tmp_orphan.py'].

Bookkeeping:

  • The path-keyed quality baselines (assertion_quality_baseline.json, test_taxonomy_baseline.json, exact_test_duplicates.json) are re-keyed and kept sorted. The duplicates baseline drops 6 stale entries (--update-baseline); nothing grows.
  • CONFORMANCE.{json,md} is regenerated after a full pytest tests --collect-only; only req-lk-001's node id changes.
  • The primitive-types.md doc path is updated.

Issue and approved scope

Issue: Fixes #4736

Human scope-approval comment: pending. The Q&L lead assigned the work (Epic #4565); a fresh scope approval has been requested through the regent.

Does this PR complete the issue, or what remains? It completes #4736: every test module under tests/ is selected, each failure is triaged, and the guard is in place. The product fix for the lockfile double parse is #4742, a separate PR that flips the xfail.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Validation evidence (local, host_guard, -n 2):

  • the 17 moved modules plus the guard: 668 passed, 2 skipped, 1 xfailed, 9 subtests passed
  • tests/quality/test_test_taxonomy.py tests/quality/test_quality_baselines.py: 43 passed
  • tests/quality/test_ci_topology.py: passed (in the 523 passed run before the baseline re-sort)
  • lint chain: ruff 0.15.12 check + format, pylint R0801 10.00/10, auth signals, complexity ratchet, taxonomy --changed, AQ ratchet, exact-duplicate ratchet: all clean

Changelog

  • One fragment per section, changelog.d/<pr>.<section>.md, holding
    one line: user-visible effect first, 25 words or fewer, ending with
    (#PR); breaking changes only under upgrade notes; no Highlights; no
    new lines under ## [Unreleased]. See changelog.d/README.md and
    .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • Spec edit: docs/src/content/docs/specs/openapm-v0.1.md updated
    (new/changed <a id="req-XXX"></a> anchor + prose + Appendix C
    row).
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml
    updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under
    tests/spec_conformance/ added or extended.
  • CONFORMANCE.{md,json} regenerated via
    uv run --extra dev python -m tests.spec_conformance.gen_statement
    and committed (node-id move only).
  • N/A -- this PR does not change OpenAPM-observable behaviour.

…4736)

17 test modules (16 top-level tests/test_*.py plus tests/acceptance)
ran in no CI job. They move under tests/unit/<area>/; the git-spawning
GitLab transport module moves to tests/integration (component).

Triage of the failures this surfaces:
- three stale resolver tests now pin enforce_ref_pins/accept_ref_change
- a stale install-logging fixture gains apm.yml's required version
- two Codex adapter modules stop writing .codex/ into the repo cwd
- test_write_parses_legacy_lockfile_once now counts parses of the
  on-disk text only; it is a strict xfail citing #4742
- one exact duplicate (test_empty_string_invalid) is removed

tests/unit/test_ci_test_selection_coverage.py fails when a test module
outside integration/lifecycle/benchmarks/perf is not named by any
workflow pytest, sharding or selection command.

Fixes #4736

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The coverage guard can miss orphaned test modules by crediting non-executing command text and unused selections, and by exempting paths outside the intended directories.

3 open issues
What changed in this PR

This PR addresses #4736 by moving orphaned tests into CI-selected directories and adding a guard against future selection gaps. It also fixes stale test expectations and tracks the known lockfile parsing issue separately in #4742.

Changes:

  • Relocates 17 test modules, adjusts repository-root lookups, and isolates Codex configuration writes.
  • Adds a workflow-selection coverage guard with negative controls.
  • Updates quality baselines, test references, and conformance metadata for the moved paths.
File Description
tests/​unit/​test_ci_test_selection_coverage.py Adds the CI selection guard and controls.
tests/​unit/​runtime/​test_runtime_manager_token_precedence.py Moves runtime token tests into CI selection.
tests/​unit/​primitives/​test_enhanced_discovery.py Moves discovery tests and removes path injection.
tests/​unit/​models/​test_apm_package_models.py Moves package-model tests into CI selection.
tests/​unit/​install/​test_logging_acceptance.py Fixes root lookups and adds the required fixture version.
tests/​unit/​deps/​test_virtual_package_multi_install.py Moves virtual-package tests into CI selection.
tests/​unit/​deps/​test_lockfile.py Narrows parse counting and marks the known failure.
tests/​unit/​deps/​test_github_downloader_token_precedence.py Moves downloader token tests into CI selection.
tests/​unit/​deps/​test_apm_resolver.py Updates expected reference-pin arguments.
tests/​unit/​core/​test_token_manager.py Moves token tests and removes one duplicate.
tests/​unit/​core/​test_runnable_prompts.py Adjusts root lookups after relocation.
tests/​unit/​core/​test_collision_integration.py Adjusts root lookups after relocation.
tests/​unit/​compilation/​test_distributed_compilation.py Moves compilation tests into CI selection.
tests/​unit/​adapters/​test_vscode_v01_value_runtime_args.py Updates a test-path reference in a docstring.
tests/​unit/​adapters/​test_empty_string_and_defaults.py Moves adapter tests and removes path injection.
tests/​unit/​adapters/​test_codex_empty_string_and_defaults.py Isolates configuration writes in a temporary directory.
tests/​unit/​adapters/​test_codex_docker_args_fix.py Isolates configuration writes in a temporary directory.
tests/​quality/​test_taxonomy_baseline.json Re-keys exemptions for moved modules.
tests/​quality/​exact_test_duplicates.json Re-keys duplicate records and removes stale entries.
tests/​quality/​assertion_quality_baseline.json Re-keys assertion allowances for moved modules.
tests/​integration/​test_gitlab_install_e2e.py Updates a test-path reference in its docstring.
tests/​integration/​test_gitlab_git_transport.py Moves Git transport tests into integration selection.
tests/​acceptance/​__init__.py Cleans up the former acceptance package.
docs/​src/​content/​docs/​reference/​primitive-types.md Updates the discovery-test path and command.
CONFORMANCE.json Updates the lockfile test node path.

Review effort: Balanced

- the guard reads tokenized commands: a launcher (uv/python/pytest) must
  run pytest, ci_sharding files or ci_selections as a module; echo
  lines, --collect-only runs, --ignore values and comments select
  nothing; a selection counts only where a workflow invokes it; the
  own-job exclusions match directory boundaries
- test_git_config_global_uses_dev_null_on_unix fakes sys.platform, so on
  a Windows host os.devnull stays 'nul': skip it there

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Active findings show false-positive CI coverage from ignored files and quoted shell text, an incorrect test classification, and a structured-reference test that can pass without exercising the intended dispatch.

No open issues 🎉

3 previously missed issues

In code that hasn't changed since last review

Medium severity Classify filesystem tests as component tests

tests/​unit/​test_ci_test_selection_coverage.py:24

This module reads workflow files and recursively inventories the filesystem, and its negative controls create files through tmp_path. It therefore crosses the component boundary defined in pyproject.toml:217-219, rather than the pure-logic/no-filesystem unit boundary. Mark the module as component so its behavioral classification matches the tests it contains.

Medium severity Respect shell quoting when splitting commands

tests/​unit/​test_ci_test_selection_coverage.py:75

Splitting before interpreting quotes makes echo 'status; pytest tests/test_tmp_orphan.py; done' credit the module even though the shell only prints text. Preserve quoting when identifying command boundaries, and add this quoted-separator case as a negative control.

Medium severity Preserve per-command exclusions in module coverage

tests/​unit/​test_ci_test_selection_coverage.py:118

uv run pytest tests/extra --ignore tests/extra/test_orphan.py still credits the ignored module through the tests/extra root, allowing an orphan to pass the guard. Preserve exclusions per command when computing module coverage, and add a negative control with an ignored file inside the selected directory.

3 resolved since last review

Review effort: Balanced

@danielmeppiel Daniel Meppiel (danielmeppiel) added the full-integration Run the full integration suite (ci-integration.yml) on this PR before merge label Nov 22, 2026
…l-fix-4736-orphan-tests

# Conflicts:
#	tests/quality/exact_test_duplicates.json

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The coverage guard can credit modules that never execute due to quoted commands, comments, or marker filters, and the structured-reference test masks a class mismatch without exercising its intended branch.

2 open issues

Review effort: Balanced

def _commands(run: str) -> list[list[str]]:
"""Each shell command of a step's ``run`` text, tokenized with comments dropped."""
commands = []
for part in re.split(r"&&|\|\||;|\|", run.replace("\\\n", " ")):
Comment on lines +116 to +118
return {
arg.split("::", 1)[0].rstrip("/") for arg in _positionals(args) if arg.startswith("tests/")
}
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 7415642 into main Nov 22, 2026
61 of 66 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-fix-4736-orphan-tests branch November 22, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-integration Run the full integration suite (ci-integration.yml) on this PR before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] 16 top-level tests/test_*.py modules are not selected by any CI job

2 participants