From 266913715fdc42853b51a1358e661519d232187d Mon Sep 17 00:00:00 2001 From: Lisachenko Alexander Date: Sat, 16 Dec 2017 20:11:06 +0300 Subject: [PATCH 1/8] Add AppVeyor CI for Windows tests --- appveyor.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..c12f1d7b --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,35 @@ +build: false +shallow_clone: true +platform: + - x86 + - x64 +clone_folder: c:\projects\goaop + +cache: + - c:\tools\php -> appveyor.yml + +init: + - SET PATH=C:\Program Files\OpenSSL;c:\tools\php;%PATH% + - SET COMPOSER_NO_INTERACTION=1 + - SET PHP=1 + - SET ANSICON=121x90 (121x90) + +install: + - IF EXIST c:\tools\php (SET PHP=0) + - IF %PHP%==1 cinst -y OpenSSL.Light + - IF %PHP%==1 cinst -y php + - cd c:\tools\php + - IF %PHP%==1 copy php.ini-production php.ini /Y + - IF %PHP%==1 echo date.timezone="UTC" >> php.ini + - IF %PHP%==1 echo extension_dir=ext >> php.ini + - IF %PHP%==1 echo extension=php_openssl.dll >> php.ini + - IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini + - IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini + - IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat + - appveyor DownloadFile https://getcomposer.org/composer.phar + - cd c:\projects\goaop + - composer install --prefer-dist --no-progress + +test_script: + - cd c:\projects\composer + - vendor/bin/phpunit --colors=always From cf573144ff47a7c61905d21145a4c3cee4e799da Mon Sep 17 00:00:00 2001 From: Lisachenko Alexander Date: Sat, 16 Dec 2017 20:11:47 +0300 Subject: [PATCH 2/8] Disable failures for PHP7.2 as it was released --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5f4e9ad0..6c033fa6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,3 @@ script: after_script: - sh .travis.coverage.sh -matrix: - allow_failures: - - php: 7.2 From 21786ce02ac669f629458e27713b0c6266992c03 Mon Sep 17 00:00:00 2001 From: Lisachenko Alexander Date: Sat, 16 Dec 2017 20:15:21 +0300 Subject: [PATCH 3/8] Adjust config for AppVeyor --- appveyor.yml | 66 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index c12f1d7b..b2235db4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,35 +1,59 @@ build: false shallow_clone: true platform: - - x86 - x64 clone_folder: c:\projects\goaop +## Cache composer, chocolatey and php bits cache: - - c:\tools\php -> appveyor.yml + - '%LOCALAPPDATA%\Composer\files -> composer.lock' + - composer.phar + # Cache chocolatey packages + - C:\ProgramData\chocolatey\bin -> .appveyor.yml + - C:\ProgramData\chocolatey\lib -> .appveyor.yml + # Cache php install + - c:\tools\php -> .appveyor.yml +## Build matrix for lowest and highest possible targets +environment: + matrix: + - dependencies: current + php_ver_target: 5.6 + - dependencies: current + php_ver_target: 7.0 + - dependencies: current + php_ver_target: 7.1 + - dependencies: current + php_ver_target: 7.2 + #- dependencies: highest + # php_ver_target: 7.0 + +## Set up environment variables init: - - SET PATH=C:\Program Files\OpenSSL;c:\tools\php;%PATH% - - SET COMPOSER_NO_INTERACTION=1 - - SET PHP=1 - - SET ANSICON=121x90 (121x90) + - SET PATH=C:\Program Files\OpenSSL;c:\tools\php;%PATH% + - SET COMPOSER_NO_INTERACTION=1 + - SET PHP=1 # This var is connected to PHP install cache + - SET ANSICON=121x90 (121x90) +## Install PHP and composer, and run the appropriate composer command install: - - IF EXIST c:\tools\php (SET PHP=0) - - IF %PHP%==1 cinst -y OpenSSL.Light - - IF %PHP%==1 cinst -y php - - cd c:\tools\php - - IF %PHP%==1 copy php.ini-production php.ini /Y - - IF %PHP%==1 echo date.timezone="UTC" >> php.ini - - IF %PHP%==1 echo extension_dir=ext >> php.ini - - IF %PHP%==1 echo extension=php_openssl.dll >> php.ini - - IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini - - IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini - - IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat - - appveyor DownloadFile https://getcomposer.org/composer.phar - - cd c:\projects\goaop - - composer install --prefer-dist --no-progress + - IF EXIST c:\tools\php (SET PHP=0) # Checks for the PHP install being cached + - 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|]','') + - cd c:\tools\php + - IF %PHP%==1 copy php.ini-production php.ini /Y + - IF %PHP%==1 echo date.timezone="UTC" >> php.ini + - IF %PHP%==1 echo extension_dir=ext >> php.ini + - IF %PHP%==1 echo extension=php_openssl.dll >> php.ini + - IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini + - IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini + - IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat + - appveyor-retry appveyor DownloadFile https://getcomposer.org/composer.phar + - cd c:\projects\goaop + - IF %dependencies%==lowest appveyor-retry composer update --prefer-lowest --no-progress --profile -n + - IF %dependencies%==current appveyor-retry composer install --no-progress --profile + - IF %dependencies%==highest appveyor-retry composer update --no-progress --profile -n + - composer show test_script: - - cd c:\projects\composer + - cd c:\projects\goaop - vendor/bin/phpunit --colors=always From b0647d0cd031958854917b815cb87855aded4fda Mon Sep 17 00:00:00 2001 From: Lisachenko Alexander Date: Sun, 17 Dec 2017 23:00:23 +0300 Subject: [PATCH 4/8] Upload test results via rest-api, also reduce test PHP envs --- appveyor.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index b2235db4..b3e586d5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -19,10 +19,6 @@ environment: matrix: - dependencies: current php_ver_target: 5.6 - - dependencies: current - php_ver_target: 7.0 - - dependencies: current - php_ver_target: 7.1 - dependencies: current php_ver_target: 7.2 #- dependencies: highest @@ -56,4 +52,13 @@ install: test_script: - cd c:\projects\goaop - - vendor/bin/phpunit --colors=always + - vendor/bin/phpunit --verbose --coverage-text --coverage-clover=clover.xml --colors + +on_finish: +# Upload test results via rest-api + - ps: | + $wc = New-Object 'System.Net.WebClient' + Get-ChildItem . -Name -Recurse 'clover.xml' | + Foreach-Object { + $wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $_)) + } From c0b302d82fc5129ff533ff74748a30981b20ca7c Mon Sep 17 00:00:00 2001 From: Alexander Lisachenko Date: Mon, 18 Dec 2017 13:47:32 +0300 Subject: [PATCH 5/8] Fixed detection of PHP and passing env for Windows platform --- tests/Go/Functional/BaseFunctionalTest.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/Go/Functional/BaseFunctionalTest.php b/tests/Go/Functional/BaseFunctionalTest.php index f0aa416b..9d9dae7e 100644 --- a/tests/Go/Functional/BaseFunctionalTest.php +++ b/tests/Go/Functional/BaseFunctionalTest.php @@ -18,6 +18,7 @@ use Go\PhpUnit\ClassMemberNotWovenConstraint; use PHPUnit_Framework_TestCase as TestCase; use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\Process; /** @@ -114,16 +115,17 @@ protected function loadConfiguration() */ protected function execute($command, $args = null, $expectSuccess = true, $expectedExitCode = null) { - $commandStatement = sprintf('GO_AOP_CONFIGURATION=%s php %s %s %s %s', - $this->getConfigurationName(), + $phpExecutable = (new PhpExecutableFinder())->find(); + $commandStatement = sprintf('%s %s %s %s %s', + $phpExecutable, $this->configuration['console'], $command, $this->configuration['frontController'], (null !== $args) ? $args : '' ); - $process = new Process($commandStatement); - + $process = new Process($commandStatement, null, ['GO_AOP_CONFIGURATION' => $this->getConfigurationName()]); + $process->inheritEnvironmentVariables(); $process->run(); if ($expectSuccess) { From 935137af0d7c74fe04a94ef197f6ec0d3e22c97f Mon Sep 17 00:00:00 2001 From: Alexander Lisachenko Date: Sat, 6 Jan 2018 00:40:25 +0300 Subject: [PATCH 6/8] Normalize path to prevent error with long filename on Windows --- tests/Go/Functional/BaseFunctionalTest.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/Go/Functional/BaseFunctionalTest.php b/tests/Go/Functional/BaseFunctionalTest.php index 9d9dae7e..53981a57 100644 --- a/tests/Go/Functional/BaseFunctionalTest.php +++ b/tests/Go/Functional/BaseFunctionalTest.php @@ -11,6 +11,7 @@ namespace Go\Functional; use Go\Core\AspectContainer; +use Go\Instrument\PathResolver; use Go\PhpUnit\ClassIsNotWovenConstraint; use Go\PhpUnit\ClassWovenConstraint; use Go\PhpUnit\ClassAdvisorIdentifier; @@ -57,9 +58,10 @@ public function tearDown() protected function clearCache() { $filesystem = new Filesystem(); - - if ($filesystem->exists($this->configuration['cacheDir'])) { - $filesystem->remove($this->configuration['cacheDir']); + // We need to normalize path to prevent Windows 260-length filename trouble + $absoluteCacheDir = PathResolver::realpath($this->configuration['cacheDir']); + if ($filesystem->exists($absoluteCacheDir)) { + $filesystem->remove($absoluteCacheDir); } } From a4aa5b971bb2930f2d181c967e13855a9e733b62 Mon Sep 17 00:00:00 2001 From: Alexander Lisachenko Date: Sat, 6 Jan 2018 01:06:29 +0300 Subject: [PATCH 7/8] Normalize path to Unix-style for Windows --- src/Instrument/FileSystem/Enumerator.php | 2 +- src/Instrument/Transformer/WeavingTransformer.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Instrument/FileSystem/Enumerator.php b/src/Instrument/FileSystem/Enumerator.php index d6f6dda3..adbc5f8b 100644 --- a/src/Instrument/FileSystem/Enumerator.php +++ b/src/Instrument/FileSystem/Enumerator.php @@ -61,7 +61,7 @@ public function enumerate() $iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $this->rootDirectory, - \FilesystemIterator::SKIP_DOTS + \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS ) ); diff --git a/src/Instrument/Transformer/WeavingTransformer.php b/src/Instrument/Transformer/WeavingTransformer.php index ced424e2..924938df 100644 --- a/src/Instrument/Transformer/WeavingTransformer.php +++ b/src/Instrument/Transformer/WeavingTransformer.php @@ -271,8 +271,7 @@ private function saveProxyToCache($class, $child) $cacheDir = $this->cachePathManager->getCacheDir() . $cacheDirSuffix; $relativePath = str_replace($this->options['appDir'] . DIRECTORY_SEPARATOR, '', $class->getFileName()); - $classSuffix = str_replace('\\', DIRECTORY_SEPARATOR, $class->getName()) . '.php'; - $proxyRelativePath = $relativePath . DIRECTORY_SEPARATOR . $classSuffix; + $proxyRelativePath = str_replace('\\', '/', $relativePath . '/' . $class->getName() . '.php'); $proxyFileName = $cacheDir . $proxyRelativePath; $dirname = dirname($proxyFileName); if (!file_exists($dirname)) { From 43c763d0b2f5ba97e2e32fc5d99b87a22d86da50 Mon Sep 17 00:00:00 2001 From: Alexander Lisachenko Date: Sat, 6 Jan 2018 01:28:22 +0300 Subject: [PATCH 8/8] Disable ANSI-output as it breaks matching on AppVeyor --- tests/Go/Functional/BaseFunctionalTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Go/Functional/BaseFunctionalTest.php b/tests/Go/Functional/BaseFunctionalTest.php index 53981a57..7277b49e 100644 --- a/tests/Go/Functional/BaseFunctionalTest.php +++ b/tests/Go/Functional/BaseFunctionalTest.php @@ -118,7 +118,7 @@ protected function loadConfiguration() protected function execute($command, $args = null, $expectSuccess = true, $expectedExitCode = null) { $phpExecutable = (new PhpExecutableFinder())->find(); - $commandStatement = sprintf('%s %s %s %s %s', + $commandStatement = sprintf('%s %s --no-ansi %s %s %s', $phpExecutable, $this->configuration['console'], $command,