Skip to content

Commit fcc1f29

Browse files
authored
Merge pull request #10 from wp-cli/configurable-features-folder
Make features folder configurable in behat-tags.php
2 parents c68fa22 + e82332f commit fcc1f29

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

utils/behat-tags.php

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@
1313
* vendor/bin/behat --format progress $BEHAT_TAGS
1414
*/
1515

16-
function version_tags( $prefix, $current, $operator = '<' ) {
16+
function version_tags(
17+
$prefix,
18+
$current,
19+
$operator = '<',
20+
$features_folder = 'features'
21+
) {
1722
if ( ! $current ) {
1823
return array();
1924
}
2025

21-
exec( "grep '@{$prefix}-[0-9\.]*' -h -o features/*.feature | uniq", $existing_tags );
26+
exec( "grep '@{$prefix}-[0-9\.]*' -h -o {$features_folder}/*.feature | uniq",
27+
$existing_tags );
2228

2329
$skip_tags = array();
2430

@@ -32,27 +38,34 @@ function version_tags( $prefix, $current, $operator = '<' ) {
3238
return $skip_tags;
3339
}
3440

41+
$features_folder = getenv( 'BEHAT_FEATURES_FOLDER' ) ?: 'features';
3542
$wp_version = getenv( 'WP_VERSION' );
3643
$wp_version_reqs = array();
3744
// Only apply @require-wp tags when WP_VERSION isn't 'latest', 'nightly' or 'trunk'.
3845
// 'latest', 'nightly' and 'trunk' are expected to work with all features.
39-
if ( $wp_version && ! in_array( $wp_version, array( 'latest', 'nightly', 'trunk' ), true ) ) {
46+
if ( $wp_version &&
47+
! in_array( $wp_version, array( 'latest', 'nightly', 'trunk' ), true ) ) {
4048
$wp_version_reqs = array_merge(
41-
version_tags( 'require-wp', $wp_version, '<' ),
42-
version_tags( 'less-than-wp', $wp_version, '>=' )
49+
version_tags( 'require-wp', $wp_version, '<', $features_folder ),
50+
version_tags( 'less-than-wp', $wp_version, '>=', $features_folder )
4351
);
4452
} else {
4553
// But make sure @less-than-wp tags always exist for those special cases. (Note: @less-than-wp-latest etc won't work and shouldn't be used).
46-
$wp_version_reqs = array_merge( $wp_version_reqs, version_tags( 'less-than-wp', '9999', '>=' ) );
54+
$wp_version_reqs = array_merge( $wp_version_reqs,
55+
version_tags( 'less-than-wp', '9999', '>=', $features_folder ) );
4756
}
4857

4958
$skip_tags = array_merge(
5059
$wp_version_reqs,
51-
version_tags( 'require-php', PHP_VERSION, '<' ),
52-
version_tags( 'less-than-php', PHP_VERSION, '>=' ) // Note: this was '>' prior to WP-CLI 1.5.0 but the change is unlikely to cause BC issues as usually compared against major.minor only.
60+
version_tags( 'require-php', PHP_VERSION, '<', $features_folder ),
61+
62+
// Note: this was '>' prior to WP-CLI 1.5.0 but the change is unlikely to
63+
// cause BC issues as usually compared against major.minor only.
64+
version_tags( 'less-than-php', PHP_VERSION, '>=', $features_folder )
5365
);
5466

55-
# Skip Github API tests if `GITHUB_TOKEN` not available because of rate limiting. See https://github.com/wp-cli/wp-cli/issues/1612
67+
// Skip Github API tests if `GITHUB_TOKEN` not available because of rate
68+
// limiting. See https://github.com/wp-cli/wp-cli/issues/1612
5669
if ( ! getenv( 'GITHUB_TOKEN' ) ) {
5770
$skip_tags[] = '@github-api';
5871
}
@@ -61,9 +74,12 @@ function version_tags( $prefix, $current, $operator = '<' ) {
6174
$skip_tags[] = '@broken';
6275

6376
# Require PHP extension, eg 'imagick'.
64-
function extension_tags() {
77+
function extension_tags( $features_folder = 'features' ) {
6578
$extension_tags = array();
66-
exec( "grep '@require-extension-[A-Za-z_]*' -h -o features/*.feature | uniq", $extension_tags );
79+
exec(
80+
"grep '@require-extension-[A-Za-z_]*' -h -o {$features_folder}/*.feature | uniq",
81+
$extension_tags
82+
);
6783

6884
$skip_tags = array();
6985

@@ -78,9 +94,8 @@ function extension_tags() {
7894
return $skip_tags;
7995
}
8096

81-
$skip_tags = array_merge( $skip_tags, extension_tags() );
97+
$skip_tags = array_merge( $skip_tags, extension_tags( $features_folder ) );
8298

8399
if ( ! empty( $skip_tags ) ) {
84100
echo '--tags=~' . implode( '&&~', $skip_tags );
85101
}
86-

0 commit comments

Comments
 (0)