mirror of
https://github.com/tmux/tmux.git
synced 2026-10-11 13:04:22 +00:00
Tests for 5602 and for run-shell -c.
This commit is contained in:
53
regress/codepoint-widths.sh
Normal file
53
regress/codepoint-widths.sh
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Width cache ranges must include their endpoint without overflowing wchar_t.
|
||||||
|
|
||||||
|
PATH=/bin:/usr/bin
|
||||||
|
TERM=screen
|
||||||
|
|
||||||
|
[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux)
|
||||||
|
TMUX="$TEST_TMUX -LtestA$$ -f/dev/null"
|
||||||
|
SERVER=
|
||||||
|
WATCHDOG=
|
||||||
|
|
||||||
|
cleanup()
|
||||||
|
{
|
||||||
|
if [ -n "$WATCHDOG" ]; then
|
||||||
|
kill "$WATCHDOG" 2>/dev/null
|
||||||
|
wait "$WATCHDOG" 2>/dev/null
|
||||||
|
fi
|
||||||
|
[ -n "$SERVER" ] && kill -9 "$SERVER" 2>/dev/null
|
||||||
|
}
|
||||||
|
trap cleanup 0
|
||||||
|
trap 'exit 1' 1 2 15
|
||||||
|
|
||||||
|
$TMUX new-session -d 'exec sleep 60' || exit 1
|
||||||
|
SERVER=$($TMUX display-message -p '#{pid}') || exit 1
|
||||||
|
|
||||||
|
# kill-server cannot stop a server stuck rebuilding the width cache.
|
||||||
|
(
|
||||||
|
sleep 5
|
||||||
|
kill -9 "$SERVER" 2>/dev/null
|
||||||
|
) &
|
||||||
|
WATCHDOG=$!
|
||||||
|
|
||||||
|
$TMUX set -g codepoint-widths 'U+1F600=2' || exit 1
|
||||||
|
|
||||||
|
# Cover both signed and unsigned 32-bit wchar_t. Values above WCHAR_MAX
|
||||||
|
# are ignored by the parser on platforms where they cannot be represented.
|
||||||
|
for value in U+7FFFFFFF=1 U+7FFFFFFE-U+7FFFFFFF=2 \
|
||||||
|
U+FFFFFFFF=1 U+FFFFFFFE-U+FFFFFFFF=2; do
|
||||||
|
$TMUX set -g codepoint-widths "$value" || exit 1
|
||||||
|
[ "$($TMUX display-message -p alive)" = alive ] || exit 1
|
||||||
|
done
|
||||||
|
|
||||||
|
# Check that an ordinary range still includes both endpoints and stops there.
|
||||||
|
$TMUX set -g codepoint-widths 'U+03B1-U+03B3=2' || exit 1
|
||||||
|
$TMUX set -g @text 'αβγδ' || exit 1
|
||||||
|
[ "$($TMUX display-message -p '#{w:@text}')" = 7 ] || exit 1
|
||||||
|
$TMUX set -gu codepoint-widths || exit 1
|
||||||
|
[ "$($TMUX display-message -p '#{w:@text}')" = 4 ] || exit 1
|
||||||
|
|
||||||
|
$TMUX kill-server || exit 1
|
||||||
|
SERVER=
|
||||||
|
exit 0
|
||||||
43
regress/run-shell-cwd.sh
Normal file
43
regress/run-shell-cwd.sh
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# run-shell -c should expand formats using the target pane.
|
||||||
|
|
||||||
|
PATH=/bin:/usr/bin
|
||||||
|
TERM=screen
|
||||||
|
|
||||||
|
[ -z "$TEST_TMUX" ] && TEST_TMUX=$(readlink -f ../tmux)
|
||||||
|
TMUX="$TEST_TMUX -LtestA$$ -f/dev/null"
|
||||||
|
|
||||||
|
TMP=$(mktemp -d)
|
||||||
|
trap '$TMUX kill-server 2>/dev/null; rm -rf "$TMP"' 0 1 15
|
||||||
|
TMP=$(cd "$TMP" && pwd -P)
|
||||||
|
mkdir "$TMP/first" "$TMP/second dir" || exit 1
|
||||||
|
|
||||||
|
check_directory()
|
||||||
|
{
|
||||||
|
actual=$(cat "$TMP/out")
|
||||||
|
if [ "$actual" != "$1" ]; then
|
||||||
|
echo "Expected directory '$1', got '$actual'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Expand the current pane's directory in the same command queue as creation.
|
||||||
|
$TMUX new-session -d -s test -c "$TMP/first" 'sleep 60' \; \
|
||||||
|
run-shell -c '#{pane_current_path}' "pwd >'$TMP/out'" || exit 1
|
||||||
|
check_directory "$TMP/first"
|
||||||
|
|
||||||
|
# An explicit target must supply the format context, including with a delay.
|
||||||
|
pane=$($TMUX new-window -d -P -F '#{pane_id}' -t test \
|
||||||
|
-c "$TMP/second dir" 'sleep 60') || exit 1
|
||||||
|
$TMUX run-shell -t "$pane" -d 0.1 -c '#{pane_current_path}' \
|
||||||
|
"pwd >'$TMP/out'" || exit 1
|
||||||
|
check_directory "$TMP/second dir"
|
||||||
|
|
||||||
|
# Literal directories and the default client directory still work.
|
||||||
|
$TMUX run-shell -c "$TMP/second dir" "pwd >'$TMP/out'" || exit 1
|
||||||
|
check_directory "$TMP/second dir"
|
||||||
|
(cd "$TMP/first" && $TMUX run-shell "pwd >'$TMP/out'") || exit 1
|
||||||
|
check_directory "$TMP/first"
|
||||||
|
|
||||||
|
exit 0
|
||||||
Reference in New Issue
Block a user