if (!empty($_SERVER['argv'][2]) && strtolower($_SERVER['argv'][2]) === 'html') {
    $mode = 'html';
}
$test_script_name = realpath($_SERVER['argv'][1]);
if (!$test_script_name) {
    echo "Error: The test script [{$_SERVER['argv'][1]}] does not exist. Please try again." . PHP_EOL;
    exit;
}
$status = get_status_binaries(DIR_BUILD_PREFIX);
if (!count($status['good'])) {
    echo 'Could not find binaries to test against' . PHP_EOL;
    exit;
}
$text = array();
foreach ($status['good'] as $version => $it) {
    $out = run_shell_command(DIR_BUILD_PREFIX . $version . '/bin/php -d error_reporting=-1  -f ' . $test_script_name);
    if ($out['stdout']) {
        $text[$version] = $out['stdout'];
    } else {
        $text[$version] = 'No output';
    }
}
uksort($text, 'strnatcmp');
// FIXME: print_r() isn't ideal here
if ($mode === 'stdout') {
    print_r($text);
    exit;
}
// Colours defined in inc/config.php
$uniques = array_unique($text);
$colour_matches = array_combine(array_slice($colours, 0, count($uniques)), $uniques);
/**
 * Checks if $configure_options are valid
 * Returns false with error, array() if yes, array(...) if no
*/
function check_configure_valid($path, $configure_options)
{
    $out = run_shell_command($path . '/configure --help');
    if (empty($out['stdout'])) {
        return false;
    }
    $configure_help = $out['stdout'];
    $unknowns = array();
    foreach ($configure_options as $option) {
        if (false === stripos($configure_help, $option)) {
            $unknowns[] = $option;
        }
    }
    return $unknowns;
}