Skip to content

Commit 352f77a

Browse files
committed
minor #274 [WIP] Fix windows tests issues and speed (sadikoff)
This PR was merged into the 1.0-dev branch. Discussion ---------- [WIP] Fix windows tests issues and speed Trying to fix all tests issues. Still in progress... Commits ------- 9404111 Tests are back again. New git env is ready thx to @nikophil for idea
2 parents 52288cc + 9404111 commit 352f77a

File tree

8 files changed

+208
-338
lines changed

8 files changed

+208
-338
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ env:
2020
global:
2121
- SYMFONY_PHPUNIT_DIR=.phpunit
2222

23+
before_install:
24+
- phpenv config-rm xdebug.ini
25+
2326
install:
2427
- composer install
2528
- ./vendor/bin/simple-phpunit install
2629

27-
before_script:
28-
- phpenv config-rm xdebug.ini
29-
3030
script:
3131
- ./vendor/bin/simple-phpunit
3232
- ./vendor/bin/php-cs-fixer fix --dry-run --diff

appveyor.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
build: false
22
platform:
33
- x64
4-
clone_folder: c:\projects\maker-bundle
4+
clone_folder: C:\projects\maker-bundle
55

66
cache:
7-
- '%LOCALAPPDATA%\Composer\files -> composer.lock'
8-
- composer.phar
7+
- C:\projects\maker-bundle\vendor -> composer.json
98
# Cache chocolatey packages
109
- C:\ProgramData\chocolatey\bin -> .appveyor.yml
1110
- C:\ProgramData\chocolatey\lib -> .appveyor.yml
1211
# Cache php install
1312
- C:\tools\php -> .appveyor.yml
1413
- .phpunit -> phpunit
15-
- C:\projects\maker-bundle\vendor -> composer.json
1614

1715
services:
1816
- mysql
@@ -26,8 +24,6 @@ init:
2624
environment:
2725
TEST_DATABASE_DSN: mysql://root:[email protected]:3306/test_maker
2826
matrix:
29-
- dependencies: lowest
30-
php_ver_target: 7.1.3
3127
- dependencies: highest
3228
php_ver_target: 7.2.3
3329

@@ -39,10 +35,10 @@ install:
3935
- IF %PHP%==0 copy php.ini-development php.ini /Y
4036
- IF %PHP%==0 echo memory_limit=-1 >> php.ini
4137
- IF %PHP%==0 echo serialize_precision=14 >> php.ini
38+
- IF %PHP%==0 echo realpath_cache_size=8192k >> php.ini
4239
- IF %PHP%==0 echo max_execution_time=1200 >> php.ini
4340
- IF %PHP%==0 echo date.timezone="UTC" >> php.ini
4441
- IF %PHP%==0 echo extension_dir=ext >> php.ini
45-
- IF %PHP%==0 echo zend_extension=php_opcache.dll >> php.ini
4642
- IF %PHP%==0 echo opcache.enable_cli=1 >> php.ini
4743
- IF %PHP%==0 echo extension=php_openssl.dll >> php.ini
4844
- IF %PHP%==0 echo extension=php_mbstring.dll >> php.ini
@@ -52,9 +48,7 @@ install:
5248
- IF %PHP%==0 echo extension=php_pdo_mysql.dll >> php.ini
5349
- IF %PHP%==0 echo @php %%~dp0composer.phar %%* > composer.bat
5450
- appveyor-retry appveyor DownloadFile https://getcomposer.org/composer.phar
55-
- composer global require hirak/prestissimo --no-progress
5651
- cd C:\projects\maker-bundle
57-
- IF %dependencies%==lowest appveyor-retry composer update --prefer-lowest --no-progress --no-suggest --ansi
5852
- IF %dependencies%==highest appveyor-retry composer update --no-progress --no-suggest --ansi
5953
- vendor/bin/simple-phpunit install
6054

src/Test/MakerTestCase.php

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,41 +26,37 @@ protected function executeMakerCommand(MakerTestDetails $testDetails)
2626
// prepare environment to test
2727
$testEnv->prepare();
2828

