Esempio n. 1
0
    exit;
}
// set up some variables
$passthru = check_opt($options, 'p', 'passthru');
$commands = array_diff($options, $parameters);
$all = empty($commands);
$ret = 0;
// run tests
if ($all || check_opt($commands, 'l', 'lint')) {
    $ret += check_lint();
}
if ($all || check_opt($commands, 's', 'style')) {
    $ret += check_style($passthru);
}
if ($all || check_opt($commands, 'u', 'unit')) {
    $ret += check_unit($passthru);
}
// output Tests ok, if no arguments passed
if ($all && $ret === 0) {
    echo "Tests ok, submit away :) \n";
}
exit($ret);
//return the combined/single return value of tests
/**
 *  Check if the given options array contains any of the $opts specified
 *
 * @param array $options the array from getopt()
 * @param string $opts,... options to check for
 * @return bool If one of the specified options is set
 */
function check_opt($options)
Esempio n. 2
0
// set up some variables
$parameters = array('p' => false, 'c' => false, 'passthru' => false, 'commands' => false);
$passthru = check_opt($options, 'p', 'passthru');
$command_only = check_opt($options, 'c', 'commands');
$commands = array_diff_assoc($options, $parameters);
$all = empty($commands);
$ret = 0;
// run tests
if (($all || check_opt($commands, 'l', 'lint')) && !getenv('SKIP_LINT_CHECK')) {
    $ret += check_lint($passthru, $command_only);
}
if (($all || check_opt($commands, 's', 'style')) && !getenv('SKIP_STYLE_CHECK')) {
    $ret += check_style($passthru, $command_only);
}
if (($all || check_opt($commands, 'u', 'unit')) && !getenv('SKIP_UNIT_CHECK')) {
    $ret += check_unit($passthru, $command_only);
}
// output Tests ok, if no arguments passed
if ($all && $ret === 0) {
    echo "Tests ok, submit away :) \n";
}
exit($ret);
//return the combined/single return value of tests
/**
 * Runs php -l and tests for any syntax errors
 *
 * @param bool $passthru display the output as comes in
 * @param bool $command_only only display the intended command, no checks
 * @return int the return value from running php -l (0 = success)
 */
function check_lint($passthru = false, $command_only = false)