Adopt Larch in an existing app
An existing app breaks rules on its first run. A baseline accepts those violations, so CI fails only on new ones.
Create the baseline
Section titled “Create the baseline”-
Write your rules. Run them once to see what they find.
-
Write the baseline:
Terminal window ./vendor/bin/pest tests/Arch --update-larch-baselineLarch writes
larch-baseline.jsonat the project root. -
Commit
larch-baseline.json.
From now on, a test fails only on violations that are not in the baseline. The failure message says how many more are in the baseline.
Remove fixed violations
Section titled “Remove fixed violations”After the tests, Larch lists the baseline entries of passing tests that no violation matches any more.
To remove them, run Pest with --update-larch-baseline again and commit the file.
Start over
Section titled “Start over”--update-larch-baseline keeps the entries of the tests that fail. To start over, delete the file first:
rm larch-baseline.json./vendor/bin/pest tests/Arch --update-larch-baselineKeep the baseline somewhere else
Section titled “Keep the baseline somewhere else”larch()->baseline('tests/Arch/baseline.json');With parallel tests
Section titled “With parallel tests”--update-larch-baseline works with --parallel. The lines Larch prints after the tests are missing then, because each worker keeps its own count.