Record the installer's region choice during system setup

This commit is contained in:
ZacharyZhang-NY committed 2026-10-05 23:20:36 -04:00
1 parent 83d158ad07
commit c86af5cea5
6 files changed
+68 -4

No files matched your search

+20
View File
@@ -54,3 +54,23 @@ if output=$("$region_bin" 2>&1); then
fi
[[ $output == "Unknown region in $region_file: mars" ]] || fail "an unknown region names the file and value" "$output"
pass "an unknown region fails and names the file and value"
region_setup="$test_tmp/region.sh"
sed "s|/etc/omarchy|$test_tmp/etc-omarchy|g" "$ROOT/install/config/region.sh" >"$region_setup"
OMARCHY_REGION=china bash -e "$region_setup"
[[ $(<"$test_tmp/etc-omarchy/region") == "china" ]] || fail "install records the China region"
pass "install records the China region"
OMARCHY_REGION=global bash -e "$region_setup"
[[ ! -e $test_tmp/etc-omarchy/region ]] || fail "install records Global by leaving no region file"
OMARCHY_REGION=china bash -e "$region_setup"
env -u OMARCHY_REGION bash -e "$region_setup"
[[ ! -e $test_tmp/etc-omarchy/region ]] || fail "an installer that passes no region installs Global"
pass "Global and an unset region leave no region file"
if output=$(OMARCHY_REGION=mars bash -e "$region_setup" 2>&1); then
fail "install rejects an unknown region" "$output"
fi
[[ $output == "Unknown OMARCHY_REGION: mars" ]] || fail "install names the unknown region" "$output"
pass "install rejects an unknown region"
+20
View File
@@ -61,6 +61,7 @@ trap 'if [[ ${FUNCNAME[0]:-} == "$PROMPT_FN" ]]; then printf "returned\n" >>"$MA
"$PROMPT_FN"
printf 'region=%s\n' "${region:-}"
printf 'keyboard=%s\n' "${keyboard:-}"
printf 'keyboard_label=%s\n' "${keyboard_label:-}"
printf 'username=%s\n' "${username:-}"
@@ -123,6 +124,25 @@ source "$ROOT/install/provisioning/setup-form.sh"
fail "English (US) leads the keyboard layouts so gum choose opens on the default"
pass "the form publishes the 0/1/130 status contract and leads with English (US)"
# Region
run_prompt omarchy_prompt_region "0:China"
assert_status 0 "region prompt succeeds"
[[ $(field region) == "china" ]] || fail "region prompt stores China as china"
grep -qxF -- 'choose --selected Global --header Select region Global China' "$GUM_ARGS" || fail "region prompt offers Global then China and preselects Global"
run_prompt omarchy_prompt_region "0:Global"
[[ $(field region) == "global" ]] || fail "region prompt stores Global as global"
pass "region prompt maps Global and China to the stored region"
run_prompt omarchy_prompt_region "1:"
assert_status "$OMARCHY_FORM_BACK" "region prompt reports Esc as back"
assert_returned "region prompt survives Esc under set -e"
run_prompt omarchy_prompt_region "130:"
assert_status "$OMARCHY_FORM_SIGNAL" "region prompt reports Ctrl+C as the caller's signal"
assert_returned "region prompt survives Ctrl+C under set -e"
pass "region prompt propagates Esc and Ctrl+C without dying under set -e"
# Keyboard
run_prompt omarchy_prompt_keyboard "0:German"