Skip to content

Convert test_bootstrap.py to unittest so discover collects it - #755

Merged
ptr727 merged 1 commit into
developfrom
fix-test-bootstrap-ci-754
Aug 16, 2026
Merged

Convert test_bootstrap.py to unittest so discover collects it#755
ptr727 merged 1 commit into
developfrom
fix-test-bootstrap-ci-754

Conversation

@ptr727

@ptr727 ptr727 commented Aug 16, 2026

Copy link
Copy Markdown
Owner

scripts/tests/test_bootstrap.py defined its ten checks as module-level test_* functions with its own check()/failures collector and main() runner, no unittest.TestCase. CI's only invocation, validate-task.yml's unittest discover -s scripts/tests, loads TestCase subclasses from each module it imports; a bare test_* function is not one, so none of the loader-invariant or spec-to-installer coverage checks ran.

What changed

Converted the file to unittest.TestCase, matching the other six files under scripts/tests/:

  • TestLoaderInvariant — the two loaders each read exactly one path into the fetched tree, and need no Python.
  • TestSpecCoverage — every tool spec/host-tools.json requires is one the platform installers can provide, and every floored tool carries a total remedy mapping.
  • TestScriptPresence — every script a loader hands control to is present and, on Linux, tracked executable; the Windows scripts and bootstrap.ps1 carry no shebang.
  • TestHarness — floors the collected test count, matching the sibling files' pattern.

Dropped the check()/failures global collector for self.assert* and self.subTest, so a loop over multiple items (tools, platforms, forbidden paths) reports each failing item as its own subtest instead of one lumped list. Added the shebang and executable bit the other six sibling files carry.

Verification

  • python3 scripts/tests/test_bootstrap.py — 11 tests, OK.
  • python3 -m unittest discover -s scripts/tests — 686 tests, OK (previously ran none of this file's checks; confirmed by grepping the -v output for bootstrap before this change).
  • uvx coverage@latest run --source=scripts,spec,host-setup -m unittest discover -s scripts/tests — the exact CI invocation — 686 tests, OK.
  • uvx ruff@latest check ., uvx ruff@latest format --check ., uvx mypy@latest — clean.
  • python3 scripts/prose_lint.py, python3 scripts/repo_gate.py — clean.
  • docker run ... mstruebing/editorconfig-checker:latest — clean on the changed file (only gitignored local tool caches flagged, not part of the change).
  • Fault injection: appended a forbidden $TREE/spec/... read to a scratch copy of host-setup/bootstrap.sh and reran — TestLoaderInvariant failed with the expected message, confirming the converted checks actually catch a violation rather than passing vacuously. Reverted before committing.

Fixes #754

test_bootstrap.py defined its ten checks as module-level test_* functions
with its own check()/failures collector and main() runner, no
unittest.TestCase. validate-task.yml's only invocation is
'unittest discover -s scripts/tests', which loads TestCase subclasses from
each module it imports; a bare test_* function is not one, so none of the
loader-invariant or spec-to-installer coverage checks ran.

Convert the file to unittest.TestCase, matching the other six files under
scripts/tests/: TestLoaderInvariant, TestSpecCoverage, and
TestScriptPresence group the ten checks, subTest reports each item in a
loop rather than lumping failures into one list, and a TestHarness case
floors the collected count. Confirmed discover now collects and runs all
eleven cases, and that a fault (a payload path added to bootstrap.sh) is
caught rather than passing silently.

Fixes #754
Copilot AI lite review requested due to automatic review settings August 16, 2026 03:12

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.

Pull request overview

This pull request fixes a CI test-discovery gap by converting scripts/tests/test_bootstrap.py from a custom module-level test_* + manual runner pattern into unittest.TestCase classes so python -m unittest discover -s scripts/tests actually collects and runs the checks (loader invariant + spec-to-installer coverage).

Changes:

  • Refactors the bootstrap checks into unittest.TestCase suites using assert* + subTest, replacing the prior global failures collector and main() runner.
  • Adds a small “harness” test to assert the module collects a minimum number of test cases (guarding against silent collection failures).
  • Adds a shebang and enables direct execution via unittest.main(verbosity=2).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ptr727
ptr727 merged commit 40bbd1b into develop Aug 16, 2026
6 checks passed
@ptr727
ptr727 deleted the fix-test-bootstrap-ci-754 branch August 16, 2026 03:17
ptr727 added a commit that referenced this pull request Aug 16, 2026
… Default (#768)

Promote `develop` to `main`, carrying the remaining stages of the
hub-hosted reusable-workflow rollout and the changes that landed beside
them:

- #759 Host Get-Version and Publish-Plan as Hub Reusable Tasks
- #760 Host the Validate Task and Reshape the Test Pull Request Stub
(settles #729 by design: the hub's validate task runs `uvx
<tool>@latest`, since Dependabot tracks the action pins and not a uvx
version)
- #761 Host the Type-Specific Tasks and Retire the Date Badge
- #762 Host the Release Chain and the Docker Core in the Hub
- #748 and #752, the staged rollout tracker and the PhotoCleaner
merge-bot pilot record
- #758 Flip the Fleet Line-Ending Default from CRLF to LF
- #753, #755, #756, #764, host-setup and test-collection changes

The release that follows this promotion is the first tag carrying every
hub task, so it is the pin the stage 2 to 5 adoptions and their catalog
snippets use. It is also the first run of the hub's own
`publish-release.yml` through `build-release-task.yml` with every target
disabled, which is the live proof that `github-release` runs when its
build needs are skipped.

Closes #729.
Refs #521 (hub half shipped, the merge-bot adoption sweep is what
remains).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants