Check tmux version for truecolor test.

This commit is contained in:
John Hood
2017-11-04 12:24:17 -04:00
parent 96b5027d9e
commit 0ec85b508e
3 changed files with 47 additions and 37 deletions
+2 -37
View File
@@ -57,42 +57,6 @@ test_exitstatus()
} }
# Tmux check.
tmux_check()
{
# OpenBSD tmux does not have '-V'.
if [ "$(uname -s)" = "OpenBSD" ]; then
openbsd_major="$(uname -r)"
openbsd_major="${openbsd_major%%.*}"
if [ "${openbsd_major}" -ge 6 ]; then
return 0
fi
fi
version=$(tmux -V)
if [ $? != 0 ]; then
error "tmux unavailable\n"
return 1
fi
if [ "$version" = "tmux master" ]; then
return 0
fi
version=${version##tmux }
version_major=${version%%.*}
version_minor=${version##*.}
# need version 1.8 for capture-pane
if [ "$version_major" -lt 1 ] ||
{ [ "$version_major" -eq 1 ] && [ "$version_minor" -lt 8 ]; }; then
error "tmux version %s too old\n" "$version"
return 1
fi
# Finally, check that tmux actually works to some degree.
#
# Use a different socket name. On Cygwin, this tmux server is
# slow to exit, and the actual test tmux can attach to it, causing
# problems with missing environment variables.
tmux -f /dev/null -S "${tmux_socket}c" -C new-session true
}
ssh_localhost_check() ssh_localhost_check()
{ {
ssh localhost : ssh localhost :
@@ -169,7 +133,8 @@ fi
# XXX this ignores $TMPDIR, because it results in an overlong pathname on OS X # XXX this ignores $TMPDIR, because it results in an overlong pathname on OS X
tmux_socket="/tmp/.tmux-mosh-test-$$" tmux_socket="/tmp/.tmux-mosh-test-$$"
if ! tmux_check; then # need version 1.8 for capture-pane
if ! tmux_check 1 8; then
test_skipped "tmux unavailable\n" test_skipped "tmux unavailable\n"
fi fi
+38
View File
@@ -80,3 +80,41 @@ set_locale()
# Fail. # Fail.
return 1 return 1
} }
# Tmux check.
tmux_check()
{
need_major="$1"; shift
need_minor="$1"; shift
# OpenBSD tmux does not have '-V'.
if [ "$(uname -s)" = "OpenBSD" ]; then
openbsd_major="$(uname -r)"
openbsd_major="${openbsd_major%%.*}"
if [ "${openbsd_major}" -ge 6 ]; then
return 0
fi
fi
version=$(tmux -V)
if [ $? != 0 ]; then
error "tmux unavailable\n"
return 1
fi
if [ "$version" = "tmux master" ]; then
return 0
fi
version=${version##tmux }
version_major=${version%%.*}
version_minor=${version##*.}
if [ "$version_major" -lt "$need_major" ] ||
{ [ "$version_major" -eq "$need_major" ] && [ "$version_minor" -lt "$need_minor" ]; }; then
printf "tmux version %s too old\n" "$version" >&2
return 1
fi
# Finally, check that tmux actually works to some degree.
#
# Use a different socket name. On Cygwin, this tmux server is
# slow to exit, and the actual test tmux can attach to it, causing
# problems with missing environment variables.
tmux -f /dev/null -S "${tmux_socket}c" -C new-session true
}
+7
View File
@@ -14,6 +14,13 @@
# shellcheck source=e2e-test-subrs # shellcheck source=e2e-test-subrs
. "$(dirname "$0")/e2e-test-subrs" . "$(dirname "$0")/e2e-test-subrs"
PATH=$PATH:.:$srcdir PATH=$PATH:.:$srcdir
# Need 2.3 for true-color support (2.2 may work also)
if [ "$(basename "$0")" = emulation-attributes-truecolor.test ] &&
! tmux_check 2 3; then
printf "tmux does not support true color\n" >&2
exit 77
fi
# Top-level wrapper. # Top-level wrapper.
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
e2e-test "$0" baseline direct verify e2e-test "$0" baseline direct verify