The corpus
A bug a run found once is worth checking every run after, even once it’s fixed: bugs come back. A pin does that for the inputs you choose. The corpus does it for the rest, on its own: a store of inputs that found something before, run first each time.
What it holds
Section titled “What it holds”Each property has a folder under .proptastic/corpus/, and each input in it is a file:
proptastic.corpus/v1choices=50/1000000 0/1000000 49/999999domain=dbb236166b054eeeinput=aliceHas = 50, bobHas = 0, amount = 50choicesreplay the input, as a saved counterexample’s do.domainis a fingerprint of the property’s domains when the entry was found.inputis the input as the failure printed it, for a person reading the folder.
An entry’s file is named by the hash of its choices, so the same input found twice, or on two
machines, is one file. A property.txt in the folder names the property it’s for.
When it runs, and when it grows
Section titled “When it runs, and when it grows”A run tries a property’s corpus entries after its pinned examples and saved counterexample, and
before its random tries, in the same order on every machine: fewer choices first, then smaller
ones. The pr profile runs every entry and only 10 random
tries, so a pull request always checks what was found before.
A counterexample is added when PROPTASTIC_CORPUS_RECORD is on, as it is in the nightly
profile. PROPTASTIC_CORPUS moves the corpus, or
with off runs none.
A property’s corpus, after a rename
Section titled “A property’s corpus, after a rename”A property’s folder is named for its test’s class and method, made safe and its own as a counterexample’s file is, so renaming or moving the test starts its corpus afresh. Give the property an id of its own and the corpus follows it:
forAll(fields()).id("fields-round-trip").check(…);An id is letters, digits, ., _ and -, as a folder’s name is.
When an entry goes stale
Section titled “When an entry goes stale”An entry is choices, and choices mean what the domains make of them. Change a domain, a bound,
a new field in a record, and an old entry’s choices make a different input. That entry is
stale: its domain fingerprint isn’t the property’s any more. It still runs, as a different
input is still an input, and one that finds something is stamped again with the new fingerprint.
A cache, not a record
Section titled “A cache, not a record”The corpus holds inputs worth trying first, and nothing in it is needed: delete it and every
property still runs its own tries, and a longer search finds what was there again. That’s why it’s
safe to cache in CI and to prune. The proptastic command’s corpus shows each property’s entries
and the stale ones, merges another machine’s in, and prunes it.