|
@@ -296,32 +296,31 @@ class Route_AsyncJobs extends RouteBase {
|
|
$seBinPath = $this->getSbinPath();
|
|
$seBinPath = $this->getSbinPath();
|
|
|
|
|
|
$listTest = []; // [ [ ret_code, cmd ], ... ]
|
|
$listTest = []; // [ [ ret_code, cmd ], ... ]
|
|
|
|
+ $listTest[] = [ 1, "cd '{$seBinPath}' && bash ./se.sh" ]; // expected usage
|
|
|
|
+ $listTest[] = [ 1, "cd '{$seBinPath}' && bash ./se.sh non-existing-script" ]; // expected Module not exists + usage
|
|
|
|
+ $listTest[] = [ 1, "cd '{$seBinPath}' && bash ./se.sh --sudo" ]; // expected Missing script name + usage
|
|
$listTest[] = [ 0, "cd '{$seBinPath}' && bash ./se.sh test-exit-0" ];
|
|
$listTest[] = [ 0, "cd '{$seBinPath}' && bash ./se.sh test-exit-0" ];
|
|
$listTest[] = [ 1, "cd '{$seBinPath}' && bash ./se.sh test-exit-1" ];
|
|
$listTest[] = [ 1, "cd '{$seBinPath}' && bash ./se.sh test-exit-1" ];
|
|
$listTest[] = [ 1, "cd '{$seBinPath}' && bash ./se.sh test-sudo" ];
|
|
$listTest[] = [ 1, "cd '{$seBinPath}' && bash ./se.sh test-sudo" ];
|
|
$listTest[] = [ 0, "cd '{$seBinPath}' && bash ./se.sh --sudo test-sudo" ];
|
|
$listTest[] = [ 0, "cd '{$seBinPath}' && bash ./se.sh --sudo test-sudo" ];
|
|
|
|
|
|
- // $cmd = "cd '{$seBinPath}' && bash se.sh install-pm2-www"; // DBG: require root, add prefix 'sudo--'
|
|
|
|
- // $cmd = "cd '{$seBinPath}' && bash ./se.sh --sudo install-pm2-www";
|
|
|
|
- // $cmd = "cd '{$seBinPath}' && bash se.sh install-pm2-www"; // expected Permission denied - missing sudo
|
|
|
|
- // $cmd = "cd '{$seBinPath}' && bash se.sh sudo "; // expected Missing script name + usage
|
|
|
|
- // $cmd = "cd '{$seBinPath}' && bash se.sh non-existing-script"; // expecte Module not exists + usage
|
|
|
|
- // $cmd = "cd '{$seBinPath}' && bash se.sh "; // expected usage
|
|
|
|
-
|
|
|
|
foreach ($listTest as $idx => $test) {
|
|
foreach ($listTest as $idx => $test) {
|
|
list($expected, $cmd) = $test;
|
|
list($expected, $cmd) = $test;
|
|
$out = [];
|
|
$out = [];
|
|
V::exec($cmd = "{$cmd} 2>&1", $out, $ret);
|
|
V::exec($cmd = "{$cmd} 2>&1", $out, $ret);
|
|
- echo UI::h('details', [], [
|
|
|
|
- UI::h('summary', [], "test {$idx} " . (($expected === $ret) ? "SUCCESS" : "FAILED")),
|
|
|
|
- UI::h('div', [], [
|
|
|
|
- UI::h('pre', [], "RET({$ret}). OUTPUT:" . "\n" . implode("\n", $out)),
|
|
|
|
- UI::h('div', [ 'class' => "alert alert-info" ], "test ({$ret})" . "\n<br>" . implode("\n<br>", $out) ),
|
|
|
|
- ($expected === $ret)
|
|
|
|
- ? UI::h('div', [ 'class' => 'alert alert-success' ], "OK: script return as expected!")
|
|
|
|
- : UI::h('div', [ 'class' => 'alert alert-danger' ], "FAIL: script return '{$ret}' but expected '{$expected}'!")
|
|
|
|
- ,
|
|
|
|
- ]),
|
|
|
|
|
|
+ echo UI::h('p5:Details', [
|
|
|
|
+ 'theme' => 'dark',
|
|
|
|
+ 'summary' => "test {$idx} " . (($expected === $ret) ? "SUCCESS" : "FAILED"),
|
|
|
|
+ 'summary.style' => "font-size:small",
|
|
|
|
+ 'body.style' => "font-size:small",
|
|
|
|
+ ], [
|
|
|
|
+ UI::h('pre', [], $cmd),
|
|
|
|
+ UI::h('pre', [], "RET({$ret}). OUTPUT:" . "\n" . implode("\n", $out)),
|
|
|
|
+ UI::h('p5:Alert', [ 'type' => 'info' ], "test ({$ret})" . "\n<br>" . implode("\n<br>", $out) ),
|
|
|
|
+ ($expected === $ret)
|
|
|
|
+ ? UI::h('p5:Alert', [ 'type' => 'success' ], "OK: script return as expected!")
|
|
|
|
+ : UI::h('p5:Alert', [ 'type' => 'danger' ], "FAIL: script return '{$ret}' but expected '{$expected}'!")
|
|
|
|
+ ,
|
|
]);
|
|
]);
|
|
}
|
|
}
|
|
|
|
|