-
Notifications
You must be signed in to change notification settings - Fork 6k
scripts: validate the first Comments-URI entry #2233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
grandpig
wants to merge
1
commit into
bitcoin:master
Choose a base branch
from
grandpig:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+74
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.