Repository navigation
Add bats test suite and CI - #7
Merged
Merged
Conversation
- tests/stubs: fake systemctl/ss/journalctl/sleep that keep unit state in a temp folder, so tests never touch real services and the startup check doesn't wait. - 49 tests covering argument parsing and APP_NAME validation, .env parsing (never executed, reserved keys, export), build/run/stop/ restart/status/down, crash and port detection during startup, ps states, stop-all/start-all, name conflicts and orphaned names, and the generated unit file (escaping, quoting, systemd-analyze verify). - GitHub Actions runs ShellCheck and the tests on every PR and on main. - README: how to run the tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KdsNJV9e2ktZ9gF5kmczEu
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.
PR 1 of 3 in this round. The features PR and the host-setup PR are stacked on this one, so merge this first.
What's added
tests/stubs/: fakesystemctl,ss,journalctlandsleep.sleepis a no-op, so the startup check runs instantly.cli.bats: argument parsing, usage,APP_NAMEvalidation (path traversal, empty, spaces).env_file.bats:.envis never executed, quotes and CRLF line endings are handled, reserved keys andexportlines are refused, andconfig.envexportlines trigger a warning.lifecycle.bats: build (including a real venv), pip failure stoppingup, port checks, re-runningrunon a running app, crash/restart/never-listens detection, stop on a crash-looping app, restart, status memory, down.dashboard.bats:psstates with exactly one line per app, RESTARTING,(missing)folders, name conflicts for every command, claiming orphaned names, stop-all/start-all, other user services left alone.unit_file.bats: settings in the generated service file, escaping of%/$/&/|, project paths with spaces, and realsystemd-analyze verifyincluding how systemd splitsExecStart..github/workflows/ci.yml): ShellCheck plus the bats tests on every PR and every push tomain.Checking the tests catch regressions
I put three earlier bugs back one at a time and ran the suite:
pswith|| echo unknownstop-allonly stoppingactiveapps%escapingTesting
bats tests: 49/49 pass in about 11 s locally (bats 1.10, the version in Ubuntu 24.04's apt).shellcheckis clean on the scripts, stubs and test files. It caught one real test bug: a bare!in bats, which can't fail a test. That line now usesrun !.🤖 Generated with Claude Code
https://claude.ai/code/session_01KdsNJV9e2ktZ9gF5kmczEu
Generated by Claude Code