Merge pull request #295 from corpsee/master

Fixes for windows
This commit is contained in:
Steve B 2014-03-10 09:49:47 +00:00
commit 7041478cec
5 changed files with 83 additions and 7 deletions

View file

@ -75,6 +75,10 @@ class CommandExecutor
$status = 0;
exec($command, $this->lastOutput, $status);
foreach ($this->lastOutput as &$lastOutput) {
$lastOutput = trim($lastOutput, '"');
}
if (!empty($this->lastOutput) && ($this->verbose|| $status != 0)) {
$this->logger->log($this->lastOutput);
}
@ -118,11 +122,12 @@ class CommandExecutor
return $this->rootDir . 'vendor/bin/' . $bin;
}
// Use "which"
$which = trim(shell_exec('which ' . $bin));
// Use "where" for windows and "which" for other OS
$findCmd = (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') ? 'which' : 'where';
$findCmdResult = trim(shell_exec($findCmd . ' ' . $bin));
if (!empty($which)) {
return $which;
if (!empty($findCmdResult)) {
return $findCmdResult;
}
}

View file

@ -45,8 +45,11 @@ class Composer implements \PHPCI\Plugin
$this->phpci->logFailure('Could not find Composer.');
return false;
}
$cmd = $composerLocation . ' --no-ansi --no-interaction ';
$cmd = '';
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$cmd = 'php ';
}
$cmd .= $composerLocation . ' --no-ansi --no-interaction ';
$cmd .= ($this->preferDist ? '--prefer-dist' : null) . ' --working-dir="%s" %s';
return $this->phpci->executeCommand($cmd, $this->directory, $this->action);

44
Tests/bootstrap.php Normal file
View file

@ -0,0 +1,44 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2013, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link http://www.phptesting.org/
*/
// Let PHP take a guess as to the default timezone, if the user hasn't set one:
date_default_timezone_set(@date_default_timezone_get());
// Set up a basic autoloader for PHPCI:
$autoload = function ($class) {
$file = str_replace(array('\\', '_'), '/', $class);
$file .= '.php';
if (substr($file, 0, 1) == '/') {
$file = substr($file, 1);
}
if (is_file(dirname(__DIR__) . '/' . $file)) {
include(dirname(__DIR__) . '/' . $file);
return;
}
};
spl_autoload_register($autoload, true, true);
// Load Composer autoloader:
require_once(dirname(__DIR__) . '/vendor/autoload.php');
// Load configuration if present:
$conf = array();
$conf['b8']['app']['namespace'] = 'PHPCI';
$conf['b8']['app']['default_controller'] = 'Home';
$conf['b8']['view']['path'] = dirname(__DIR__) . '/PHPCI/View/';
if (file_exists(dirname(__DIR__) . '/PHPCI/config.yml')) {
$config = new b8\Config($conf);
$config->loadYaml(dirname(__DIR__) . '/PHPCI/config.yml');
}
require_once(dirname(__DIR__) . '/vars.php');

View file

@ -34,11 +34,11 @@
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
"phpspec/prophecy-phpunit": "1.*"
},
"suggest": {
"phpunit/phpunit": "PHP unit testing framework",
"phpmd/phpmd": "PHP Mess Detector",
"sebastian/phpcpd": "PHP Copy/Paste Detector",
"squizlabs/php_codesniffer": "PHP Code Sniffer",

24
phpunit.xml Normal file
View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./Tests/bootstrap.php"
>
<testsuites>
<testsuite name="PHPCI Helper Test Suite">
<directory suffix="Test.php">./Tests/PHPCI/Helper</directory>
</testsuite>
<testsuite name="PHPCI Logging Test Suite">
<directory suffix="Test.php">./Tests/PHPCI/Logging</directory>
</testsuite>
<testsuite name="PHPCI Plugin Test Suite">
<directory suffix="Test.php">./Tests/PHPCI/Plugin</directory>
</testsuite>
</testsuites>
</phpunit>