Skip to content

Add bats test suite and CI - #7

Merged
dafioram merged 1 commit into
mainfrom
claude/upbeat-cannon-w8n2qa
Oct 4, 2026
Merged

dafioram merged 1 commit into
mainfrom
claude/upbeat-cannon-w8n2qa

Conversation

@dafioram

@dafioram dafioram commented Oct 4, 2026

Copy link
Copy Markdown
Owner

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/: fake systemctl, ss, journalctl and sleep.
    • Unit states live in a temp folder, so the tests never touch real services.
    • sleep is a no-op, so the startup check runs instantly.
    • Environment variables simulate failures: start failure, crash loop, restarts, ports, memory.
  • 49 bats tests in five files:
    • cli.bats: argument parsing, usage, APP_NAME validation (path traversal, empty, spaces).
    • env_file.bats: .env is never executed, quotes and CRLF line endings are handled, reserved keys and export lines are refused, and config.env export lines trigger a warning.
    • lifecycle.bats: build (including a real venv), pip failure stopping up, port checks, re-running run on a running app, crash/restart/never-listens detection, stop on a crash-looping app, restart, status memory, down.
    • dashboard.bats: ps states 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 real systemd-analyze verify including how systemd splits ExecStart.
  • CI (.github/workflows/ci.yml): ShellCheck plus the bats tests on every PR and every push to main.
  • README: a short "Development" section on running the tests.

Checking the tests catch regressions

I put three earlier bugs back one at a time and ran the suite:

Reintroduced bug Failing tests
ps with || echo unknown 2
stop-all only stopping active apps 1
No % escaping 2

Testing

  • bats tests: 49/49 pass in about 11 s locally (bats 1.10, the version in Ubuntu 24.04's apt).
  • shellcheck is 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 uses run !.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KdsNJV9e2ktZ9gF5kmczEu


Generated by Claude Code

- 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
@dafioram
dafioram merged commit 9f296fc into main Oct 4, 2026
1 check passed
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