echo "screenshot url:    {$screenshot_url}\n";
    echo "printer:           {$phpunit_printer}\n";
    echo "include-path:      {$phpunit_includepath}\n";
    echo 'error reporting:   E_ALL' . chr(10);
}
error_reporting(E_ALL);
// Ensure a clean destination for results exists.
exec('rm -rf "' . $results_directory . '"');
mkdir($results_directory);
exec('cp -R "' . __DIR__ . '/fancybox" "' . $results_directory . '"');
// Set path to stuff in the HTML report
if ($copytests) {
    $reltestpath = '';
} else {
    // Find a best guess relative path between results directory and tests directory to use for linking from result.html to tests
    $reltestpath = find_relative_path($results_directory, $tests_directory);
}
// Start job-wide services.
$selenium_is_running = selenium_is_running($selenium_host, $selenium_port);
$xvfb = NULL;
$selenium = NULL;
if ($selenium_is_running) {
    if ($output_startup_services) {
        echo 'Selenium is already running. Using the existing service.' . PHP_EOL;
    }
    $selenium = new SeleniumExternalService($selenium_host, $selenium_port);
} else {
    if ($output_startup_services) {
        echo 'Selenium is not running. Starting a new, local service.' . PHP_EOL;
    }
    if (!$onscreen) {
        }
        $i++;
    }
    $j = count($from) - 1;
    // Add '..' until the path is the same
    while ($i <= $j) {
        if (!empty($from[$j])) {
            $relpath .= '..' . DIRECTORY_SEPARATOR;
        }
        $j--;
    }
    // Go to folder from where it starts differing
    while (isset($to[$i])) {
        if (!empty($to[$i])) {
            $relpath .= $to[$i] . DIRECTORY_SEPARATOR;
        }
        $i++;
    }
    // Strip last separator
    return substr($relpath, 0, -1);
}
foreach ($wgKwidgetPsEnabledModules as $moduleName) {
    $modulePath = $wgKalturaPSHtml5ModulesDir . '/' . $moduleName;
    $relativeModulePath = find_relative_path($IP, $modulePath);
    if (is_file($modulePath . '/' . $moduleName . '.json')) {
        MwEmbedResourceManager::register($relativeModulePath);
    }
}
# Add the resource loader hooks
$wgHooks['ResourceLoaderRegisterModules'][] = 'MwEmbedResourceManager::registerModules';
$wgHooks['ResourceLoaderGetConfigVars'][] = 'MwEmbedResourceManager::registerConfigVars';