summaryrefslogtreecommitdiff
path: root/t/lib-terminal.sh
blob: 6fc33db6c14ffaa25e8b086a563be5f7b3829949 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh

test_expect_success 'set up terminal for tests' '
	if test -t 1
	then
		>stdout_is_tty
	elif
		test_have_prereq PERL &&
		"$PERL_PATH" "$TEST_DIRECTORY"/test-terminal.perl \
			sh -c "test -t 1"
	then
		>test_terminal_works
	fi
'

if test -e stdout_is_tty
then
	test_terminal() { "$@"; }
	test_set_prereq TTY
elif test -e test_terminal_works
then
	test_terminal() {
		"$PERL_PATH" "$TEST_DIRECTORY"/test-terminal.perl "$@"
	}
	test_set_prereq TTY
else
	say "# no usable terminal, so skipping some tests"
fi