Skip to content

Commit d86e3e9

Browse files
authored
Tests: further improve Windows compatibility (#519)
1 parent 0e4392a commit d86e3e9

6 files changed

Lines changed: 24 additions & 16 deletions

File tree

features/plugin-install.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ Feature: Install WordPress plugins
168168
Scenario: Paths aren't backslashed when destination folder already exists
169169
Given a WP install
170170

171-
When I run `pwd`
171+
When I run `wp eval "echo str_replace(chr(92), '/', getcwd());"`
172172
Then save STDOUT as {WORKING_DIR}
173173

174174
When I run `rm wp-content/plugins/akismet/akismet.php`

features/plugin-list-recently-active.feature

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ Feature: List recently active WordPress plugins
4242
| debug-bar |
4343
| site-secrets |
4444

45+
# Skipped on Windows due to non-portable shell command substitution and newline discrepancies
46+
@skip-windows
4547
Scenario: Use recently active plugin to activate plugins
4648
Given a WP install
4749

@@ -114,6 +116,8 @@ Feature: List recently active WordPress plugins
114116
| debug-bar |
115117
| site-secrets |
116118

119+
# Skipped on Windows due to non-portable shell command substitution and newline discrepancies
120+
@skip-windows
117121
Scenario: For a MU site, use recently active plugin to activate plugins
118122
Given a WP multisite install
119123

features/plugin-update.feature

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ Feature: Update WordPress plugins
198198
"""
199199

200200
# Akismet currently requires WordPress 5.8
201-
@require-wp-5.8
201+
# Skipped on Windows because chmod does not reliably enforce unwritable files cross-platform
202+
@require-wp-5.8 @skip-windows
202203
Scenario: Plugin updates that error should not report a success
203204
Given a WP install
204205
And I run `wp plugin install --force akismet --version=4.0`
@@ -237,7 +238,8 @@ Feature: Update WordPress plugins
237238
"""
238239
And the return code should be 0
239240

240-
@require-wp-5.2
241+
# Skipped on Windows because of sed usage that would need to be refactored for compatibility.
242+
@require-wp-5.2 @skip-windows
241243
Scenario: Updating all plugins with some of them having an invalid version shouldn't report an error
242244
Given a WP install
243245
And I run `wp plugin delete akismet`
@@ -378,7 +380,8 @@ Feature: Update WordPress plugins
378380
Success: Updated 2 of 2 plugins.
379381
"""
380382

381-
@require-wp-5.2
383+
# Skipped on Windows because of mkdir usage that would need to be refactored for compatibility.
384+
@require-wp-5.2 @skip-windows
382385
Scenario: Skip plugin update when plugin directory is a VCS checkout
383386
Given a WP install
384387
And I run `wp plugin install wordpress-importer --version=0.5 --force`
@@ -397,7 +400,8 @@ Feature: Update WordPress plugins
397400
"""
398401
And the return code should be 1
399402

400-
@require-wp-5.2
403+
# Skipped on Windows because of mkdir usage that would need to be refactored for compatibility.
404+
@require-wp-5.2 @skip-windows
401405
Scenario: Update plugin in VCS checkout when --include-vcs is set
402406
Given a WP install
403407
And I run `wp plugin install wordpress-importer --version=0.5 --force`

features/plugin.feature

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,13 @@ Feature: Manage WordPress plugins
356356
Automattic
357357
"""
358358

359-
When I run `wp eval 'echo get_site_transient("update_plugins")->last_checked;'`
359+
When I run `wp eval "echo get_site_transient('update_plugins')->last_checked;"`
360360
Then save STDOUT as {LAST_UPDATED}
361361

362362
When I run `wp plugin list --skip-update-check`
363363
Then STDOUT should not be empty
364364

365-
When I run `wp eval 'echo get_site_transient("update_plugins")->last_checked;'`
365+
When I run `wp eval "echo get_site_transient('update_plugins')->last_checked;"`
366366
Then STDOUT should be:
367367
"""
368368
{LAST_UPDATED}
@@ -371,7 +371,7 @@ Feature: Manage WordPress plugins
371371
When I run `wp plugin list`
372372
Then STDOUT should not be empty
373373

374-
When I run `wp eval 'echo get_site_transient("update_plugins")->last_checked;'`
374+
When I run `wp eval "echo get_site_transient('update_plugins')->last_checked;"`
375375
Then STDOUT should not contain:
376376
"""
377377
{LAST_UPDATED}
@@ -467,7 +467,7 @@ Feature: Manage WordPress plugins
467467
Given a WP install
468468

469469
When I run `rm -rf wp-content/plugins`
470-
And I run `if test -d wp-content/plugins; then echo "fail"; fi`
470+
And I run `wp eval "if ( is_dir('wp-content/plugins') ) echo 'fail';"`
471471
Then STDOUT should be empty
472472

473473
When I run `wp plugin install wordpress-importer --activate`

features/theme-update.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ Feature: Update WordPress themes
264264
And I run `wp theme path twentytwelve --dir`
265265
And save STDOUT as {THEME_DIR}
266266

267-
When I run `mkdir {THEME_DIR}/.git`
267+
When I run `wp eval "is_dir( '{THEME_DIR}/.git' ) || mkdir( '{THEME_DIR}/.git', 0777, true ) || exit( 1 );"`
268268
And I try `wp theme update twentytwelve`
269269
Then STDERR should contain:
270270
"""
@@ -282,7 +282,7 @@ Feature: Update WordPress themes
282282
And I run `wp theme path twentytwelve --dir`
283283
And save STDOUT as {THEME_DIR}
284284

285-
When I run `mkdir {THEME_DIR}/.git`
285+
When I run `wp eval "is_dir( '{THEME_DIR}/.git' ) || mkdir( '{THEME_DIR}/.git', 0777, true ) || exit( 1 );"`
286286
And I run `wp theme update twentytwelve --include-vcs`
287287
Then STDOUT should contain:
288288
"""

features/theme.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,13 @@ Feature: Manage WordPress themes
243243
When I run `wp theme list`
244244
Then STDOUT should not be empty
245245

246-
When I run `wp eval 'echo get_site_transient("update_themes")->last_checked;'`
246+
When I run `wp eval "echo get_site_transient( 'update_themes' )->last_checked;"`
247247
Then save STDOUT as {LAST_UPDATED}
248248

249249
When I run `wp theme list --skip-update-check`
250250
Then STDOUT should not be empty
251251

252-
When I run `wp eval 'echo get_site_transient("update_themes")->last_checked;'`
252+
When I run `wp eval "echo get_site_transient( 'update_themes' )->last_checked;"`
253253
Then STDOUT should be:
254254
"""
255255
{LAST_UPDATED}
@@ -258,7 +258,7 @@ Feature: Manage WordPress themes
258258
When I run `wp theme list`
259259
Then STDOUT should not be empty
260260

261-
When I run `wp eval 'echo get_site_transient("update_themes")->last_checked;'`
261+
When I run `wp eval "echo get_site_transient( 'update_themes' )->last_checked;"`
262262
Then STDOUT should not contain:
263263
"""
264264
{LAST_UPDATED}
@@ -269,7 +269,7 @@ Feature: Manage WordPress themes
269269
And I run `wp theme delete --all --force`
270270

271271
When I run `rm -rf wp-content/themes`
272-
And I run `if test -d wp-content/themes; then echo "fail"; fi`
272+
And I run `wp eval "if ( is_dir('wp-content/themes') ) echo 'fail';"`
273273
Then STDOUT should be empty
274274

275275
When I run `wp theme install twentytwelve --activate`
@@ -283,7 +283,7 @@ Feature: Manage WordPress themes
283283
Scenario: Attempt to activate or fetch a broken theme
284284
Given a WP install
285285

286-
When I run `mkdir -pv wp-content/themes/myth`
286+
When I run `wp eval "is_dir( 'wp-content/themes/myth' ) || mkdir( 'wp-content/themes/myth', 0777, true ) || exit( 1 );"`
287287
Then the wp-content/themes/myth directory should exist
288288

289289
When I try `wp theme activate myth`

0 commit comments

Comments
 (0)