mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Preserve full command in mcc-cmd and broaden tests
This commit is contained in:
parent
1be001bdf8
commit
e03b7de959
2 changed files with 22 additions and 10 deletions
|
|
@ -158,7 +158,7 @@ mcc-run() {
|
||||||
}
|
}
|
||||||
mcc-cmd() {
|
mcc-cmd() {
|
||||||
local session=""
|
local session=""
|
||||||
local command=""
|
local -a command_parts=()
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--session)
|
--session)
|
||||||
|
|
@ -171,17 +171,22 @@ mcc-cmd() {
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
command="$1"
|
command_parts+=("$1")
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
[[ -n "$command" ]] || { echo "Usage: mcc-cmd [--session NAME] <command>" >&2; return 1; }
|
if [[ ${#command_parts[@]} -eq 0 ]]; then
|
||||||
|
echo "Usage: mcc-cmd [--session NAME] <command>" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
session="$(_mcc_resolve_session "$session")"
|
session="$(_mcc_resolve_session "$session")"
|
||||||
local input_file
|
local input_file
|
||||||
input_file="$(_mcc_session_input_file "$session")"
|
input_file="$(_mcc_session_input_file "$session")"
|
||||||
mkdir -p "$(dirname "$input_file")"
|
mkdir -p "$(dirname "$input_file")"
|
||||||
|
local command
|
||||||
|
command="${command_parts[*]}"
|
||||||
printf '%s\n' "$command" >> "$input_file"
|
printf '%s\n' "$command" >> "$input_file"
|
||||||
}
|
}
|
||||||
mcc-kill() { pkill -f "MinecraftClient" 2>/dev/null && echo "MCC killed" || echo "No MCC process found"; tmux kill-session -t mcc-debug 2>/dev/null || true; }
|
mcc-kill() { pkill -f "MinecraftClient" 2>/dev/null && echo "MCC killed" || echo "No MCC process found"; tmux kill-session -t mcc-debug 2>/dev/null || true; }
|
||||||
|
|
|
||||||
|
|
@ -80,16 +80,23 @@ input_file="$(_mcc_session_input_file "$session")"
|
||||||
rm -rf "$(_mcc_session_root "$session")"
|
rm -rf "$(_mcc_session_root "$session")"
|
||||||
|
|
||||||
mcc-cmd --session "$session" "debug state"
|
mcc-cmd --session "$session" "debug state"
|
||||||
grep -Fq "debug state" "$input_file"
|
input_contents="$(cat "$input_file")"
|
||||||
|
assert_eq "debug state" "$input_contents" "session input command is intact"
|
||||||
|
|
||||||
mcc-reset-session --session "$session"
|
mcc-reset-session --session "$session"
|
||||||
[[ ! -e "$(_mcc_session_root "$session")" ]]
|
[[ ! -e "$(_mcc_session_root "$session")" ]]
|
||||||
malformed_log="${TMPDIR:-/tmp}/mcc-env-session-hang-test.log"
|
malformed_log="${TMPDIR:-/tmp}/mcc-env-session-hang-test.log"
|
||||||
if mcc-cmd --session >"$malformed_log" 2>&1; then
|
for func in mcc-cmd mcc-reset-session mcc-state mcc-log-mcc; do
|
||||||
echo "FAIL: --session accepted without value" >&2
|
set +e
|
||||||
cat "$malformed_log" >&2
|
"$func" --session >"$malformed_log" 2>&1
|
||||||
exit 1
|
status=$?
|
||||||
fi
|
set -e
|
||||||
grep -Fq -- "--session requires a value" "$malformed_log"
|
if [[ $status -eq 0 ]]; then
|
||||||
|
echo "FAIL: $func accepted --session without a value" >&2
|
||||||
|
cat "$malformed_log" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
grep -Fq -- "--session requires a value" "$malformed_log"
|
||||||
|
done
|
||||||
|
|
||||||
echo "PASS"
|
echo "PASS"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue