Skip to main content

Without the command

bootstrap.php works directly in PHPUnit, Pest and ParaTest, configured by environment variables; it is what the command does underneath. It serves a runner the command does not know, or a CI step that wants to drive the pieces itself.

The bootstrap​

Pass the bootstrap to the runner with the variables set. With Sonda installed by Composer:

SONDA_AUTOLOAD=vendor/autoload.php SONDA_TARGET=app SONDA_EXCLUDE=app/Providers \
SONDA_CACHE=/tmp/sonda/cache SONDA_OUT=/tmp/sonda/runs SONDA_STRICT=1 SONDA_FAST=1 \
php artisan test --parallel --bootstrap=vendor/ddr/sonda/bootstrap.php

With a clone, the bootstrap is /opt/sonda/bootstrap.php. Each process (every ParaTest worker included) saves its own run in SONDA_OUT; use a new directory for each measurement.

Variables​

Lists are separated by PATH_SEPARATOR (: on Linux and macOS).

VariableRequiredMeaning
SONDA_AUTOLOADyesvendor/autoload.php of the measured project
SONDA_TARGETyesinstrumented directories
SONDA_CACHEyesdirectory of the instrumented files
SONDA_OUTyesdirectory of the runs, one file per process; use a new one for each measurement
SONDA_EXCLUDEnodirectories left out
SONDA_ONLYnothe only files measured
SONDA_STRICT=1nostrict branch semantics
SONDA_FAST=1nolocal reference per function: cheaper probes
SONDA_CHAINnothe project's original bootstrap, when it is not just the autoload
SONDA_VIEWSnodirectories of Blade views to measure
SONDA_INCLUDES=1noinstruments the files of the target loaded by their path (include/require) too

The report​

report.php merges the runs of a directory and writes a php-code-coverage .cov file, which serves any other format:

php vendor/ddr/sonda/report.php /tmp/sonda/runs app coverage.cov app/Providers

Its arguments: the runs directory, the source directory, the output .cov file and, optionally, excluded directories.

usage: report.php <runs directory> <source directory> <output .cov file> [excluded directory]...