Dawnline 0.14.1
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / ucode static checks (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Blocked by required conditions
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / ucode static checks (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 24.10) (push) Blocked by required conditions
CI / ucode compiles and tests pass (OpenWrt 25.12) (push) Blocked by required conditions
- The updater started without a command, with one it doesn't know, or with an install of nothing prints its usage and exits. It no longer counts that as a failed update: nothing goes into the service log, Activity or the update history, and Components shows no failed job. `updater --help` prints the same usage
This commit is contained in:
1 parent
dc0f159447
commit
a1915f070b
6 files changed
+61
-6
No files matched your search
@@ -0,0 +1,36 @@
|
||||
// usr/libexec/dawnline/updater: a call without a command it knows prints the usage and changes nothing (no job for
|
||||
// Components, no history, no "update failed" in the service log).
|
||||
import * as fs from 'fs';
|
||||
|
||||
const REPO = `${sourcepath(0, true)}/../..`;
|
||||
const UPDATER = `${REPO}/package/luci-app-dawnline/root/usr/libexec/dawnline/updater`;
|
||||
const MODULES = `${REPO}/package/luci-app-dawnline/root/usr/share/ucode/*.uc`;
|
||||
const JOB = '/var/run/dawnline/update-job.json';
|
||||
|
||||
/** The updater run with `args`: { code, out } (stdout and stderr together). */
|
||||
function updater(args) {
|
||||
let p = fs.popen(`ucode -L '${MODULES}' '${UPDATER}' ${args} 2>&1; echo "exit=$?"`, 'r');
|
||||
let out = p.read('all') ?? '';
|
||||
p.close();
|
||||
let m = match(out, /exit=([0-9]+)\s*$/);
|
||||
return { code: m ? +m[1] : -1, out: replace(out, /exit=[0-9]+\s*$/, '') };
|
||||
}
|
||||
|
||||
test('without a command it knows: the usage, nothing written', () => {
|
||||
for (let args in [ '', 'frobnicate', 'install', "install ''" ]) {
|
||||
fs.unlink(JOB);
|
||||
let r = updater(args);
|
||||
eq(r.code, 2, `exit code for "${args}"`);
|
||||
ok(index(r.out, 'Usage:') == 0, `usage for "${args}"`);
|
||||
ok(index(r.out, 'updater install app | app@<tag>') > 0, `the commands for "${args}"`);
|
||||
ok(!fs.access(JOB), `no job for "${args}"`);
|
||||
}
|
||||
});
|
||||
|
||||
test('asked for help: the usage, exit 0', () => {
|
||||
for (let args in [ '-h', '--help', 'help' ]) {
|
||||
let r = updater(args);
|
||||
eq(r.code, 0, `exit code for "${args}"`);
|
||||
ok(index(r.out, 'Usage:') == 0, `usage for "${args}"`);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user