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() {
|
||||
local session=""
|
||||
local command=""
|
||||
local -a command_parts=()
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--session)
|
||||
|
|
@ -171,17 +171,22 @@ mcc-cmd() {
|
|||
shift
|
||||
;;
|
||||
*)
|
||||
command="$1"
|
||||
command_parts+=("$1")
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
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")"
|
||||
local input_file
|
||||
input_file="$(_mcc_session_input_file "$session")"
|
||||
mkdir -p "$(dirname "$input_file")"
|
||||
local command
|
||||
command="${command_parts[*]}"
|
||||
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; }
|
||||
|
|
|
|||
|
|
@ -80,16 +80,23 @@ input_file="$(_mcc_session_input_file "$session")"
|
|||
rm -rf "$(_mcc_session_root "$session")"
|
||||
|
||||
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"
|
||||
[[ ! -e "$(_mcc_session_root "$session")" ]]
|
||||
malformed_log="${TMPDIR:-/tmp}/mcc-env-session-hang-test.log"
|
||||
if mcc-cmd --session >"$malformed_log" 2>&1; then
|
||||
echo "FAIL: --session accepted without value" >&2
|
||||
cat "$malformed_log" >&2
|
||||
exit 1
|
||||
fi
|
||||
grep -Fq -- "--session requires a value" "$malformed_log"
|
||||
for func in mcc-cmd mcc-reset-session mcc-state mcc-log-mcc; do
|
||||
set +e
|
||||
"$func" --session >"$malformed_log" 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue