diff --git a/packages/cli/tests/case2-install.test.mjs b/packages/cli/tests/case2-install.test.mjs index 932ec4372..da4678084 100644 --- a/packages/cli/tests/case2-install.test.mjs +++ b/packages/cli/tests/case2-install.test.mjs @@ -521,6 +521,16 @@ test("row 322 F8: library personas install from the copy with no clone node_modu assert.equal(existsSync(join(x.clone, "node_modules")), false); }); +// Without selector.sh beside it the install refuses before parsing, rather than skip the selector rules. +test("the install refuses when its selector.sh is missing, before it reads or writes anything", (t) => { + const x = dependencyFreeClone(t); + rmSync(join(x.clone, "scripts", "selector.sh")); + const r = x.run(); + assert.equal(r.code, 4, r.out); + assert.ok(r.out.endsWith(`case2-install: cannot read ${join(x.clone, "scripts", "selector.sh")}\n`), r.out); + assert.equal(existsSync(x.business), false); +}); + test("row 322 F9: importer refusal keeps the error line rather than the Node banner", (t) => { const x = dependencyFreeClone(t); const copy = join(x.home, ".local", "share", "mosaic-stack", "copies", COMMIT); diff --git a/packages/cli/tests/case2-unit.test.mjs b/packages/cli/tests/case2-unit.test.mjs index 6810cb4e6..49c09d770 100644 --- a/packages/cli/tests/case2-unit.test.mjs +++ b/packages/cli/tests/case2-unit.test.mjs @@ -871,6 +871,16 @@ test("the precheck takes --org or --business, alone or matching in either order, assert.equal(r.out, "case2-precheck: --profile must be factory or library: --org\n"); }); +test("the precheck refuses when its selector.sh is missing, before any check", (t) => { + const x = host(t), lone = join(x.root, "lone", "scripts", "case2-precheck.sh"); + mkdirSync(dirname(lone), { recursive: true }); + cpSync(PRECHECK, lone); + const r = spawnSync(lone, ["--org", "acme"], { encoding: "utf8", env: { PATH: `${x.bin}:/usr/bin:/bin`, HOME: x.home } }); + assert.equal(r.status, 4, r.stdout + r.stderr); + assert.equal(r.stdout, ""); + assert.ok(r.stderr.endsWith(`case2-precheck: cannot read ${join(x.root, "lone", "scripts", "selector.sh")}\n`), r.stderr); +}); + test("the precheck refuses each failed host check", (t) => { blocked(precheck(host(t), { env: { CASE2_TEST_NODE: "v22.22.2" } }), /REFUSED node v22\.22\.2 is older than 24/); blocked(precheck(host(t), { env: { CASE2_TEST_GROUPS: `${GID} 998` } }), /REFUSED id -G prints more than one group/); diff --git a/scripts/case2-install.sh b/scripts/case2-install.sh index 4e83ece41..1a6cd63c7 100755 --- a/scripts/case2-install.sh +++ b/scripts/case2-install.sh @@ -44,7 +44,7 @@ STACK_COPY="${CASE2_STACK_COPY:-$REPO/scripts/stack-copy.sh}" usage() { echo 'usage: case2-install.sh --business ID --business-file FILE --commit SHA [--profile factory|library] [--personas DIR] [--home DIR]' >&2; exit 4; } # shellcheck source=scripts/selector.sh -. "$REPO/scripts/selector.sh" +. "$REPO/scripts/selector.sh" || { echo "case2-install: cannot read $REPO/scripts/selector.sh" >&2; exit 4; } # The selectors (rename design r2): the id family and the file family are separate scopes. A # missing value is a usage error; a flag-shaped or invalid id is the business-id refusal below; a # flag-shaped file, a repeated spelling and a conflict say why. All exit 4, as before. diff --git a/scripts/case2-precheck.sh b/scripts/case2-precheck.sh index 34ff020bc..26fe54e90 100755 --- a/scripts/case2-precheck.sh +++ b/scripts/case2-precheck.sh @@ -56,7 +56,7 @@ MARKER_TOKEN_CEILING=2000 usage() { echo 'usage: case2-precheck.sh --business ID [--profile factory|library] | --business ID --library-status' >&2; exit 4; } # shellcheck source=scripts/selector.sh -. "$REPO/scripts/selector.sh" +. "$REPO/scripts/selector.sh" || { echo "case2-precheck: cannot read $REPO/scripts/selector.sh" >&2; exit 4; } # --org and --business are one selector here (rename design r2). A missing value is a usage error, # a flag-shaped or invalid one the business-id refusal below, and a repeated or conflicting one # says why; all exit 4, as before.