aboutsummaryrefslogtreecommitdiff
path: root/tests/signals.sh
blob: ad7ed2da1fe0dd53b06600c6be8a8b71864d7afc (plain) (blame)
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
29
#!/bin/sh
set -u

. tests/lib.sh

test_status_is_zero_when_command_is_successful() {
	printf 'a\n' | sh remembering -pp1 -c 'head -n1' 1>/dev/null 2>/dev/null
	STATUS=$?
	assert_status 0

	printf '' | sh remembering -pp2 -c 'exit 0' 1>/dev/null 2>/dev/null
	STATUS=$?
	assert_status 0

	seq 9 | sh remembering -pp3 -c 'grep 7' 1>/dev/null 2>/dev/null
	STATUS=$?
	assert_status 0
}

test_status_is_forwarded_from_command() {
	for status in $(seq 1 125); do
		printf '' | sh remembering -pp4 -c "exit $status" 1>/dev/null 2>/dev/null
		STATUS=$?
		assert_status "$status"
	done
}

test_status_is_zero_when_command_is_successful
test_status_is_forwarded_from_command