Skip to content

Commit aec0d01

Browse files
authored
Tests: Improve Windows compatibility (#382)
1 parent a0d8996 commit aec0d01

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

features/install-wp-tests.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Note: You need to execute the mysql command `GRANT ALL PRIVILEGES ON wp_cli_test_scaffold.* TO "wp_cli_test"@"localhost" IDENTIFIED BY "{DB_PASSWORD}";` for these tests to work locally.
22
Feature: Scaffold install-wp-tests.sh tests
33

4+
# TODO: Fix this on Windows. Fails because /usr/bin/env bash is not available.
5+
@skip-windows
46
Scenario: Help should be displayed
57
Given a WP install
68
And I run `wp plugin path`

features/scaffold-plugin-tests.feature

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
Feature: Scaffold plugin unit tests
22

3+
# TODO: Fix this on Windows. Fails because is_executable() fails for .sh files.
4+
@skip-windows
35
Scenario: Scaffold plugin tests
46
Given a WP install
57
When I run `wp plugin path`
@@ -220,10 +222,7 @@ Feature: Scaffold plugin unit tests
220222
Then the {RUN_DIR}/wp-content/plugins/foo.php file should exist
221223

222224
When I try `wp scaffold plugin-tests foo`
223-
Then STDERR should be:
224-
"""
225-
Error: Invalid plugin slug specified. No such target directory '{RUN_DIR}/wp-content/plugins/foo'.
226-
"""
225+
Then STDERR should match #Error: Invalid plugin slug specified\. No such target directory '.*wp-content/plugins/foo'\.#
227226
And the return code should be 1
228227

229228
When I try `wp scaffold plugin-tests .`
@@ -271,10 +270,7 @@ Feature: Scaffold plugin unit tests
271270
When I run `rm -rf {PLUGIN_DIR} && touch {PLUGIN_DIR}`
272271
Then the return code should be 0
273272
When I try `wp scaffold plugin-tests hello-world`
274-
Then STDERR should be:
275-
"""
276-
Error: Invalid plugin slug specified. No such target directory '{PLUGIN_DIR}'.
277-
"""
273+
Then STDERR should match #Error: Invalid plugin slug specified\. No such target directory '.*hello-world'\.#
278274
And the return code should be 1
279275

280276
Scenario: Scaffold plugin tests with a symbolic link

features/scaffold-theme-tests.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ Feature: Scaffold theme unit tests
256256
When I run `rm -f {THEME_DIR}/twentytwelve && mv -f {THEME_DIR}/hide-twentytwelve {THEME_DIR}/twentytwelve`
257257
Then the return code should be 0
258258

259+
# TODO: Fix this on Windows. Fails because unlink fails on directories.
260+
@skip-windows
259261
Scenario: Scaffold theme tests with a symbolic link
260262
# Temporarily move the whole theme dir and create a symbolic link to it.
261263
When I run `mv -f {THEME_DIR} {RUN_DIR}/alt-themes && ln -s {RUN_DIR}/alt-themes {THEME_DIR}`

src/Scaffold_Command.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,8 @@ protected function create_files( $files_and_contents, $force ) {
10081008
continue;
10091009
}
10101010

1011+
$contents = str_replace( "\r\n", "\n", $contents );
1012+
10111013
$wp_filesystem->mkdir( dirname( $filename ) );
10121014

10131015
// Create multi-level folders.

0 commit comments

Comments
 (0)