-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
50 lines (38 loc) · 874 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"
./os --help > /dev/null 2>&1
assert $? 1
describe "Help: short flag"
./os -h > /dev/null 2>&1
assert $? 1
describe "Version"
./os --version > /dev/null 2>&1
assert $? 0
describe "Version: short flag"
./os -v > /dev/null 2>&1
assert $? 0
describe "Execute: more than two arguments"
./os foo bar baz > /dev/null 2>&1
assert $? 1
describe "Execute: no arguments"
./os > /dev/null 2>&1
assert $? 0
describe "Execute: one argumet or flag"
./os foo > /dev/null 2>&1
assert $? 1
printf "\033[32m\n(✓) Passed $tests assertions without errors\033[0m\n"
exit 0