Files
interpres/scripts/docs-drift.pl
T
petrbalvin f6a96379e6
Test / test (push) Successful in 1m37s
ci: schedule nightly race and fuzz, pin actions, add release-check and docs drift
Assisted-by: GLM 5.3 Flash
2026-09-22 01:26:48 +02:00

35 lines
1.5 KiB
Perl
Executable File

#!/usr/bin/env perl
# docs-drift compares the toml-test suite counts the documentation names with
# the run this repository produces now. A corpus change moves the counts, and
# README.md and docs/ARCHITECTURE.md quote them; this is the check that keeps
# the quotation honest. Builtins only, and the toml-test binary on PATH.
use v5.40;
my $out = qx{toml-test test -decoder=bin/interpres-decode -encoder='bin/interpres-decode -encode' -toml=1.1 2>&1};
die "docs-drift: toml-test failed to run; build the adapter first (just build)\n"
if !defined $out || $out =~ /not found|No such file/;
my ($valid) = $out =~ /valid tests:\s+(\d+) passed/;
my ($invalid) = $out =~ /invalid tests:\s+(\d+) passed/;
die "docs-drift: could not read the suite counts from the toml-test output\n"
unless defined $valid && defined $invalid;
print "docs-drift: the suite now stands at $valid valid and $invalid invalid cases\n";
my $drift = 0;
for my $file ('README.md', 'docs/ARCHITECTURE.md') {
open(my $fh, '<', $file) or die "docs-drift: cannot read $file: $!\n";
my $text = do { local $/; <$fh> };
close($fh);
while ($text =~ /(\d+)\s+(valid|invalid)/g) {
my ($quoted, $kind) = ($1, $2);
my $live = $kind eq 'valid' ? $valid : $invalid;
if ($quoted != $live) {
print "docs-drift: $file quotes $quoted $kind cases, the suite says $live\n";
$drift = 1;
}
}
}
die "docs-drift: the documentation has drifted from the suite\n" if $drift;
print "docs-drift: the documentation matches the suite\n";