-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
tests.bats
42 lines (35 loc) · 916 Bytes
/
tests.bats
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
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bats
@test "simple command invocation" {
rm resultfile 2> /dev/null || true
./build/multirun \
"sh -c \"echo test > resultfile\""
[ -e resultfile ]
result=$(cat resultfile)
[ "$result" = "test" ]
rm resultfile
}
@test "multiple commands invocation" {
rm resultfile1 2> /dev/null || true
rm resultfile2 2> /dev/null || true
./build/multirun \
"sh -c \"echo test > resultfile1; sleep 1\"" \
"sh -c \"echo test > resultfile2; sleep 1\""
[ -e resultfile1 ]
[ -e resultfile2 ]
result1=$(cat resultfile1)
[ "$result1" = "test" ]
result2=$(cat resultfile2)
[ "$result2" = "test" ]
rm resultfile1
rm resultfile2
}
@test "returns 0" {
run ./build/multirun "sh -c \"exit 0\""
[ "$status" -eq 0 ]
}
@test "returns -1" {
run ./build/multirun "sh -c \"exit -1\""
[ "$status" -eq 255 ]
run ./build/multirun "sh -c \"exit 1\""
[ "$status" -eq 255 ]
}