English
Runner tests/run.py
A wrapper for any check: the full stdout/stderr goes to a log, the terminal gets a short summary. Only the Python standard library.
sh
python3 tests/run.py [--verbose] [--log /path/new.log] -- <command> [arguments...]What it does
- Runs the command in a new process group and writes its output to a log: by default a new
/tmp/ours-check-*.log, with--log— the given file (an existing one is not overwritten, it is opened withxb).--verboseadditionally streams the output to the terminal. - Prints
RUN <command>and the log path, and on completion —PASS/FAIL, the exit code and the time, and the counters parsed from the log:- Cargo: the lines
test result: … N passed; M failed; K ignored;across all suites; - E2E: the lines
ok,FAIL,skip(theexpect/expect_logmarkers fromtests/e2e/run.sh). If nothing is recognized, it says so (No recognized test summary.) and does not make numbers up.
- Cargo: the lines
- On an error without
--verbose— up to 40 lines of diagnostics: up to 10 failed tests and the surroundings of the linespanicked at,error[/error:,FAIL,ERROR:; if there are none — the tail of the log. FAILif the code is non-zero or there are failed tests: a successful suite does not hide a subsequent build or bench error. The command's exit code is preserved; a signal —128+N.SIGINT/SIGTERMare forwarded to the whole group of child processes.- Sets
OURS_TEST_REPORT_ACTIVE=1in the environment (from ittests/e2e/run.shknows it is already inside the runner and does not enter it a second time) andCARGO_TERM_COLOR=neverby default. - After every
cargocommand (if not interrupted) it prunes<target>/*/build/<pkg>/, keeping the 8 newest hash directories of each package: rebuilt test binaries get a new hash, and the old ones pile up in the sharedtarget/. A profile whose.cargo-lockis held (a build is running) is skipped.OURS_SWEEP=0turns this off.
Examples
sh
python3 tests/run.py -- cargo test -p ours-mod-socks --test socks
python3 tests/run.py -- cargo clippy --workspace --all-targets -- -D warnings
python3 tests/run.py --verbose -- cargo test -p ours-json
python3 tests/run.py -- python3 tests/dashboard/test_admin.pytests/e2e/run.sh hooks up the runner itself — no need to wrap it.
Rules for new tests
- A successful test is silent; the result is reported by the framework (Cargo,
expectin E2E). - An error names the expected and the actual value, the case, the parameters, the seed — so as to reproduce it.
- Large data — by length, the place of divergence or a hash, not in full.
- A skip — by the framework's means and with a reason (
#[ignore = "…"],skip).
Tests of the runner itself
tests/test_runner.py — a unittest that runs the runner as a subprocess: logs, summaries, exit codes, interruption; without the network and Docker:
sh
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s tests -p test_runner.py