tests: pinned regression suite for #29 + #30 (CI + pre-commit)#31
Open
kody-w wants to merge 1 commit into
Open
tests: pinned regression suite for #29 + #30 (CI + pre-commit)#31kody-w wants to merge 1 commit into
kody-w wants to merge 1 commit into
Conversation
Adds a stdlib-only regression test that catches reintroduction of the two project-local-install bugs we just fixed: - #29 — hardcoded :7071 in the chat UI's `API` constant - #30 — text-mode open() without encoding="utf-8" (Windows GBK crash) Files: rapp_brainstem/test_regressions.py Three checks: parse the `API` declaration in index.html and reject port literals; grep for `fetch('http://localhost:7071/...')` shapes elsewhere; ast-walk every .py in the package and flag any text-mode open / read_text / write_text without an `encoding=` kwarg. Stdlib only, runs directly: `python3 rapp_brainstem/test_regressions.py`. Manually verified by reintroducing each regression — both checks fail with precise file:line offenders, then pass once reverted. .github/workflows/regression-tests.yml Runs the suite on PRs touching `rapp_brainstem/` and on every push to main. Python 3.11, no extra deps. .pre-commit-config.yaml Same suite as a `pre-commit` hook (`pip install pre-commit && pre-commit install`) so local commits fail fast before CI. rapp_brainstem/CLAUDE.md Documents the pinned-regressions pattern and points future contributors at test_regressions.py for the rationale behind each check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rapp_brainstem/and on push to main) and pre-commit (same script as a local hook).Why
#29and#30were both invisible until someone hit them: the:7071hardcode looked fine until you ran a project-local install on a different port, and the encoding bug only crashed Windows users on non-UTF-8 system locales. A grep-able test pinned to a specific PR is the cheapest way to keep them dead.What gets checked
test_index_html_api_is_same_originconst API = …declaration inindex.htmldoes not contain a numeric port literaltest_index_html_no_hardcoded_fetch_to_7071fetch / XHR / WebSocket / EventSourcecall site inindex.htmltargetslocalhost:7071directlytest_no_text_open_without_encoding.pyinrapp_brainstem/and flags any text-modeopen(),Path.open(),Path.read_text(), orPath.write_text()missingencoding=The AST walker excludes
zf.open,urlopen,os.open,subprocess.Popen,webbrowser.open, and binary-mode ("rb"/"wb") opens — these don't have an encoding concept and would otherwise produce false positives.Manually verified
Reintroduced each regression and confirmed the suite catches them with precise
file:lineoffenders, then reverted and confirmed clean:Post-revert:
4 passed, 0 failed.How to run locally
Test plan
yaml.safe_load)Future regressions
When fixing a new bug that "ought to stay fixed," extend
rapp_brainstem/test_regressions.pywith a test referencing the PR number — the workflow and pre-commit hook pick it up automatically.