-
-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
373e687
commit 8e45876
Showing
4 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Zephir. | ||
* | ||
* (c) Zephir Team <team@zephir-lang.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Zephir\Test\Command; | ||
|
||
use Symfony\Component\Console\Tester\CommandTester; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Zephir\Application; | ||
use Zephir\Command\CompileCommand; | ||
use Zephir\Di\Singleton; | ||
use Zephir\Support\TestCase; | ||
use function Zephir\unlink_recursive; | ||
|
||
/** | ||
* Zephir\Test\Command\CompileCommandTest | ||
* | ||
* @package Zephir\Test\CompilerFile | ||
*/ | ||
class CompileCommandTest extends TestCase | ||
{ | ||
/** | ||
* Common directory. | ||
* unit-tests/Zephir/Test/Command/CompileCommandTest.php | ||
* @var string | ||
*/ | ||
private $pwd; | ||
|
||
/** | ||
* Store the current directory before to be change. | ||
* | ||
* @return void | ||
*/ | ||
public function setUp() | ||
{ | ||
$this->pwd = getcwd(); | ||
Singleton::reset(); | ||
} | ||
|
||
/** | ||
* Restore current directory, and clean config.json. | ||
* | ||
* @return void | ||
*/ | ||
public function tearDown() | ||
{ | ||
if (getcwd() !== $this->pwd) { | ||
if (file_exists('.temp')) { | ||
unlink_recursive('.temp/'); | ||
} | ||
|
||
if (file_exists('ext')) { | ||
unlink_recursive('ext/'); | ||
} | ||
|
||
if (file_exists('compile.log')) { | ||
unlink('compile.log'); | ||
} | ||
|
||
if (file_exists('compile-errors.log')) { | ||
unlink('compile-errors.log'); | ||
} | ||
|
||
chdir($this->pwd); | ||
} | ||
} | ||
|
||
/** | ||
* @test | ||
* @dataProvider devModeProvider | ||
* @issue https://github.com/phalcon/zephir/issues/1520 | ||
* | ||
* @param array $mode | ||
* @param string $cflags | ||
*/ | ||
public function shouldDetermineDevOption(array $mode, $cflags) | ||
{ | ||
// TODO: Create a test for Windows | ||
if (\strtoupper(\substr(PHP_OS, 0, 3)) === 'WIN') { | ||
$this->markTestSkipped( | ||
'This test currently works on Linux systems only' | ||
); | ||
} | ||
|
||
chdir(ZEPHIRPATH . '/unit-tests/fixtures/devmode'); | ||
|
||
$application = new Application(ZEPHIRPATH); | ||
$application->add(new CompileCommand()); | ||
|
||
Singleton::getDefault()->get('config')->set('silent', true); | ||
|
||
$command = $application->find('compile'); | ||
$commandTester = new CommandTester($command); | ||
|
||
ob_start(); | ||
|
||
$commandTester->execute( | ||
['command' => $command->getName()] + $mode, | ||
['verbosity' => OutputInterface::VERBOSITY_QUIET] | ||
); | ||
|
||
ob_get_clean(); | ||
|
||
$this->assertRegexp("/CFLAGS='{$cflags}'/", file_get_contents('ext/config.nice')); | ||
} | ||
|
||
public function devModeProvider() | ||
{ | ||
return [ | ||
[['--no-dev' => true], '-O2 -fvisibility=hidden -Wparentheses -flto -DZEPHIR_RELEASE=1'], | ||
[['--dev' => true], '-O0 -g3'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"stubs": { | ||
"stubs-run-after-generate": false | ||
}, | ||
"warnings": { | ||
"unused-variable": true, | ||
"unused-variable-external": false, | ||
"possible-wrong-parameter": true, | ||
"possible-wrong-parameter-undefined": false, | ||
"nonexistent-function": true, | ||
"nonexistent-class": true, | ||
"non-valid-isset": true, | ||
"non-array-update": true, | ||
"non-valid-objectupdate": true, | ||
"non-valid-fetch": true, | ||
"invalid-array-index": true, | ||
"non-array-append": true, | ||
"invalid-return-type": true, | ||
"unreachable-code": true, | ||
"nonexistent-constant": true, | ||
"not-supported-magic-constant": true, | ||
"non-valid-decrement": true, | ||
"non-valid-increment": true, | ||
"non-valid-clone": true, | ||
"non-valid-new": true, | ||
"non-array-access": true, | ||
"invalid-reference": true, | ||
"invalid-typeof-comparison": true, | ||
"conditional-initialization": true | ||
}, | ||
"optimizations": { | ||
"static-type-inference": true, | ||
"static-type-inference-second-pass": true, | ||
"local-context-pass": true, | ||
"constant-folding": true, | ||
"static-constant-class-folding": true, | ||
"call-gatherer-pass": true, | ||
"check-invalid-reads": false, | ||
"internal-call-transformation": false | ||
}, | ||
"namespace": "devmode", | ||
"name": "devmode", | ||
"description": "", | ||
"author": "", | ||
"version": "0.0.1", | ||
"verbose": false, | ||
"requires": { | ||
"extensions": [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace Devmode; | ||
|
||
class Test | ||
{ | ||
} |