29-
try {
30-
// run tests
31-
$makerTestProcess = $testEnv->runMaker();
32-
$files = $testEnv->getGeneratedFilesFromOutputText();
29+
// run tests
30+
$makerTestProcess = $testEnv->runMaker();
31+
$files = $testEnv->getGeneratedFilesFromOutputText();
3332

34-
foreach ($files as $file) {
35-
$this->assertTrue($testEnv->fileExists($file));
33+
foreach ($files as $file) {
34+
$this->assertTrue($testEnv->fileExists($file));
3635

37-
if ('.php' === substr($file, -4)) {
38-
$csProcess = $testEnv->runPhpCSFixer($file);
36+
if ('.php' === substr($file, -4)) {
37+
$csProcess = $testEnv->runPhpCSFixer($file);
3938

40-
$this->assertTrue($csProcess->isSuccessful(), sprintf('File "%s" has a php-cs problem: %s', $file, $csProcess->getOutput()));
41-
}
39+
$this->assertTrue($csProcess->isSuccessful(), sprintf('File "%s" has a php-cs problem: %s', $file, $csProcess->getOutput()));
40+
}
4241

43-
if ('.twig' === substr($file, -5)) {
44-
$csProcess = $testEnv->runTwigCSLint($file);
42+
if ('.twig' === substr($file, -5)) {
43+
$csProcess = $testEnv->runTwigCSLint($file);
4544

46-
$this->assertTrue($csProcess->isSuccessful(), sprintf('File "%s" has a twig-cs problem: %s', $file, $csProcess->getOutput()));
47-
}
45+
$this->assertTrue($csProcess->isSuccessful(), sprintf('File "%s" has a twig-cs problem: %s', $file, $csProcess->getOutput()));
4846
}
47+
}
4948

50-
// run internal tests
51-
$internalTestProcess = $testEnv->runInternalTests();
52-
if (null !== $internalTestProcess) {
53-
$this->assertTrue($internalTestProcess->isSuccessful(), sprintf("Error while running the PHPUnit tests *in* the project: \n\n %s \n\n Command Output: %s", $internalTestProcess->getOutput(), $makerTestProcess->getOutput()));
54-
}
49+
// run internal tests
50+
$internalTestProcess = $testEnv->runInternalTests();
51+
if (null !== $internalTestProcess) {
52+
$this->assertTrue($internalTestProcess->isSuccessful(), sprintf("Error while running the PHPUnit tests *in* the project: \n\n %s \n\n Command Output: %s", $internalTestProcess->getOutput(), $makerTestProcess->getOutput()));
53+
}
5554

56-
// checkout user asserts
57-
if (null === $testDetails->getAssert()) {
58-
$this->assertContains('Success', $makerTestProcess->getOutput(), $makerTestProcess->getErrorOutput());
59-
} else {
60-
($testDetails->getAssert())($makerTestProcess->getOutput(), $testEnv->getPath());
61-
}
62-
} finally {
63-
$testEnv->reset();
55+
// checkout user asserts
56+
if (null === $testDetails->getAssert()) {
57+
$this->assertContains('Success', $makerTestProcess->getOutput(), $makerTestProcess->getErrorOutput());
58+
} else {
59+
($testDetails->getAssert())($makerTestProcess->getOutput(), $testEnv->getPath());
6460
}
6561
}
6662

src/Test/MakerTestDetails.php

Lines changed: 11 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ final class MakerTestDetails
2424

2525
private $deletedFiles = [];
2626

27-
private $filesToRevert = [];
28-
2927
private $replacements = [];
3028

3129
private $postMakeReplacements = [];
@@ -42,7 +40,7 @@ final class MakerTestDetails
4240

4341
private $commandAllowedToFail = false;
4442

45-
private $snapshotSuffix = '';
43+
private $rootNamespace = 'App';
4644

4745
private $requiredPhpVersion;
4846

@@ -72,44 +70,16 @@ public function setFixtureFilesPath(string $fixtureFilesPath): self
7270
return $this;
7371
}
7472

75-
public function changeRootNamespace(string $rootNamespace): self
73+
public function getRootNamespace()
7674
{
77-
$rootNamespace = trim($rootNamespace, '\\');
75+
return $this->rootNamespace;
76+
}
7877

79-
// to bypass read before flush issue
80-
$this->snapshotSuffix = $rootNamespace;
78+
public function changeRootNamespace(string $rootNamespace): self
79+
{
80+
$this->rootNamespace = trim($rootNamespace, '\\');
8181

82-
return $this
83-
->addReplacement(
84-
'composer.json',
85-
'"App\\\\": "src/"',
86-
'"'.$rootNamespace.'\\\\": "src/"'
87-
)
88-
->addReplacement(
89-
'src/Kernel.php',
90-
'namespace App',
91-
'namespace '.$rootNamespace
92-
)
93-
->addReplacement(
94-
'bin/console',
95-
'use App\\Kernel',
96-
'use '.$rootNamespace.'\\Kernel'
97-
)
98-
->addReplacement(
99-
'public/index.php',
100-
'use App\\Kernel',
101-
'use '.$rootNamespace.'\\Kernel'
102-
)
103-
->addReplacement(
104-
'config/services.yaml',
105-
'App\\',
106-
$rootNamespace.'\\'
107-
)
108-
->addReplacement(
109-
'phpunit.xml.dist',
110-
'<env name="KERNEL_CLASS" value="App\\Kernel" />',
111-
'<env name="KERNEL_CLASS" value="'.$rootNamespace.'\\Kernel" />'
112-
);
82+
return $this;
11383
}
11484

11585
public function addPreMakeCommand(string $preMakeCommand): self
@@ -138,18 +108,6 @@ public function getFilesToDelete(): array
138108
return $this->deletedFiles;
139109
}
140110

141-
public function revertFileAfterFinish(string $filename): self
142-
{
143-
$this->filesToRevert[] = $filename;
144-
145-
return $this;
146-
}
147-
148-
public function getFilesToRevert(): array
149-
{
150-
return $this->filesToRevert;
151-
}
152-
153111
public function addReplacement(string $filename, string $find, string $replace): self
154112
{
155113
$this->replacements[] = [
@@ -269,7 +227,6 @@ public function setRequiredPhpVersion(int $version): self
269227
public function setGuardAuthenticator(string $firewallName, string $id): self
270228
{
271229
$this->guardAuthenticators[$firewallName] = $id;
272-
$this->revertFileAfterFinish('config/packages/security.yaml');
273230

274231
return $this;
275232
}
@@ -286,9 +243,9 @@ public function getFixtureFilesPath()
286243

287244
public function getUniqueCacheDirectoryName(): string
288245
{
289-
// for cache purposes, only the dependencies are important
290-
// shortened to avoid long paths on Windows
291-
return 'maker_'.substr(md5(serialize($this->getDependencies()).$this->snapshotSuffix), 0, 10);
246+
// for cache purposes, only the dependencies are important!
247+
// You can change it ONLY if you don't have another way to implement it
248+
return 'maker_'.strtolower($this->getRootNamespace()).'_'.md5(serialize($this->getDependencies()));
292249
}
293250

294251
public function getPreMakeCommands(): array

0 commit comments

Comments
 (0)