10000 [appveyor] Fix command line by nicolas-grekas · Pull Request #16061 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[appveyor] Fix command line #16061

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

Merged
merged 1 commit into from
Oct 2, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions phpunit
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/usr/bin/env php
<?php

use Symfony\Component\Process\ProcessUtils;

error_reporting(-1);
require __DIR__.'/src/Symfony/Component/Process/ProcessUtils.php';

$PHPUNIT_VERSION = '4.8';
$PHPUNIT_DIR = __DIR__.'/.phpunit';
Expand Down Expand Up @@ -32,7 +35,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit")) {
chdir($oldPwd);
}

$cmd = array_map('escapeshellarg', $argv);
$cmd = array_map('Symfony\Component\Process\ProcessUtils::escapeArgument', $argv);
$exit = 0;

if (isset($argv[1]) && 'symfony' === $argv[1]) {
Expand All @@ -51,11 +54,13 @@ if ($phpIniMatrix) {

$phpDir = dirname(`where.exe php`);

$newCmd = '(SET X=0';
$newCmd = 'cmd /v:on /d /c "(SET X=0';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure that windows flags are case insensitive ? they are uppercase in the Process component

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I tested on my windows vm, this works fine

foreach ($phpIniMatrix as $iniFile) {
$newCmd .= " & copy /Y $phpDir\\$iniFile $phpDir\\php.ini & echo. & echo Running tests with $iniFile: & $cmd & (if %%errorlevel%% NEQ 0 SET X=1)";
$newCmd .= " & copy /Y $phpDir\\$iniFile $phpDir\\php.ini & echo. & echo Running tests with $iniFile: & ($cmd || SET X=1)";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be && rather than & btw ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

& is the bash equivalent of ;, which is what we want: a failure in a matrix line should not prevent the second line from running

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and I assume that copy and echo will never fail yes :) )

}
$cmd = $newCmd .= ' & exit %%X%%)';
$cmd = $newCmd .= ' & exit !X!)%2$s"';
} else {
$cmd .= ' %2$s';
}

if (isset($argv[1]) && 'symfony' === $argv[1]) {
Expand All @@ -73,9 +78,9 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {

// Run phpunit tests in parallel

$c = escapeshellarg($component);
$c = ProcessUtils::escapeArgument($component);

if ($proc = proc_open(sprintf($cmd, $c)." > $c/phpunit.stdout 2> $c/phpunit.stderr", array(), $pipes)) {
if ($proc = proc_open(sprintf($cmd, $c, " > $c/phpunit.stdout 2> $c/phpunit.stderr"), array(), $pipes)) {
$runningProcs[$component] = $proc;
} else {
$exit = 1;
Expand Down Expand Up @@ -137,7 +142,7 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
// Run regular phpunit in a subprocess

$errFile = tempnam(sys_get_temp_dir(), 'phpunit.stderr.');
if ($proc = proc_open(sprintf($cmd, '').' 2> '.escapeshellarg($errFile), array(1 => array('pipe', 'w')), $pipes)) {
if ($proc = proc_open(sprintf($cmd, '', ' 2> '.ProcessUtils::escapeArgument($errFile)), array(1 => array('pipe', 'w')), $pipes)) {
stream_copy_to_stream($pipes[1], STDOUT);
fclose($pipes[1]);
$exit = proc_close($proc);
Expand Down
0