Require the unit copy to come before the enable, and compare first-run to a clean run
Naming a unit's source in default/ counted as installing it, so a command that never copied the unit, or copied it after enabling it, passed. Look for the install or cp of that source ahead of the enable instead. The first-run test accepted any script that tried three of the units. It now requires one enable --now per unit and, with each unit unknown in turn, exactly the calls of a clean run minus that unit.
This commit is contained in:
1 parent
55fc353e47
commit
5489418c9d
2 files changed
+37
-9
No files matched your search
@@ -38,19 +38,33 @@ pass "first-run uses one lifecycle completion marker"
|
||||
# missing from a build must cost first-run only that unit.
|
||||
cat >"$mock_bin/systemctl" <<'SH'
|
||||
#!/bin/bash
|
||||
[[ $* != *omarchy-sleep-lock.service* ]] || exit 1
|
||||
[[ $* != *"$OMARCHY_TEST_MISSING_UNIT"* ]] || exit 1
|
||||
printf '%s\n' "$*" >>"$OMARCHY_TEST_CALLS"
|
||||
SH
|
||||
cat >"$mock_bin/omarchy-hook-install" <<'SH'
|
||||
#!/bin/bash
|
||||
echo hook >>"$OMARCHY_TEST_CALLS"
|
||||
echo "hook $*" >>"$OMARCHY_TEST_CALLS"
|
||||
SH
|
||||
chmod +x "$mock_bin/systemctl" "$mock_bin/omarchy-hook-install"
|
||||
|
||||
if PATH="$mock_bin:$PATH" OMARCHY_TEST_CALLS="$test_tmp/calls" bash "$ROOT/install/user/first-run/enable-user-units.sh"; then
|
||||
fail "first-run reports a unit it could not enable"
|
||||
fi
|
||||
for expected in bt-agent.service omarchy-crash-watch.service hook; do
|
||||
grep -Fq "$expected" "$test_tmp/calls" || fail "a unit missing from the build does not cost first-run $expected"
|
||||
enable_user_units() {
|
||||
rm -f "$test_tmp/calls"
|
||||
PATH="$mock_bin:$PATH" OMARCHY_TEST_CALLS="$test_tmp/calls" OMARCHY_TEST_MISSING_UNIT="$1" \
|
||||
bash "$ROOT/install/user/first-run/enable-user-units.sh"
|
||||
}
|
||||
|
||||
enable_user_units no-such-unit || fail "first-run enables its user units"
|
||||
clean_run=$(<"$test_tmp/calls")
|
||||
grep -Fq 'hook theme-set' <<<"$clean_run" || fail "first-run installs the theme hook"
|
||||
mapfile -t units < <(sed -n 's/^--user enable --now //p' <<<"$clean_run")
|
||||
|
||||
for unit in "${units[@]}"; do
|
||||
[[ $unit != *" "* ]] || fail "first-run enables each unit on its own" "$unit"
|
||||
if enable_user_units "$unit"; then
|
||||
fail "first-run reports a unit it could not enable" "$unit"
|
||||
fi
|
||||
[[ $(<"$test_tmp/calls") == "$(grep -Fvx -- "--user enable --now $unit" <<<"$clean_run")" ]] ||
|
||||
fail "a unit missing from the build costs first-run only that unit" "$unit"
|
||||
done
|
||||
(( ${#units[@]} > 1 )) || fail "first-run enables each unit on its own"
|
||||
pass "a unit missing from the build costs first-run only that unit"
|
||||
Reference in new issue
Block a user