Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/github-action-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- run: prove scripts/t/*.t
- run: scripts/buildtable.pl >/tmp/table.mediawiki || exit 1
Diff-Checks:
name: "Diff Checks (fails until number assignment)"
Expand Down
2 changes: 1 addition & 1 deletion scripts/buildtable.pl
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
die "Unacceptable license $val in $fn" unless exists $AcceptableLicenses{$val} or ($val eq 'PD' and exists $GrandfatheredPD{$bipnum}) or ($val eq 'CC-BY-SA-4.0' and exists $GrandfatheredCCBySA{$bipnum});
}
} elsif ($field eq 'Comments-URI') {
if ($found{'Comments-URI'}) {
if (not $found{'Comments-URI'}) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes sense to me. I see that I introduced this mistake in #1820. Thanks for catching that.

It’s not clear to me why we should be adding the second script to our build actions. It seems to be a proof that the bugfix change is correct, but if that’s the case adding it to the build actions going forth seems unnecessary.

my $first_comments_uri = sprintf('https://github.com/bitcoin/bips/wiki/Comments:BIP-%04d', $bipnum);
die "First Comments-URI must be exactly \"$first_comments_uri\" in $fn" unless $val eq $first_comments_uri;
}
Expand Down
72 changes: 72 additions & 0 deletions scripts/t/buildtable-comments-uri.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/perl
use strict;
use warnings;

use File::Spec;
use File::Temp qw(tempdir);
use FindBin;
use Test::More;

my $buildtable = File::Spec->catfile($FindBin::Bin, '..', 'buildtable.pl');

sub run_buildtable {
my (@comments_uris) = @_;
my $dir = tempdir(CLEANUP => 1);
my $bip = File::Spec->catfile($dir, 'bip-0001.mediawiki');
my $stdout = File::Spec->catfile($dir, 'stdout');
my $stderr = File::Spec->catfile($dir, 'stderr');

open my $BIP, '>', $bip or die "Could not create $bip: $!";
print {$BIP} "<pre>\n";
print {$BIP} " BIP: 1\n";
print {$BIP} " Title: Test BIP\n";
print {$BIP} " Authors: Test Author <test\@example.com>\n";
print {$BIP} " Comments-URI: $comments_uris[0]\n";
for my $uri (@comments_uris[1 .. $#comments_uris]) {
print {$BIP} ' ' x (4 + length('Comments-URI')), "$uri\n";
}
print {$BIP} " Status: Draft\n";
print {$BIP} " Type: Process\n";
print {$BIP} " Assigned: 2026-08-03\n";
print {$BIP} "</pre>\n";
close $BIP or die "Could not close $bip: $!";

my $pid = fork // die "Could not fork: $!";
if ($pid == 0) {
chdir $dir or die "Could not chdir to $dir: $!";
open STDOUT, '>', $stdout or die "Could not open $stdout: $!";
open STDERR, '>', $stderr or die "Could not open $stderr: $!";
exec $^X, $buildtable;
die "Could not execute $buildtable: $!";
}
waitpid $pid, 0;
my $exit_code = $? >> 8;

open my $ERRORS, '<', $stderr or die "Could not open $stderr: $!";
my $errors = do { local $/; <$ERRORS> };
close $ERRORS;

return ($exit_code, $errors);
}

my $wiki_uri = 'https://github.com/bitcoin/bips/wiki/Comments:BIP-0001';

{
my ($exit_code, $errors) = run_buildtable($wiki_uri);
is($exit_code, 0, 'accepts the standard Comments wiki URI');
is($errors, '', 'does not report an error for the standard Comments wiki URI');
}

{
my ($exit_code, $errors) = run_buildtable('https://example.com/wrong');
isnt($exit_code, 0, 'rejects a nonstandard first Comments-URI');
like($errors, qr/First Comments-URI must be exactly/, 'reports the invalid first Comments-URI');
}

{
my ($exit_code, $errors) = run_buildtable($wiki_uri, 'https://example.com/discussion');
is($exit_code, 0, 'accepts an additional external discussion URI');
is($errors, '', 'does not report an error for an additional discussion URI');
}

done_testing();