Skip to content

Commit 5449f8d

Browse files
committed
Improved tests process
1 parent 95c02e2 commit 5449f8d

File tree

8 files changed

+69
-14
lines changed

8 files changed

+69
-14
lines changed

.travis.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,22 @@ env:
2121
- LD_LIBRARY_PATH="$TRAVIS_BUILD_DIR/build/lib":$LD_LIBRARY_PATH
2222
- LIBRARY_PATH="$TRAVIS_BUILD_DIR/build/lib":$LIBRARY_PATH
2323
- C_INCLUDE_PATH="$TRAVIS_BUILD_DIR/build/include"
24+
- CFLAGS="-g3 -O0 -Wall -fvisibility=hidden"
25+
- ZEND_DONT_UNLOAD_MODULES=1
26+
- USE_ZEND_ALLOC=0
2427
matrix:
25-
- CC="ccache gcc" CFLAGS="-g3 -O0 -fno-delete-null-pointer-checks -Wall -std=gnu90 -fvisibility=hidden"
26-
- CC="ccache clang" CFLAGS="-g3 -O0 -fcolor-diagnostics -Wall -std=gnu90"
28+
- CC="ccache gcc"
29+
- CC="ccache clang"
2730

2831
matrix:
2932
fast_finish: true
3033
allow_failures:
3134
- php: nightly
3235
include:
33-
- env: CC="ccache gcc" CFLAGS="-g3 -O0 -fno-delete-null-pointer-checks -Wall -std=gnu90 -fvisibility=hidden"
36+
- env: CC="ccache gcc"
3437
php: nightly
3538
compiler: gcc
36-
- env: CC="ccache clang" CFLAGS="-g3 -O0 -fcolor-diagnostics -Wall -std=gnu90"
39+
- env: CC="ccache clang"
3740
php: nightly
3841
compiler: clang
3942

@@ -47,15 +50,15 @@ cache:
4750
- $HOME/.composer/cache
4851

4952
install:
50-
- bash ./tests/ci/install-travis
53+
- bash ./unit-tests/ci/install-travis
5154
- composer --prefer-source install
5255

5356
before_install:
5457
- if [[ ! -z "${GH_TOKEN}" ]]; then composer config github-oauth.github.com ${GH_TOKEN}; echo "Configured Github token"; fi;
5558

5659
script:
5760
- php --ri "Zephir Parser"
58-
- valgrind --read-var-info=yes --error-exitcode=1 --fullpath-after= --track-origins=yes --leak-check=full ./vendor/bin/phpunit -c phpunit.xml.dist --debug tests/
61+
- valgrind --read-var-info=yes --error-exitcode=1 --fullpath-after= --track-origins=yes --leak-check=full --num-callers=20 $(phpenv which php) ./unit-tests/phpunit -c phpunit.xml.dist --debug unit-tests/
5962

6063
notifications:
6164
email:
Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,25 @@
2020
// turn on all errors
2121
error_reporting(-1);
2222

23-
$vendorPath = dirname(dirname(__FILE__)) . '/vendor';
23+
ini_set('display_errors', 1);
24+
ini_set('display_startup_errors', 1);
25+
26+
setlocale(LC_ALL, 'en_US.utf-8');
2427

25-
if (!is_file($vendorPath . '/autoload.php')) {
26-
throw new \RuntimeException(
27-
'Unable to locate autoloader. Run `composer install` from the project root directory.'
28-
);
28+
set_time_limit(-1);
29+
30+
if (!ini_get('date.timezone')) {
31+
ini_set('date.timezone', 'UTC');
2932
}
3033

31-
require $vendorPath . '/autoload.php';
34+
clearstatcache();
35+
36+
$vendorPath = dirname(dirname(__FILE__)) . '/vendor';
37+
38+
if (file_exists($vendorPath . '/autoload.php')) {
39+
require $vendorPath . '/autoload.php';
40+
}
3241

33-
define('ZEPHIR_DATA', __DIR__ . DIRECTORY_SEPARATOR . 'Data' . DIRECTORY_SEPARATOR);
34-
define('OUTPUT_DATA', __DIR__ . DIRECTORY_SEPARATOR . 'Output' . DIRECTORY_SEPARATOR);
42+
define('TESTS_ROOT', __DIR__);
43+
define('ZEPHIR_DATA', __DIR__ . DIRECTORY_SEPARATOR . 'Data');
44+
define('OUTPUT_DATA', __DIR__ . DIRECTORY_SEPARATOR . 'Output');

unit-tests/phpunit

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
/*
5+
+--------------------------------------------------------------------------+
6+
| Zephir Parser. |
7+
+--------------------------------------------------------------------------+
8+
| Copyright (c) 2013-2017 Zephir Team and contributors |
9+
+--------------------------------------------------------------------------+
10+
| This source file is subject the MIT license, that is bundled with |
11+
| this package in the file LICENSE, and is available through the |
12+
| world-wide-web at the following url: |
13+
| http://zephir-lang.com/license.html |
14+
| |
15+
| If you did not receive a copy of the MIT license and are unable |
16+
| to obtain it through the world-wide-web, please send a note to |
17+
| license@zephir-lang.com so we can mail you a copy immediately. |
18+
+--------------------------------------------------------------------------+
19+
*/
20+
21+
require __DIR__ . DIRECTORY_SEPARATOR . 'bootstrap.php';
22+
23+
$exit = true;
24+
if ($index = array_search('--not-exit', $_SERVER['argv'])) {
25+
$exit = false;
26+
unset($_SERVER['argv'][$index]);
27+
}
28+
29+
if (!class_exists('PHPUnit_TextUI_Command')) {
30+
fwrite(STDERR,
31+
'You need to set up the project dependencies using Composer:' . PHP_EOL . PHP_EOL .
32+
' composer install' . PHP_EOL . PHP_EOL .
33+
'You can learn all about Composer on https://getcomposer.org/.' . PHP_EOL
34+
);
35+
36+
die(1);
37+
}
38+
39+
$res = PHPUnit_TextUI_Command::main($exit);
40+
if ($res) {
41+
exit($res);
42+
}

0 commit comments

Comments
 (0)