Skip to content
Snippets Groups Projects
Unverified Commit ad1184b2 authored by Tim van Dijen's avatar Tim van Dijen Committed by GitHub
Browse files

Use Appveyor for CI on Windows (#1083)

* Create .appveyor.yml

* Fix tests for Windows platform

* Fix builtin webserver for Windows

* Properly kill process on Windows
parent a29c0b54
No related branches found
No related tags found
No related merge requests found
build: false
shallow_clone: false
version: '1.17.1.{build}'
platform: 'x64'
clone_folder: C:\projects\simplesamlphp
environment:
matrix:
- PHP_VERSION: "5.6"
- PHP_VERSION: "7.0"
- PHP_VERSION: "7.1"
- PHP_VERSION: "7.2"
- PHP_VERSION: "7.3"
install:
- ps: Invoke-WebRequest "https://raw.githubusercontent.com/ChadSikorra/ps-install-php/master/Install-PHP.ps1" -OutFile "Install-PHP.ps1"
- ps: .\Install-PHP.ps1 -Version $Env:PHP_VERSION -Highest -Arch x64 -Extensions mbstring,intl,openssl,curl,pdo_mysql,pdo_sqlite
- refreshenv
- cd C:\projects\simplesamlphp
- php -r "readfile('https://getcomposer.org/installer');" | php
before_test:
- cd C:\projects\simplesamlphp
- php composer.phar install --no-interaction --no-progress --optimize-autoloader --prefer-source --no-ansi
test_script:
- cd C:\projects\simplesamlphp
- vendor\bin\phpunit.bat
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
namespace SimpleSAML\Test; namespace SimpleSAML\Test;
use SimpleSAML\Utils\System;
class BuiltInServer class BuiltInServer
{ {
...@@ -60,6 +62,10 @@ class BuiltInServer ...@@ -60,6 +62,10 @@ class BuiltInServer
} else { } else {
$this->docroot = dirname(dirname(__FILE__)).'/www/'; $this->docroot = dirname(dirname(__FILE__)).'/www/';
} }
// Rationalize docroot
$this->docroot = str_replace('\\', '/', $this->docroot);
$this->docroot = rtrim($this->docroot, '/');
} }
...@@ -80,17 +86,26 @@ class BuiltInServer ...@@ -80,17 +86,26 @@ class BuiltInServer
$port = mt_rand(1025, 65535); $port = mt_rand(1025, 65535);
$this->address = 'localhost:'.$port; $this->address = 'localhost:'.$port;
$command = sprintf( if (System::getOS() === System::WINDOWS) {
'php -S %s -t %s %s >> /dev/null 2>&1 & echo $!', $command = sprintf(
$this->address, 'powershell $proc = start-process php -ArgumentList (\'-S %s\', \'-t %s\', \'%s\') -Passthru; Write-output $proc.Id;',
$this->docroot, $this->address,
$this->router $this->docroot,
); $this->router
);
} else {
$command = sprintf(
'php -S %s -t %s %s >> /dev/null 2>&1 & echo $!',
$this->address,
$this->docroot,
$this->router
);
}
// execute the command and store the process ID // execute the command and store the process ID
$output = []; $output = [];
exec($command, $output); exec($command, $output);
$this->pid = (int) $output[0]; $this->pid = intval($output[0]);
// wait until it's listening for connections to avoid race conditions // wait until it's listening for connections to avoid race conditions
$start = microtime(true); $start = microtime(true);
...@@ -117,8 +132,11 @@ class BuiltInServer ...@@ -117,8 +132,11 @@ class BuiltInServer
{ {
if ($this->pid === 0) { if ($this->pid === 0) {
return; return;
} else if (System::getOS() === System::WINDOWS) {
exec('taskkill /PID '.$this->pid);
} else {
exec('kill '.$this->pid);
} }
exec('kill '.$this->pid);
$this->pid = 0; $this->pid = 0;
} }
......
...@@ -210,17 +210,17 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase ...@@ -210,17 +210,17 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase
public function testGetBaseDir() public function testGetBaseDir()
{ {
$c = Configuration::loadFromArray([]); $c = Configuration::loadFromArray([]);
$this->assertEquals($c->getBaseDir(), dirname(dirname(dirname(dirname(__FILE__)))).'/'); $this->assertEquals($c->getBaseDir(), dirname(dirname(dirname(dirname(__FILE__)))).DIRECTORY_SEPARATOR);
$c = Configuration::loadFromArray([ $c = Configuration::loadFromArray([
'basedir' => '/basedir', 'basedir' => DIRECTORY_SEPARATOR.'basedir',
]); ]);
$this->assertEquals($c->getBaseDir(), '/basedir/'); $this->assertEquals($c->getBaseDir(), DIRECTORY_SEPARATOR.'basedir'.DIRECTORY_SEPARATOR);
$c = Configuration::loadFromArray([ $c = Configuration::loadFromArray([
'basedir' => '/basedir/', 'basedir' => DIRECTORY_SEPARATOR.'basedir'.DIRECTORY_SEPARATOR,
]); ]);
$this->assertEquals($c->getBaseDir(), '/basedir/'); $this->assertEquals($c->getBaseDir(), DIRECTORY_SEPARATOR.'basedir'.DIRECTORY_SEPARATOR);
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment