Tests
Phasor runs a project's checks and records each result with the tree it ran on. The verification state of intent is computed from those recorded results. A passing result is evidence that a check passed on a given tree. It is not proof that the software is correct.
Check configuration
Tests are ordinary test files in the work folder, written in whatever the project uses. A check is a JSON file under .phasor/work/.checks/ that tells Phasor how to run them.
{"run": ["python", "-m", "unittest", "discover", "-s", "tests"], "inputs": ["snake/**", "tests/**"], "timeout": 60000}
| Field | Meaning |
|---|---|
run | Required. The command and its arguments, as a list. The program is found on PATH and started directly, without a shell. |
inputs | Path patterns that name the files the result depends on. A recorded pass is reused while those files are unchanged. Without inputs, every file counts. |
timeout | A limit in milliseconds. The default is 600000, ten minutes. |
env | Additional environment variables, as a list of [name, value] pairs. The values are literal text in the check file. |
A check is bound to intent by a landing: the checks that land with a piece of work are bound to the intent that work covers.
Executing checks
phasor check --current .checks/unit.json: pass phasor check --current --json {"appends":[{"id":"2dc423e99676","kind":"result"}],"ok":true,"results":{".checks/unit.json":"pass"},"tree":"16cbe27e6162"}
phasor check --currentruns the checks on the project's current landed state and records the results.phasor checkwith no flag runs them on the work in the folder. Those results are held with the draft and recorded when it lands.phasor landruns the checks as part of the landing, so most results are recorded with the work they verify.
A run ends in one of three outcomes.
| Outcome | Meaning |
|---|---|
pass | The command exited with status 0 |
fail | The command exited with another status |
error | There was no exit status to judge: the command timed out, was killed, could not be started, or the check file is invalid |
Execution environment
- Phasor copies the project's code and test files into a new temporary folder, starts the command there, and removes the folder afterwards. All of the code and tests are copied, not only the files that
inputsnames. Intent files are not copied. If the project has set a check folder withphasor check --set-folder, the command runs there instead. That folder is kept between runs, so earlier build output is still there. - The command receives a reduced environment:
PATH, the home and temporary folders, locale settings and the locations of common toolchains, taken from a fixed list. No other variable is passed from your shell, so a token exported there does not reach the command. inputsselects what a result depends on. It does not restrict what the command can read.
A check is not sandboxed. The command runs as your user account. It can read any file that account can read, your home folder and your Phasor home included. It can use the network, and it can write outside its folder. Treat a check file as code that you run, and read one that came from somewhere else before you run it.
Verification and intent state
A result is a signed record of one run: the check and its version, the tree it ran on, the outcome, and the output. It establishes that this check ended with this outcome on this tree. It does not establish that the tests are complete or correct, or that code the check does not exercise works.
Phasor counts a result only when it ran the check itself, the run did not end in error, and the result carries the project owner's signature. It does not attest which machine or process ran the command, so a result is as trustworthy as the environment that holds the owner's key.
- Intent is resolved only while every check bound to it has a passing result for the current inputs.
- A failing result makes it regressed, until a later run passes.
- A run that ended in
error, or a change to a check's inputs with no run since, leaves it unverified. - Intent resolved with no check bound to it is reported as resolved, unchecked.
The states are defined under Intent states.
Reproducing historical results
phasor rerun RESULTruns a recorded result's check again on the exact tree it ran on and reports whether the outcome matches. It records nothing. The tools and dependencies outside the project are the ones installed at the time of the rerun.phasor bisect CHECK --good STEP --bad STEPfinds the first step at which a check fails.- Results do not expire. A result keeps the command's exit status and the first 64 KiB of its standard output and of its standard error.
phasor show RESULT --logprints them.