2019-03-11 05:04:20 +03:00
|
|
|
<?php
|
|
|
|
|
2019-10-17 22:24:25 +03:00
|
|
|
require_once __DIR__ . '/../../../tests/bootstrap.php';
|
2019-03-11 05:04:20 +03:00
|
|
|
|
|
|
|
// Fix for "Autoload path not allowed: .../cookbook/tests/testcase.php"
|
2020-11-17 19:06:20 +03:00
|
|
|
\OC_App::loadApp('cookbook');
|
2021-02-07 14:10:11 +03:00
|
|
|
|
2021-07-13 22:06:40 +03:00
|
|
|
function resetEnvironmentToBackup(string $name = 'default', bool $forceprint = false) {
|
|
|
|
$output = [];
|
|
|
|
$ret = -1;
|
2021-07-26 14:14:56 +03:00
|
|
|
exec("./.github/actions/run-tests/reset-from-container.sh $name 2>&1", $output, $ret);
|
2021-07-13 22:06:40 +03:00
|
|
|
if ($ret !== 0 || $forceprint) {
|
2021-02-07 14:10:11 +03:00
|
|
|
echo "\nStandard output:\n";
|
|
|
|
print_r($output);
|
|
|
|
echo "Return value: $ret\n";
|
2021-07-26 14:14:56 +03:00
|
|
|
if ($ret !== 0) {
|
|
|
|
throw new Exception("Could not reset environment");
|
2021-07-13 22:06:40 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function runOCCCommand(array $args, bool $forceprint = false) {
|
|
|
|
$output = [];
|
|
|
|
$ret = -1;
|
2021-07-26 14:14:56 +03:00
|
|
|
$params = join(' ', array_map(function ($x) {
|
|
|
|
return escapeshellarg($x);
|
|
|
|
}, $args));
|
2022-06-19 09:42:01 +03:00
|
|
|
|
2021-08-12 18:16:55 +03:00
|
|
|
$cmd = "./.github/actions/run-tests/run-occ.sh $params 2>&1";
|
2022-06-19 09:42:01 +03:00
|
|
|
|
2021-08-12 18:16:55 +03:00
|
|
|
exec($cmd, $output, $ret);
|
2021-07-13 22:06:40 +03:00
|
|
|
if ($ret !== 0 || $forceprint) {
|
|
|
|
echo "\nStandard output:\n";
|
|
|
|
print_r($output);
|
|
|
|
echo "Return value: $ret\n";
|
2021-07-26 14:14:56 +03:00
|
|
|
if ($ret !== 0) {
|
|
|
|
throw new Exception("Could not run OCC command");
|
2021-07-13 22:06:40 +03:00
|
|
|
}
|
2021-02-07 14:10:11 +03:00
|
|
|
}
|
|
|
|
}
|