66
esac
67
}
68
69
+# The recovery ending both failure-adjacent flows close with: an absolute,
70
+# copy-paste-safe login command. "now" is the install-only success variant
71
+# (setup skipped or unavailable, PATH untouched); "later" is the setup-failure
72
+# variant printed on stderr after the failure warning.
73
+recovery_tail() {
74
+ case $1 in
75
+ now) printf 'To get started now, run:\n\n %s login' "$2" ;;
76
+ later) printf 'To get started, run:\n\n %s login' "$2" ;;
77
+ *) fail "recovery_tail: unknown mode $1" ;;
78
+ esac
79
+}
80
+
81
# macOS Terminal.app starts bash as a login shell, which reads only the first
82
# existing of ~/.bash_profile, ~/.bash_login, ~/.profile and never ~/.bashrc.
83
# Probe a real login bash over the sandboxed HOME to prove the PATH entry
663
if grep -Fq 'install --shell' "$composio_log"; then
664
fail "$interpreter_name unset SHELL must not run shell setup"
665
fi
654
- assert_tail "$unset_shell_output" $'To get started now, run:\n\n '"$unset_shell_install/composio login" "$interpreter_name unset SHELL install-only tail"
666
+ assert_tail "$unset_shell_output" "$(recovery_tail now "$unset_shell_install/composio")" "$interpreter_name unset SHELL install-only tail"
667
668
# Runs the given command in the background, SIGTERMs it once the delayed
669
# download is reached, and asserts the process exits with 128+15.
816
[[ -x "$unsafe_install/composio" ]] || fail "$interpreter_name unsafe variant must retain the binary"
817
assert_contains "$unsafe_variant_output" 'warning:' "$interpreter_name unsafe variant warning"
818
assert_contains "$unsafe_variant_output" "$unsafe_bin" "$interpreter_name unsafe variant warning names the rejected path"
807
- assert_tail "$unsafe_variant_output" $'To get started, run:\n\n '"$unsafe_install/composio login" "$interpreter_name unsafe variant recovery tail"
819
+ assert_tail "$unsafe_variant_output" "$(recovery_tail later "$unsafe_install/composio")" "$interpreter_name unsafe variant recovery tail"
820
done
821
822
for base_mode in fail empty; do
866
fi
867
[[ ! -e "$none_home/.bashrc" && ! -e "$none_home/.bash_profile" ]] || fail "$interpreter_name none must not write rc files"
868
assert_contains "$none_output" 'COMPOSIO_INSTALL_SHELL=none' "$interpreter_name none skip disclosure"
857
- assert_tail "$none_output" $'To get started now, run:\n\n '"$none_install/composio login" "$interpreter_name none install-only tail"
869
+ assert_tail "$none_output" "$(recovery_tail now "$none_install/composio")" "$interpreter_name none install-only tail"
870
871
# none + already-resolving installed command uses the bare Case A ending.
872
reset_case
914
fail "$interpreter_name unknown shell must not run shell setup"
915
fi
916
[[ ! -e "$unknown_home/.bashrc" ]] || fail "$interpreter_name unknown shell must not write rc files"
905
- assert_tail "$unknown_output" $'To get started now, run:\n\n '"$unknown_install/composio login" "$interpreter_name unknown shell install-only tail"
917
+ assert_tail "$unknown_output" "$(recovery_tail now "$unknown_install/composio")" "$interpreter_name unknown shell install-only tail"
918
919
# Shadowing: bin dir on the inherited PATH, but another composio resolves
920
# first. The ending must never run the shadowed bare command.
1029
[[ -x "$wf_delegated_install/composio" ]] || fail "$interpreter_name delegated setup failure must retain the binary"
1030
assert_contains "$wf_delegated_output" 'warning: Automatic PATH setup for zsh failed' "$interpreter_name delegated setup failure warning"
1031
assert_contains "$wf_delegated_output" 'COMPOSIO_DEBUG=1' "$interpreter_name delegated setup failure points at the captured output"
1020
- assert_tail "$wf_delegated_output" $'To get started, run:\n\n '"$wf_delegated_install/composio login" "$interpreter_name delegated setup failure recovery tail"
1032
+ assert_tail "$wf_delegated_output" "$(recovery_tail later "$wf_delegated_install/composio")" "$interpreter_name delegated setup failure recovery tail"
1033
1034
# Inline path: helper failure inside a conditional must propagate explicitly.
1035
+ # COMPOSIO_QUIET=1 and COMPOSIO_INSTALL_HELP=0 are set on purpose: both only
1036
+ # gate the normal-success final block, so this one case also proves they are
1037
+ # no-ops on the setup-failure path — the warning and the recovery tail reach
1038
+ # the user even with all optional output suppressed.
1039
reset_case
1040
CASE_SHELL_CAPABILITY=unsupported
1041
+ CASE_QUIET=1
1042
+ CASE_HELP=0
1043
wf_inline_home="$case_root/write-failure-inline-home"
1044
wf_inline_install="$case_root/write-failure-inline-install"
1045
mkdir -p "$wf_inline_home/.bashrc"
1047
fail "$interpreter_name inline setup failure must keep the install successful"
1048
[[ -x "$wf_inline_install/composio" ]] || fail "$interpreter_name inline setup failure must retain the binary"
1049
assert_contains "$wf_inline_output" 'warning: Automatic PATH setup for bash failed' "$interpreter_name inline setup failure warning"
1032
- assert_tail "$wf_inline_output" $'To get started, run:\n\n '"$wf_inline_install/composio login" "$interpreter_name inline setup failure recovery tail"
1050
+ assert_tail "$wf_inline_output" "$(recovery_tail later "$wf_inline_install/composio")" "$interpreter_name inline setup failure recovery tail"
1051
1052
# --- Managed-block reconciliation: a rerun replaces stale blocks instead of stacking duplicates ---
1053
1183
fail "$interpreter_name unsafe auto bin dir must not write startup files"
1184
[[ -x "$unsafe_auto_install/composio" ]] || fail "$interpreter_name unsafe auto bin dir must retain the binary"
1185
assert_contains "$unsafe_auto_output" "$unsafe_auto_bin" "$interpreter_name unsafe auto warning names the rejected path"
1168
- assert_tail "$unsafe_auto_output" $'To get started, run:\n\n '"$unsafe_auto_install/composio login" "$interpreter_name unsafe auto recovery tail"
1186
+ assert_tail "$unsafe_auto_output" "$(recovery_tail later "$unsafe_auto_install/composio")" "$interpreter_name unsafe auto recovery tail"
1187
done
1188
1189
# A valid absolute install dir containing spaces stays copy-paste safe in
1195
mkdir -p "$space_home/.bashrc"
1196
space_output=$(run_installer "$space_home" "$space_install" "$case_root/space-bin" "$stable_tag" 2>&1) ||
1197
fail "$interpreter_name spaced install dir setup failure must keep the install successful"
1180
- assert_tail "$space_output" $'To get started, run:\n\n '"'$space_install/composio' login" "$interpreter_name spaced recovery tail"
1198
+ assert_tail "$space_output" "$(recovery_tail later "'$space_install/composio'")" "$interpreter_name spaced recovery tail"
1199
space_recovery_line=$(printf '%s\n' "$space_output" | tail -n 1)
1200
space_recovery_command=${space_recovery_line# }
1201
space_recovery_command=${space_recovery_command% login}
1251
assert_not_contains "$agent_none_output" 'composio login' "$interpreter_name agent none flow must not print a login command"
1252
assert_tail "$agent_none_output" $'Composio agent login complete.\nRun composio from its installed location:\n\n '"$agent_none_install/composio --help" "$interpreter_name agent none tail"
1253
1236
- # Quiet mode keeps setup-failure recovery visible.
1237
- reset_case
1238
- CASE_QUIET=1
1239
- CASE_SHELL_CAPABILITY=unsupported
1240
- quiet_fail_home="$case_root/quiet-fail-home"
1241
- quiet_fail_install="$case_root/quiet-fail-install"
1242
- mkdir -p "$quiet_fail_home/.bashrc"
1243
- quiet_fail_output=$(run_installer "$quiet_fail_home" "$quiet_fail_install" "$case_root/quiet-fail-bin" "$stable_tag" 2>&1) ||
1244
- fail "$interpreter_name quiet setup failure must keep the install successful"
1245
- assert_contains "$quiet_fail_output" 'warning: Automatic PATH setup for bash failed' "$interpreter_name quiet keeps the setup-failure warning"
1246
- assert_tail "$quiet_fail_output" $'To get started, run:\n\n '"$quiet_fail_install/composio login" "$interpreter_name quiet keeps the recovery tail"
1247
-
1248
- # COMPOSIO_INSTALL_HELP=0 also keeps setup-failure recovery visible.
1249
- reset_case
1250
- CASE_HELP=0
1251
- CASE_SHELL_CAPABILITY=unsupported
1252
- helpless_fail_home="$case_root/helpless-fail-home"
1253
- helpless_fail_install="$case_root/helpless-fail-install"
1254
- mkdir -p "$helpless_fail_home/.bashrc"
1255
- helpless_fail_output=$(run_installer "$helpless_fail_home" "$helpless_fail_install" "$case_root/helpless-fail-bin" "$stable_tag" 2>&1) ||
1256
- fail "$interpreter_name help-suppressed setup failure must keep the install successful"
1257
- assert_contains "$helpless_fail_output" 'warning: Automatic PATH setup for bash failed' "$interpreter_name help suppression keeps the setup-failure warning"
1258
- assert_tail "$helpless_fail_output" $'To get started, run:\n\n '"$helpless_fail_install/composio login" "$interpreter_name help suppression keeps the recovery tail"
1259
-
1254
printf 'install scripts passed under %s\n' "$interpreter_name"
1255
done
1256