-
Notifications
You must be signed in to change notification settings - Fork 10
/
test.sh
executable file
·85 lines (59 loc) · 1008 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env bash
set -ex
LOGFILE=p-test-log
OUTPUT=p-test-output
rm -f $LOGFILE
function teardown
{
rm -f $LOGFILE $OUTPUT
}
function fail
{
echo "FAIL: $0: $1"
teardown
exit 1
}
function run
{
LOGFILE=$LOGFILE ./$1 > $OUTPUT 2>&1
}
function checkLog
{
grep "$1" $LOGFILE >/dev/null || fail "Cannot find "$1" in log"
}
run 'p start'
diff -u $OUTPUT - <<!
Pomodoro started
!
[ $? -eq 0 ] || fail
[ $(cat $LOGFILE | wc -l) -eq 1 ] || fail
run 'p start some stuff'
diff -u $OUTPUT - <<!
Last Pomodoro cancelled
Pomodoro started on "some stuff"
!
[ $? -eq 0 ] || fail
checkLog ",some stuff"
[ $(cat $LOGFILE | wc -l) -eq 1 ] || fail
run 'p i'
diff -u $OUTPUT - <<!
Interrupt recorded
!
[ $? -eq 0 ] || fail
checkLog ",',"
run 'p i'
diff -u $OUTPUT - <<!
Interrupt recorded
!
[ $? -eq 0 ] || fail
checkLog ",'',"
run 'p e'
diff -u $OUTPUT - <<!
Interrupt recorded
!
[ $? -eq 0 ] || fail
checkLog ",''-,"
run 'p log'
diff -u $OUTPUT $LOGFILE
[ $? -eq 0 ] || fail
teardown