GeezerVison is showing 4matic.github.io — How it's tested
How it's tested
The fixtures in spec/fixtures are
the source of truth. The spec says what should happen, the fixtures
pin it down, and every port has to pass all of them. The JavaScript, Python, Rust, Go and C ports all do:
13,565 of 13,565, with empty skip lists, in CI on every push.
Artist - Title • LABEL • NOTE lines from real radio show tracklists, notes, junk after the bullet, the near misses (unspaced, inside brackets, before the dash, · and ●), format with and without the label
Tracklist mode
67
Real lines that single-line parse() gets wrong, real lines with no separator at all, Markdown around names, and names that keep their * and _
Tracklist lines and times
109
LF/CRLF/CR, trailing spaces, line kinds, every time form, brackets, gap separators, invalid times, list bullets, Markdown around times, w/ lines
Tracklist positions
15
A real 81-line list numbered without dots, and the 2 Unlimited guard
Tracklist warnings
38
Each code with its near-miss, and real out-of-order lists with their suggestions
A deterministic generator builds inputs from small "atoms": an artist, a joiner, a feat placement,
a version group, a junk suffix. Each atom carries its own expected contribution, and the expected
output is assembled from those atoms. It never comes from running a parser, so the generator can't
quietly agree with the code it's testing. Combinations whose answer would depend on a rule the atoms
don't model are rejected instead of guessed.
Each port throws thousands of random strings at the parser to check the
invariants from the spec. The JavaScript suite uses
fast-check and the Python suite uses
Hypothesis. The Rust, Go and C suites each have a small seeded
generator of their own, so none of them needs an extra test dependency. The checks:
it never throws or panics, on any input, in any mode;
a 10,000-code-point input finishes inside a ceiling: 1 s in JavaScript and Python, 2 s in Rust,
Go and C (Go and C widen it ten times under the race detector or a sanitizer). It normally
takes tens of milliseconds in JavaScript and Rust, a few milliseconds in Go and C, and well
under a second in Python. The ceiling is loose so that a busy CI machine doesn't fail the run
but a blowup does;
whitespace, dash and zero-width noise don't change the result;
every output validates against the JSON Schema (JavaScript and Python with a schema library,
Go with a small validator of its own, C through a Node script that checks every output the
fixture runner writes; the Rust output is compared with JavaScript byte for byte instead, see
below);
no word of the input goes missing from the output (the Rust, Go and C suites);
parse(format(parse(s))) round-trips.
The Go module also has fuzz targets for Parse,
ParseArtists, Format,
ParseTracklist,
ApplyEdits,
Track.UnmarshalJSON and the internal pipeline (go test -fuzz) that run the same checks on
whatever the fuzzer finds, and a test that calls the parser, the tracklist functions and the edits
from 16 goroutines at once under the race detector.
The C library has the same kinds of tests, plus a few that only C needs:
libFuzzer targets for parse, parse_artists, format, parse_tracklist, apply_edits and
the JSON door that the cross-port diff runs, seeded with every fixture input and checking the
same invariants;
an out-of-memory test: for about 50 inputs across the API, the n-th allocation fails, for every n
until the call succeeds, and each call must return NULL or the correct result and free every
block it took;
16 threads calling a shared parser, the free functions, the tracklist functions and the edits at
once, under ThreadSanitizer in CI, against the bytes of a sequential run;
the whole fixture set after setlocale(LC_ALL, "") and under German and Turkish locales, which
must give the bytes of the C locale;
the suite under AddressSanitizer with UndefinedBehaviorSanitizer (GCC and Clang),
MemorySanitizer and Valgrind, so an out-of-bounds read, an uninitialized value, a leak or
undefined behaviour fails it.
For tracklists, on random multi-line text and random edit lists:
raw + eol over all entries gives back the input, and lead + time + gap + rest gives raw;
applyEdits(t, []) returns t, and an edit never touches a line it doesn't name;
shifting forward and back restores the text, unless something was clamped or upgraded;
10,000 lines parse inside a ceiling each suite sets for itself: 3 s in JavaScript (it takes
about 0.8 s), 15 s in Python, 3 s in an optimized Rust build, 3 s in Go (it takes about 0.35 s)
and 3 s in C (it takes about 0.35 s too);
Markdown emphasis around a time or a track line gives the same kind, time and track as the plain
line.
A fixture only checks the fields it asserts. So
compare-ports.mjs runs
every fixture input through all five ports, JavaScript, Python, Rust, Go and C, and diffs the complete
JSON output, tracklists and edits included. The difference count is zero.
fuzz-ports.mjs does the
same with random input, which reaches places no fixture does. The Rust crate and the Go module were
each run against JavaScript on about 500,000 random single-track cases and 290,000 random
tracklists with edits, again with zero differences. CI runs the C library against JavaScript on
50,000 random tracks and 10,000 tracklists on every push and pull request that c.yml runs on.
The tracklist rules were written against a private corpus of real podcast tracklists, a little over
5,000 lines. It can't be published, so it stays out of the repository. Every surprising line in it
became a handwritten fixture instead, which is why the tracklist fixtures talk about "real lines".
cargo test --locked on stable and on Rust 1.74. On stable only: rustfmt, clippy, the tests with --all-features and a publish dry run. Also the Rust output against the built JavaScript package on every fixture
go vet and go test -race on Go 1.22 and on stable, with the artist-side test data written from the built JavaScript package. On stable only: gofmt, staticcheck and the full Unicode check against Node. Also checks that the generated data and Unicode tables are current, that go.mod has no dependencies and that no unstable sort.Slice is used, and compares the Go output with the built JavaScript package on every fixture. A separate job builds and tests go/ on its own, as the module zip holds it. A weekly scheduled run fuzzes every fuzz target for three to five minutes
CMake builds with -Werror and ctest (fixtures, schema check, unit, property, thread, locale and out-of-memory tests, the C++ wrapper in C++17 and C++20, the examples, the exported-symbol check and the install, pkg-config, amalgamation and FetchContent consumers) with GCC and Clang on Linux, GCC on ARM64, a shared-library build, Apple Clang on macOS and MSVC on Windows; 32-bit x86 and GCC 9 with CMake 3.16. The suite under ASan + UBSan (GCC and Clang), ThreadSanitizer, MemorySanitizer and Valgrind, and under German and Turkish locales. Also checks that the generated data and Unicode tables are current and match the Go port's sample, clang-format, a grep that keeps locale-dependent and unstable calls (qsort, strtod, <ctype.h>, the printf family) out of src/, and the amalgamation; compares the C output with the built JavaScript package on every fixture and on random input. A weekly scheduled run fuzzes every libFuzzer target for ten minutes
Contributing for how a rule change goes through the spec,
the fixtures and the five ports.
How it works for the pipeline the fixtures exercise.
You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.