You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6470794
Browse filesBrowse the repository at this point in the historyBrowse files
Declare and check the commands that scenarios need
Scenarios can declare commands they run that are not always installed with
@require-bin-<name> tags. Where a command is not available, its scenarios
are left out and reported like other unmet requirements, instead of failing
halfway through.
The existing @require-composer, @require-download and
@require-opcache-save-comments tags never filtered anything and are checked
now. Unknown requirement tags are reported, as they would not filter
anything either.
When a command fails because a command it runs does not exist, the failure
names the tag to add, and the Gherkin linting lists scenarios that run
commands which are not always installed without declaring them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
&& ! preg_match( "/'([A-Za-z0-9_.+-]+)' is not recognized as an internal or external command/", $stderr, $matches )
32
+
) {
33
+
return'';
34
+
}
35
+
36
+
return"\n\nThe command `{$matches[1]}` was not found. If the scenario needs it, tag it with @require-bin-{$matches[1]}, so that environments without it report the scenario as not run instead of failing it.";
Copy file name to clipboardExpand all lines: src/Context/WhenStepDefinitions.php
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,8 @@ public function wpcli_tests_invoke_proc( $proc, $mode ) {
32
32
$message .= "\n\nThe command unexpectedly exited with status {$status}. If you expect a non-zero exit status, use `When I try [...]`. Else, this may be a bug in your code or test.";
"Feature: Commands\n\n @require-bin-wpclinonexistentcommand\n Scenario: Needs a missing command\n Given a step\n\n @require-bin-php\n Scenario: Needs PHP\n Given a step\n"
$this->assertStringContainsString( '@require-bin-wpclinonexistentcommand, as the command "wpclinonexistentcommand" is not available: ', $result['stderr'] );
$this->assertStringContainsString( 'Warning: @require-wpclinonexistent is not a known requirement and does not filter anything: ', $result['stderr'] );
$this->assertStringContainsString( "The command `{$command}` was not found. If the scenario needs it, tag it with @require-bin-{$command}", $this->hint( $stderr ) );
fwrite( STDERR, sprintf( "Warning: %s is not a known requirement and does not filter anything: %s\n", $tag, implode( ', ', array_unique( $paths ) ) ) );
464
+
}
465
+
}
466
+
387
467
/**
388
468
* Get the scenarios of the feature files with the tags that apply to them.
389
469
*
@@ -448,6 +528,22 @@ function describe_skip_tag( $tag, $context ) {
448
528
returnarray( true, "the PHP extension \"{$matches[1]}\" is not loaded" );
449
529
}
450
530
531
+
if ( preg_match( '/^@require-bin-(.+)$/', $tag, $matches ) ) {
532
+
returnarray( true, "the command \"{$matches[1]}\" is not available" );
533
+
}
534
+
535
+
if ( '@require-composer' === $tag ) {
536
+
returnarray( true, 'the command "composer" is not available' );
537
+
}
538
+
539
+
if ( '@require-download' === $tag ) {
540
+
returnarray( true, 'downloads.wordpress.org cannot be reached' );
541
+
}
542
+
543
+
if ( '@require-opcache-save-comments' === $tag ) {
0 commit comments