Skip to content

Commit 4af7b32

Browse files
committed
fix - windows support
1 parent 985eba5 commit 4af7b32

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

.github/workflows/github.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,17 @@ jobs:
2323
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
2424
steps:
2525
- uses: actions/checkout@v3
26+
27+
- name: Configure git line endings (Windows)
28+
if: runner.os == 'Windows'
29+
run: git config --global core.autocrlf false
30+
2631
- uses: shivammathur/setup-php@v2
2732
with:
2833
php-version: ${{ matrix.php-versions }}
34+
ini-values: short_open_tag=1
2935
- name: Run tests
30-
run: composer require phpunit/phpunit; vendor/bin/phpunit; cd tests; php run_all_tests.php -v
36+
run: |
37+
composer require phpunit/phpunit
38+
php vendor/bin/phpunit
39+
php tests/run_all_tests.php -v

tests/run_all_tests.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,23 @@
1313
#
1414
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1515

16-
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' && !ini_get('short_open_tag')) {
17-
unset($argv[0]);
16+
if (!ini_get('short_open_tag') && '1' !== getenv('PHPFMT_SHORTTAG_RERUN')) {
17+
$args = $argv;
18+
array_shift($args);
19+
20+
$cmd = escapeshellarg(PHP_BINARY) . ' -dshort_open_tag=1 ' . escapeshellarg(__FILE__);
21+
if (!empty($args)) {
22+
$cmd .= ' ' . implode(' ', array_map('escapeshellarg', $args));
23+
}
24+
25+
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
26+
$cmd = 'set PHPFMT_SHORTTAG_RERUN=1&& ' . $cmd;
27+
} else {
28+
$cmd = 'PHPFMT_SHORTTAG_RERUN=1 ' . $cmd;
29+
}
30+
1831
$ret = 0;
19-
passthru($_SERVER['_'] . ' -dshort_open_tag=1 ' . __DIR__ . DIRECTORY_SEPARATOR . 'run_all_tests.php ' . implode(' ', $argv) . ' 2>&1', $ret);
32+
passthru($cmd . ' 2>&1', $ret);
2033
exit($ret);
2134
}
2235

0 commit comments

Comments
 (0)