From 45917875190ef3d45dd2637e2bf2272a0562461c Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sat, 8 Apr 2017 00:35:45 +0300 Subject: [PATCH] Added ability to not exit from PHPUnit test runner --- .travis.yml | 2 +- appveyor.yml | 2 +- bootstrap.php | 28 +++++++++++---- compiler.php | 3 +- phpunit.xml.dist | 2 +- unit-tests/Data/TestExClass.php | 5 +++ unit-tests/Data/TestExInterface.php | 5 +++ unit-tests/Extension/ExistsTest.php | 10 ++++-- unit-tests/{Bootstrap.php => bootstrap.php} | 20 +++++------ unit-tests/phpunit | 39 +++++++++++++++++++++ 10 files changed, 93 insertions(+), 23 deletions(-) create mode 100644 unit-tests/Data/TestExClass.php create mode 100644 unit-tests/Data/TestExInterface.php rename unit-tests/{Bootstrap.php => bootstrap.php} (73%) create mode 100755 unit-tests/phpunit diff --git a/.travis.yml b/.travis.yml index 0ef6e0a92b..70ee38e689 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,7 +61,7 @@ before_script: script: - vendor/bin/phpcs --standard=PSR2 --report=emacs --extensions=php --warning-severity=0 Library/ unit-tests/Extension/ unit-tests/Zephir/ - - valgrind --read-var-info=yes --error-exitcode=1 --fullpath-after= --track-origins=yes --leak-check=full ./vendor/bin/phpunit -c phpunit.xml.dist --debug unit-tests/ + - valgrind --read-var-info=yes --error-exitcode=1 --fullpath-after= --track-origins=yes --leak-check=full ./unit-tests/phpunit --not-exit -c phpunit.xml.dist --debug unit-tests/ after_failure: - ./unit-tests/ci/after_failure.sh diff --git a/appveyor.yml b/appveyor.yml index cf9132449a..3932176d43 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -97,7 +97,7 @@ build_script: test_script: - cd %APPVEYOR_BUILD_FOLDER% - - 'vendor/bin/phpunit -c phpunit.xml.dist --debug' + - 'php unit-tests/phpunit -c phpunit.xml.dist --not-exit --debug' on_failure: - 'dir' diff --git a/bootstrap.php b/bootstrap.php index c4876d7cd9..418b1994d0 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -17,15 +17,29 @@ +--------------------------------------------------------------------------+ */ -error_reporting(E_ALL); +error_reporting(-1); -define('ZEPHIRPATH', __DIR__ . DIRECTORY_SEPARATOR); -define('T', "\t"); -define('2T', "\t\t"); +ini_set('display_errors', 1); +ini_set('display_startup_errors', 1); -if (file_exists(__DIR__ . '/vendor/autoload.php')) { - require __DIR__ . '/vendor/autoload.php'; +setlocale(LC_ALL, 'en_US.utf-8'); + +set_time_limit(-1); + +if (!ini_get('date.timezone')) { + ini_set('date.timezone', 'UTC'); +} + +clearstatcache(); + +defined('ZEPHIRPATH') || define('ZEPHIRPATH', __DIR__ . DIRECTORY_SEPARATOR); + +defined('T') || define('T', "\t"); +defined('2T') || define('2T', "\t\t"); + +if (file_exists(ZEPHIRPATH . 'vendor/autoload.php')) { + require ZEPHIRPATH . 'vendor/autoload.php'; } else { - require __DIR__ . '/Library/Loader.php'; + require ZEPHIRPATH . 'Library/Loader.php'; Zephir\Loader::register(); } diff --git a/compiler.php b/compiler.php index 07161505bd..32359c4cd7 100755 --- a/compiler.php +++ b/compiler.php @@ -17,5 +17,6 @@ +--------------------------------------------------------------------------+ */ -require __DIR__ . '/bootstrap.php'; +require __DIR__ . DIRECTORY_SEPARATOR . 'bootstrap.php'; + Zephir\Bootstrap::boot(); diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 34a7d356df..0083e87dd9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -4,7 +4,7 @@ xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd" backupGlobals="false" backupStaticAttributes="false" - bootstrap="./unit-tests/Bootstrap.php" + bootstrap="./unit-tests/bootstrap.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" diff --git a/unit-tests/Data/TestExClass.php b/unit-tests/Data/TestExClass.php new file mode 100644 index 0000000000..92a12491c6 --- /dev/null +++ b/unit-tests/Data/TestExClass.php @@ -0,0 +1,5 @@ +assertTrue($t->testClassExists('TestExClass')); $this->assertFalse($t->testClassExists('TestExClassx')); @@ -31,7 +36,8 @@ public function testAssertations() // with namespace $this->assertTrue($t->testClassExists('\\Test\\Exists')); - $this->assertFalse($t->testInterfaceExists('TestExClass')); // class not interface + // class not interface + $this->assertFalse($t->testInterfaceExists('TestExClass')); $this->assertTrue($t->testInterfaceExists('TestExInterface')); $this->assertFalse($t->testInterfaceExists('TestExInterfacex')); diff --git a/unit-tests/Bootstrap.php b/unit-tests/bootstrap.php similarity index 73% rename from unit-tests/Bootstrap.php rename to unit-tests/bootstrap.php index ac9358863a..4f4cf28b6f 100644 --- a/unit-tests/Bootstrap.php +++ b/unit-tests/bootstrap.php @@ -19,18 +19,18 @@ require __DIR__ . '/../bootstrap.php'; -class TestExClass -{ +if (extension_loaded('xdebug')) { + ini_set('xdebug.cli_color', 1); + ini_set('xdebug.collect_params', 0); + ini_set('xdebug.dump_globals', 'on'); + ini_set('xdebug.show_local_vars', 'on'); + ini_set('xdebug.max_nesting_level', 100); + ini_set('xdebug.var_display_max_depth', 4); } -interface TestExInterface -{ -} - -function TestExFunction() -{ -} +define('TESTS_PATH', dirname(__FILE__)); +define('DATA_PATH', dirname(__FILE__) . '/Data'); if (!extension_loaded('phalcon')) { - include_once __DIR__ . '/../prototypes/phalcon.php'; + include_once ZEPHIRPATH . 'prototypes/phalcon.php'; } diff --git a/unit-tests/phpunit b/unit-tests/phpunit new file mode 100755 index 0000000000..79162893c1 --- /dev/null +++ b/unit-tests/phpunit @@ -0,0 +1,39 @@ +#!/usr/bin/env php +