GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • trackparse
  • GitHub
  • npm
  • PyPI
  • crates.io
  • pkg.go.dev
  • Introduction
  • Getting started
  • Playgroundlive
  • What it understands
  • Artists and credits
  • Versions and remixes
  • Junk, flags and prefixes
  • Modes

This view

  • Original page
  • New address

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.

Handwritten: 1,280 cases

Section titled “Handwritten: 1,280 cases”

Each case cites the spec rules it exercises, and 65 of them spell out the complete output, field by field, so nothing drifts unnoticed.

Group Cases What's in there
Regressions 273 Every test from two real-world parsers this library replaces, and the known failures of get-artist-title and friends
Versions and brackets 90 Every version keyword, generic heads (Radio Edit → radio), multi-version groups, feat inside brackets
Artists 76 Joiners, guards (AC/DC, Mumford & Sons, Malcolm X), knownArtists, dedup
Title credits and producers 57 Title ft. X, (prod. by X), self-produced artists
Separators and suffixes 63 Dash variants, - Remastered 2015, unspaced and asymmetric dashes
Prefixes, junk, flags 111 Track numbers vs 2 Unlimited, cue times, every junk kind, years, explicit/clean
Modes 65 YouTube pipes, "Title" by Artist, uploader fallback, file names
Unicode and normalization 71 NFC, zero-width characters, fullwidth brackets, Cyrillic, CJK, Turkish İ
format, parseArtists, unknown IDs 94 Round trips, canonical joiners, ID - ID
Labels after a bullet 70 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
Tracklist edits 81 Style keeping, shift, clamp, sort, insert/delete line endings, invalid edits, locality

Generated: 12,285 cases

Section titled “Generated: 12,285 cases”

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.

Scenario Cases Scenario Cases
artists × joiners 1,811 kitchen sink (pairwise + random) 1,589
versions 1,650 junk × YouTube 806
dash suffixes 1,174 file names 780
dedup 1,008 unicode 674
feat placement 922 prefixes 577
tracklists 826 tracklists with Markdown 110
bullet labels 358

Properties

Section titled “Properties”

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;
  • normalize is idempotent;
  • 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.

Port against port

Section titled “Port against port”

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.

Real tracklists

Section titled “Real tracklists”

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".

In CI

Section titled “In CI”

Every push to main runs one workflow per port, plus one for the spec. A pull request runs the workflows whose files it touches:

Workflow What it runs
js.yml The full suite on Node 22 and 24, and every fixture against the built package on Node 18 and 20
python.yml ruff, mypy --strict and pytest on Python 3.9 to 3.14, and every fixture against the installed wheel
rust.yml 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.yml 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
c.yml 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
spec.yml Fixture validation, stale generated files, the generator's own tests, and that the version numbers of the spec and the five ports match

Run it yourself

Section titled “Run it yourself”
# JavaScript (from the repository root; Node 22 or newer, pnpm)
pnpm install
pnpm test # fixtures, properties, generator tests
pnpm conformance # pass rate per fixture file and per spec rule
# Python (uv)
cd python
uv run pytest # the same fixtures and invariants
uv run python scripts/conformance.py # pass rate per fixture file and per spec rule
# Rust (1.74 or newer)
cd ../rust
cargo test # the same fixtures and invariants
TRACKPARSE_REPORT=1 cargo test --test fixtures -- --nocapture # pass rate per file and per rule
# Go (1.22 or newer)
cd ../go
go test ./... # the same fixtures, invariants and unit tests
TRACKPARSE_REPORT=1 go test -run TestFixtures -v . # pass rate per file and per rule
# C (a C11 compiler, CMake 3.16 or newer)
cd ..
cmake -S c -B c/build-test
cmake --build c/build-test
ctest --test-dir c/build-test --output-on-failure # the same fixtures, schema check, unit tests
TRACKPARSE_REPORT=1 c/build-test/trackparse-fixtures spec/fixtures/*/*.json # pass rate per file and per rule
cmake -S c -B c/build-asan -DTRACKPARSE_SANITIZE=ON # the same suite under ASan and UBSan
cmake --build c/build-asan && ctest --test-dir c/build-asan -LE consumer
# All five against each other (from the root)
pnpm build
node scripts/compare-ports.mjs # must print "differences: 0"
node scripts/fuzz-ports.mjs # the same diff on random tracks and tracklists with edits

The C suite builds in c/build-test, not c/build: compare-ports configures c/build with the tests off.

See also

Section titled “See also”
  • Ports for what each port had to get right.
  • 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.