-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
50 lines (38 loc) · 861 Bytes
/
test.sh
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
43
44
45
46
47
48
49
50
#!/bin/sh
#!/bin/bash
typeset -i tests=0
function describe {
let tests+=1
description="$1"
}
function assert {
if [[ "$1" == "$2" ]]; then
printf "\033[32m.\033[0m"
else
printf "\033[31m\nFAIL: $description\033[0m: '$1' != '$2'\n"
exit 1
fi
}
describe "Help"
./opener --help > /dev/null 2>&1
assert $? 0
describe "Help: short flag"
./opener -h > /dev/null 2>&1
assert $? 0
describe "Version"
./opener --version > /dev/null 2>&1
assert $? 0
describe "Version: short flag"
./opener -v > /dev/null 2>&1
assert $? 0
describe "No arguments"
./opener > /dev/null 2>&1
assert $? 1
describe "One argument"
./opener foo> /dev/null 2>&1
assert $? 0
describe "More than one argument"
./opener foo bar> /dev/null 2>&1
assert $? 1
printf "\033[32m\n(✓) Passed $tests assertions without errors\033[0m\n"
exit 0