Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sed command fails when using Windows paths - colon delimeter interferes with path #261

Open
2 tasks done
ethanclevenger91 opened this issue Apr 17, 2020 · 1 comment
Open
2 tasks done

Comments

@ethanclevenger91
Copy link

ethanclevenger91 commented Apr 17, 2020

Bug Report

Describe the current, buggy behavior

Scaffolding tests in Windows requires manual intervention in wp-tests-config.php (see this issue) when using the default tests path. Manually setting WP_CORE_DIR and WP_TESTS_DIR can prevent this by using something like C:\Users{User}\AppData\Local\Temp/wordpress/ and then running install-wp-tests. But the colon causes the following sed command to fail:

sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php

Describe how other contributors can replicate this bug

  • Pull down a plugin with tests to be run that were scaffolded with this package
  • Set environment variables for both WP_CORE_DIR and WP_TESTS_DIR with the format C:/somewhere/you/want/to/keep/tests as opposed to /c/somewhere/you/want/to/keep/tests:
export WP_TESTS_DIR='D:/dev/testing-wordpress/tests'
export WP_CORE_DIR='D:/dev/testing-wordpress/core'
  • Run install-wp-tests
  • Receive sed error: sed: -e expression #1, char 36: unknown option to `s'
  • Remove the directories that were created

Workaround-ish

  • Update env vars using the more "traditional"(?) format:
export WP_TESTS_DIR='/d/dev/testing-wordpress/tests'
export WP_CORE_DIR='/d/dev/testing-wordpress/core'
  • Remove the directories that were created (so start fresh)
  • Run install-wp-tests
  • Succeeds
  • Attempt to run tests
  • Get require_once error described here, which can be fixed with the last comment shared there

Describe what you would expect as the correct outcome

Ideally you would get started testing without manual intervention.

Let us know what environment you are running this on

OS:     Windows NT 10.0 build 18363 (Windows 10) AMD64
Shell:  C:\Program Files\Git\usr\bin\bash.exe
PHP binary:     C:/Users/ethan/bin/php/php
PHP version:    7.4.4
php.ini used:   C:\Users\ethan\bin\php\php.ini
WP-CLI root dir:        C:\Users\ethan\AppData\Roaming\Composer\vendor\wp-cli\wp-cli
WP-CLI vendor dir:      C:\Users\ethan\AppData\Roaming\Composer\vendor
WP_CLI phar path:
WP-CLI packages dir:    C:\Users\ethan/.wp-cli/packages/
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.4.0

Provide a possible solution

The colon is the problem and either needs to be escaped or another delimiter used. Maybe |? The PR for that is like two lines and I've successfully tested that as an alternative, so I can provide if necessary.

@ethanclevenger91 ethanclevenger91 changed the title sed command fails when using Windows paths - colons in path should be escaped sed command fails when using Windows paths - colon delimeter interferes with path Apr 17, 2020
@swissspidy
Copy link
Member

This script could definitely benefit from an overhaul, see also #322

At the same time there are also more modern approaches like for instance https://github.com/wp-phpunit/wp-phpunit

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

No branches or pull requests

2 participants