Skip to content
Snippets Groups Projects
Commit 3bcce1a4 authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #751 from greezybacon/feature/package-run-tests


Expose fail count to shell environment

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents c3ba674a d9ad5a13
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,10 @@ function get_osticket_root_path() {
return realpath($start);
}
function run_tests($root) {
return (require "$root/setup/test/run-tests.php");
}
# Check PHP syntax across all php files
function glob_recursive($pattern, $flags = 0) {
$files = glob($pattern, $flags);
......@@ -64,6 +68,10 @@ function package($pattern, $destination, $recurse=false, $exclude=false) {
}
}
# Run tests before continuing
if (run_tests($root) > 0)
die("Regression tests failed. Cowardly refusing to package\n");
# Create the stage folder for the install files
if (!is_dir($stage_path))
mkdir($stage_path);
......
......@@ -4,25 +4,29 @@ if (php_sapi_name() != 'cli') exit();
require_once "tests/class.test.php";
function get_osticket_root_path() {
# Hop up to the root folder
$start = dirname(__file__);
for (;;) {
if (file_exists($start . '/main.inc.php')) break;
$start .= '/..';
if (!function_exists('get_osticket_root_path')) {
function get_osticket_root_path() {
# Hop up to the root folder
$start = dirname(__file__);
for (;;) {
if (file_exists($start . '/main.inc.php')) break;
$start .= '/..';
}
return realpath($start);
}
return realpath($start);
}
$root = get_osticket_root_path();
# Check PHP syntax across all php files
function glob_recursive($pattern, $flags = 0) {
$files = glob($pattern, $flags);
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
$files = array_merge($files,
glob_recursive($dir.'/'.basename($pattern), $flags));
if (!function_exists('glob_recursive')) {
# Check PHP syntax across all php files
function glob_recursive($pattern, $flags = 0) {
$files = glob($pattern, $flags);
foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
$files = array_merge($files,
glob_recursive($dir.'/'.basename($pattern), $flags));
}
return $files;
}
return $files;
}
$fails = array();
......@@ -37,6 +41,7 @@ function show_fails() {
$script = str_replace($root.'/', '', $script);
print("$test: $message @ $script:$line\n");
}
return count($fails);
}
}
if (function_exists('pcntl_signal')) {
......@@ -44,8 +49,7 @@ if (function_exists('pcntl_signal')) {
function show_fails_on_ctrlc() {
while (@ob_end_flush());
print("\n");
show_fails();
exit();
exit(show_fails());
}
pcntl_signal(SIGINT, 'show_fails_on_ctrlc');
}
......@@ -64,4 +68,10 @@ foreach (glob_recursive(dirname(__file__)."/tests/test.*.php") as $t) {
}
show_fails();
// If executed directly expose the fail count to a shell script
global $argv;
if (!strcasecmp(basename($argv[0]), basename(__file__)))
exit(count($fails));
else
return count($fails);
?>
......@@ -10,6 +10,7 @@ class Test {
'/include/PasswordHash.php',
'/include/pear/',
'/include/Spyc.php',
'/setup/cli/stage/',
);
function Test() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment