Skip to content

Conversation

@gitlost
Copy link
Contributor

@gitlost gitlost commented Jan 5, 2018

Related #4245

Adds processing of special variable {INVOKE_WP_CLI_WITH_PHP_ARGS-} to FeatureContext::replace_variables() so that PHP args can be given to either the wp-cli phar or the shell file, in order to test stuff under varying PHP conditions.

Uses it in aliases.feature, help.feature and runcommand.feature to test running with proc_open()/proc_close() unavailable, and removes corresponding phpunit tests.

Before (and still with the remaining phpunit tests) was only testing git not phar invocation. Will be useful in other cases also (eg wp-cli/package-command#27).

@gitlost gitlost added the scope:testing Related to testing label Jan 5, 2018
@gitlost gitlost added this to the 1.5.0 milestone Jan 5, 2018
@gitlost gitlost requested a review from a team January 5, 2018 16:39
@@ -332,11 +332,45 @@ public function getHookDefinitionResources() {
* Replace {VARIABLE_NAME}. Note that variable names can only contain uppercase letters and underscores (no numbers).
Copy link
Member

Choose a reason for hiding this comment

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

The comment about variable name requirements is not technically correct anymore.

public function replace_variables( $str ) {
$ret = preg_replace_callback( '/\{([A-Z_]+)\}/', array( $this, '_replace_var' ), $str );
if ( false !== strpos( $str, '{INVOKE_WP_CLI_WITH_PHP_ARGS-' ) ) {
$str = $this->_replace_invoke_wp_cli_with_php_args( $str );
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a fan of leading underscores in method names when we can just mark them as private.
Instead of matching the other functions, maybe consider just changing them to get rid of that underscore in all of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, looks funny too - will remove underscore from all...

@gitlost
Copy link
Contributor Author

gitlost commented Jan 6, 2018

Was thinking about allowing numbers in standard variable names (except at start), as it's a bit of a gotcha?

@schlessera
Copy link
Member

Yes, adding digits (except as the first character) makes sense, to adhere to POSIX:

Environment variable names used by the utilities in the Shell and Utilities volume of IEEE Std 1003.1-2001 consist solely of uppercase letters, digits, and the '_' (underscore) from the characters defined in Portable Character Set and do not begin with a digit. Other characters may be permitted by an implementation; applications shall tolerate the presence of such names.

I wonder though whether digits were left out because of a technical reason further down the pipe...?

@gitlost
Copy link
Contributor Author

gitlost commented Jan 6, 2018

adhere to POSIX

Even better!

I wonder though whether digits were left out because of a technical reason further down the pipe...?

It's good it's restrictive as it makes special processing such as here possible, but I can't think of any issue that could arise by allowing digits...

@schlessera
Copy link
Member

Yes, let's go ahead with adding digits then. 👍

@gitlost
Copy link
Contributor Author

gitlost commented Jan 6, 2018

Made that digits change. Also added steps.feature to test it.

Re latter there's some changes to steps I needed to make to get behat running on Windows where it wasn't obvious that the behaviour wasn't comprised or slightly different so it'll good to have this to "test the tests", plus could act as documentation/examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants