Skip to content

Commit 152abbf

Browse files
authored
Merge pull request #378 from goaop/feature/app-veyor-integration
Enable AppVeyor integration for Windows tests
2 parents 1428287 + 43c763d commit 152abbf

File tree

5 files changed

+77
-13
lines changed

5 files changed

+77
-13
lines changed

.travis.yml

-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,3 @@ script:
1515
after_script:
1616
- sh .travis.coverage.sh
1717

18-
matrix:
19-
allow_failures:
20-
- php: 7.2

appveyor.yml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
build: false
2+
shallow_clone: true
3+
platform:
4+
- x64
5+
clone_folder: c:\projects\goaop
6+
7+
## Cache composer, chocolatey and php bits
8+
cache:
9+
- '%LOCALAPPDATA%\Composer\files -> composer.lock'
10+
- composer.phar
11+
# Cache chocolatey packages
12+
- C:\ProgramData\chocolatey\bin -> .appveyor.yml
13+
- C:\ProgramData\chocolatey\lib -> .appveyor.yml
14+
# Cache php install
15+
- c:\tools\php -> .appveyor.yml
16+
17+
## Build matrix for lowest and highest possible targets
18+
environment:
19+
matrix:
20+
- dependencies: current
21+
php_ver_target: 5.6
22+
- dependencies: current
23+
php_ver_target: 7.2
24+
#- dependencies: highest
25+
# php_ver_target: 7.0
26+
27+
## Set up environment variables
28+
init:
29+
- SET PATH=C:\Program Files\OpenSSL;c:\tools\php;%PATH%
30+
- SET COMPOSER_NO_INTERACTION=1
31+
- SET PHP=1 # This var is connected to PHP install cache
32+
- SET ANSICON=121x90 (121x90)
33+
34+
## Install PHP and composer, and run the appropriate composer command
35+
install:
36+
- IF EXIST c:\tools\php (SET PHP=0) # Checks for the PHP install being cached
37+
- ps: appveyor-retry cinst --params '""/InstallDir:C:\tools\php""' --ignore-checksums -y php --version ((choco search php --exact --all-versions -r | select-string -pattern $env:php_ver_target | sort { [version]($_ -split '\|' | select -last 1) } -Descending | Select-Object -first 1) -replace '[php|]','')
38+
- cd c:\tools\php
39+
- IF %PHP%==1 copy php.ini-production php.ini /Y
40+
- IF %PHP%==1 echo date.timezone="UTC" >> php.ini
41+
- IF %PHP%==1 echo extension_dir=ext >> php.ini
42+
- IF %PHP%==1 echo extension=php_openssl.dll >> php.ini
43+
- IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini
44+
- IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini
45+
- IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat
46+
- appveyor-retry appveyor DownloadFile https://getcomposer.org/composer.phar
47+
- cd c:\projects\goaop
48+
- IF %dependencies%==lowest appveyor-retry composer update --prefer-lowest --no-progress --profile -n
49+
- IF %dependencies%==current appveyor-retry composer install --no-progress --profile
50+
- IF %dependencies%==highest appveyor-retry composer update --no-progress --profile -n
51+
- composer show
52+
53+
test_script:
54+
- cd c:\projects\goaop
55+
- vendor/bin/phpunit --verbose --coverage-text --coverage-clover=clover.xml --colors
56+
57+
on_finish:
58+
# Upload test results via rest-api
59+
- ps: |
60+
$wc = New-Object 'System.Net.WebClient'
61+
Get-ChildItem . -Name -Recurse 'clover.xml' |
62+
Foreach-Object {
63+
$wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $_))
64+
}

src/Instrument/FileSystem/Enumerator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function enumerate()
6161
$iterator = new \RecursiveIteratorIterator(
6262
new \RecursiveDirectoryIterator(
6363
$this->rootDirectory,
64-
\FilesystemIterator::SKIP_DOTS
64+
\FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS
6565
)
6666
);
6767

src/Instrument/Transformer/WeavingTransformer.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,7 @@ private function saveProxyToCache($class, $child)
271271

272272
$cacheDir = $this->cachePathManager->getCacheDir() . $cacheDirSuffix;
273273
$relativePath = str_replace($this->options['appDir'] . DIRECTORY_SEPARATOR, '', $class->getFileName());
274-
$classSuffix = str_replace('\\', DIRECTORY_SEPARATOR, $class->getName()) . '.php';
275-
$proxyRelativePath = $relativePath . DIRECTORY_SEPARATOR . $classSuffix;
274+
$proxyRelativePath = str_replace('\\', '/', $relativePath . '/' . $class->getName() . '.php');
276275
$proxyFileName = $cacheDir . $proxyRelativePath;
277276
$dirname = dirname($proxyFileName);
278277
if (!file_exists($dirname)) {

tests/Go/Functional/BaseFunctionalTest.php

+11-7
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
namespace Go\Functional;
1212

1313
use Go\Core\AspectContainer;
14+
use Go\Instrument\PathResolver;
1415
use Go\PhpUnit\ClassIsNotWovenConstraint;
1516
use Go\PhpUnit\ClassWovenConstraint;
1617
use Go\PhpUnit\ClassAdvisorIdentifier;
1718
use Go\PhpUnit\ClassMemberWovenConstraint;
1819
use Go\PhpUnit\ClassMemberNotWovenConstraint;
1920
use PHPUnit_Framework_TestCase as TestCase;
2021
use Symfony\Component\Filesystem\Filesystem;
22+
use Symfony\Component\Process\PhpExecutableFinder;
2123
use Symfony\Component\Process\Process;
2224

2325
/**
@@ -56,9 +58,10 @@ public function tearDown()
5658
protected function clearCache()
5759
{
5860
$filesystem = new Filesystem();
59-
60-
if ($filesystem->exists($this->configuration['cacheDir'])) {
61-
$filesystem->remove($this->configuration['cacheDir']);
61+
// We need to normalize path to prevent Windows 260-length filename trouble
62+
$absoluteCacheDir = PathResolver::realpath($this->configuration['cacheDir']);
63+
if ($filesystem->exists($absoluteCacheDir)) {
64+
$filesystem->remove($absoluteCacheDir);
6265
}
6366
}
6467

@@ -114,16 +117,17 @@ protected function loadConfiguration()
114117
*/
115118
protected function execute($command, $args = null, $expectSuccess = true, $expectedExitCode = null)
116119
{
117-
$commandStatement = sprintf('GO_AOP_CONFIGURATION=%s php %s %s %s %s',
118-
$this->getConfigurationName(),
120+
$phpExecutable = (new PhpExecutableFinder())->find();
121+
$commandStatement = sprintf('%s %s --no-ansi %s %s %s',
122+
$phpExecutable,
119123
$this->configuration['console'],
120124
$command,
121125
$this->configuration['frontController'],
122126
(null !== $args) ? $args : ''
123127
);
124128

125-
$process = new Process($commandStatement);
126-
129+
$process = new Process($commandStatement, null, ['GO_AOP_CONFIGURATION' => $this->getConfigurationName()]);
130+
$process->inheritEnvironmentVariables();
127131
$process->run();
128132

129133
if ($expectSuccess) {

0 commit comments

Comments
 (0)