chore: check the suite colour before comparing documented counts
Assisted-by: GLM 5.3
This commit is contained in:
+23
-10
@@ -1,4 +1,7 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
# Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
# docs-drift compares the toml-test suite counts the documentation names with
|
# 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
|
# 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
|
# README.md and docs/ARCHITECTURE.md quote them; this is the check that keeps
|
||||||
@@ -6,26 +9,36 @@
|
|||||||
|
|
||||||
use v5.40;
|
use v5.40;
|
||||||
|
|
||||||
my $out = qx{toml-test test -decoder=bin/interpres-decode -encoder='bin/interpres-decode -encode' -toml=1.1 2>&1};
|
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"
|
die "docs-drift: toml-test failed to run; build the adapter first (just build)\n"
|
||||||
if !defined $out || $out =~ /not found|No such file/;
|
if !defined $out || $out =~ /not found|No such file/;
|
||||||
|
# A red run is a failure to answer, not a drift: the counts it prints describe
|
||||||
|
# a suite that did not pass, and sending the maintainer to correct counts that
|
||||||
|
# are correct would be the wrong diagnosis.
|
||||||
|
die "docs-drift: the toml-test run failed; fix the suite before comparing counts\n"
|
||||||
|
if $? != 0;
|
||||||
|
|
||||||
my ($valid) = $out =~ /valid tests:\s+(\d+) passed/;
|
my %live;
|
||||||
my ($invalid) = $out =~ /invalid tests:\s+(\d+) passed/;
|
for my $kind (qw(valid invalid encoder)) {
|
||||||
die "docs-drift: could not read the suite counts from the toml-test output\n"
|
my ($passed) = $out =~ /\b$kind tests:\s+(\d+) passed/;
|
||||||
unless defined $valid && defined $invalid;
|
die "docs-drift: could not read the $kind count from the toml-test output\n"
|
||||||
print "docs-drift: the suite now stands at $valid valid and $invalid invalid cases\n";
|
unless defined $passed;
|
||||||
|
my ($failed) = $out =~ /\b$kind tests:\s+\d+ passed, (\d+) failed/;
|
||||||
|
die "docs-drift: the $kind run has $failed failures; fix the suite first\n"
|
||||||
|
if defined $failed && $failed != 0;
|
||||||
|
$live{$kind} = $passed;
|
||||||
|
}
|
||||||
|
print "docs-drift: the suite now stands at $live{valid} valid, $live{invalid} invalid and $live{encoder} encoder cases\n";
|
||||||
|
|
||||||
my $drift = 0;
|
my $drift = 0;
|
||||||
for my $file ('README.md', 'docs/ARCHITECTURE.md') {
|
for my $file ('README.md', 'docs/ARCHITECTURE.md') {
|
||||||
open(my $fh, '<', $file) or die "docs-drift: cannot read $file: $!\n";
|
open(my $fh, '<', $file) or die "docs-drift: cannot read $file: $!\n";
|
||||||
my $text = do { local $/; <$fh> };
|
my $text = do { local $/; <$fh> };
|
||||||
close($fh);
|
close($fh);
|
||||||
while ($text =~ /(\d+)\s+(valid|invalid)/g) {
|
while ($text =~ /(\d+)\s+(valid|invalid|encoder)/g) {
|
||||||
my ($quoted, $kind) = ($1, $2);
|
my ($quoted, $kind) = ($1, $2);
|
||||||
my $live = $kind eq 'valid' ? $valid : $invalid;
|
if ($quoted != $live{$kind}) {
|
||||||
if ($quoted != $live) {
|
print "docs-drift: $file quotes $quoted $kind cases, the suite says $live{$kind}\n";
|
||||||
print "docs-drift: $file quotes $quoted $kind cases, the suite says $live\n";
|
|
||||||
$drift = 1;
|
$drift = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user