Files
2026-12-02 15:44:24 +00:00

90 lines
5.0 KiB
Markdown

# Bortstack Testing Toolkit
This package is copied into generated applications. `scripts/testtask.sh` starts,
checks, or stops a **manual development environment**. `scripts/testrunner.sh`
runs configured automated suites. Both use `.bortstack/testing/target.py` to select a Git
worktree; neither needs Forge at runtime. This package does not migrate existing
Roborto application launchers. Forge's earlier `distribution/testtask` is a
separate existing-project automated runner and remains unchanged for its
previously accepted scope.
The project needs a local Git repository. An unborn initial branch works for
no-target commands, so a newly generated project can use `--git-init` without
making a commit. A generated project created without Git must initialise it
before using the toolkit.
The application owns `.bortstack/testing.json` (see
`config/testing.example.json`). A no-argument command uses the current worktree
and its checked-out branch. A branch name uses its existing worktree; a task ID
uses `docs/TASKS.md` headings and `Branch/worktree: \`name\`` references or a
matching branch slug. A branch needs no task record. Task headings accept a colon or dash separator, and three-digit targets such
as `134` also look up `TASK-134`. Missing or ambiguous targets fail without
Git mutation.
Generated Flask/React projects expose only `testtask.sh`, `testrunner.sh`
and `create-chatgpt-snapshot.sh` under `scripts/`. The testing implementation
and template-specific hooks live under `.bortstack/testing/`.
## Manual environments
`./scripts/testtask.sh [target] [--start|--status|--stop]` starts by default.
To use prepared acceptance snapshots for manual task IDs, set
`manual.acceptance_snapshots` in the launching checkout's testing
configuration to a directory such as `.test-worktrees`. A task target then
requires a registered detached Git worktree named after the lowercased task ID,
such as `.test-worktrees/task-134`. The command runs against the existing
snapshot files and its testing configuration. Prepare and verify the snapshot
before launch. Missing snapshots fail explicitly. Branch targets and automated
suites continue to resolve their own worktrees.
The current adapter supports Docker Compose. It uses a unique project name
derived from the selected worktree and branch, checks declared host ports,
starts only that project, verifies configured loopback readiness URLs, and
prints configured URLs. `--stop` runs Compose `stop` for that project; it never
removes volumes, databases, worktrees, or another project's containers. A
running project is reported without restarting it. Define project-specific
Compose services, ports, URLs, and optional account provisioning in the
application configuration. Do not configure production resources here.
For authentication, create `~/.config/bortstack/testing.env` with mode 0600:
```dotenv
BORTSTACK_TEST_EMAIL=test@localhost
BORTSTACK_TEST_PASSWORD=choose-a-private-local-password
```
`$XDG_CONFIG_HOME/bortstack/testing.env` is also accepted, and
`$XDG_CONFIG_HOME/bortstack/<project>/testing.env` can override either value.
The parser accepts only these two literal keys; it does not evaluate shell
code. The launcher asks before using defaults. Selecting N prompts for a new
email and hidden password without saving them. With no terminal, use
`--use-default-credentials` explicitly. Required credentials without a
configured local provisioning hook fail before startup. A hook receives only
the path in `BORTSTACK_CREDENTIALS_FILE` to a temporary mode-0600 JSON file;
it must never print or forward the password as a command argument. The generic
toolkit cannot promise an account exists until the project hook succeeds.
## Automated suites
`./scripts/testrunner.sh [target] [--unit] [--integration] [--act] [--all]` runs
the configured default suites when no option is supplied. Explicit suites can
be combined. `--all` includes every configured suite and only allowlisted act
jobs. Commands are argument arrays and run in the selected worktree. The tool
prints each executed suite and exit code; missing configuration or dependencies
cannot count as a pass. Exit 2 denotes target errors, 3 configuration or
infrastructure unavailability, 4 unsafe/cancelled selection, and test commands
retain their own nonzero exit codes.
`act` needs its executable and a working Docker daemon. Each allowed job must
name a local `.github/workflows/` file and job. A conservative content check
rejects obvious deployment, publishing, release, push, secret, and production
operations even if listed. Review the whole workflow before allowlisting it;
static checks cannot prove a workflow harmless. No user credentials or secrets
are passed to `act`. An act pass is local evidence, not a GitHub-hosted result.
Linux requires Python 3, Git, a POSIX shell and Docker Compose for manual
Compose environments. Windows contributors can use WSL2 with Git, Python,
Docker Desktop's WSL integration, and the project toolchain. Git Bash may work
if Docker, Python, and all project commands are available there. Windows has
not been exercised in this implementation.