forked from zeromq/gitdown
-
Notifications
You must be signed in to change notification settings - Fork 3
/
selftest
executable file
·77 lines (63 loc) · 1.81 KB
/
selftest
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
#!/bin/sh
################################################################################
# tests by comparing genearted README.md from last commited README.md
function normalize {
grep -v 'This document was published on ' $1
}
function normalize_images {
grep -v 'This document was published on ' $1 | \
grep -v '<img src='
}
function chk_return {
if test "$1" = "0"; then
echo "ok"
else
echo "failed"
fi
}
################################################################################
compare=`mktemp`
output=`mktemp`
tmpfile=`mktemp`
# compare against last commit
git show HEAD^:README.md | normalize > $compare
# normal auto
echo "== normal auto =============="
cp README.md $tmpfile
bin/gitdown README.txt
normalize README.md > $output
diff -u $compare $output
normal_auto=`chk_return $?`
cp $tmpfile README.md
# normal file specified
echo "== normal file =============="
bin/gitdown README.txt $tmpfile
normalize $tmpfile > $output
diff -u $compare $output
normal_file=`chk_return $?`
# normal stdout
echo "== normal stdout ============"
bin/gitdown README.txt - | normalize > $output
diff -u $compare $output
normal_stdout=`chk_return $?`
# local auto
echo "== local auto ==============="
cp README.md $tmpfile
bin/gitdown --to-local README.txt
normalize_images README.md > $output
normalize_images $compare | diff -u - $output
local_auto=`chk_return $?`
cp $tmpfile README.md
# local stdout
echo "== local stdout ============="
bin/gitdown --to-local README.txt - | normalize_images > $output
normalize_images $compare | diff -u - $output
local_stdout=`chk_return $?`
echo
echo "Tests"
echo " normal auto.....$normal_auto"
echo " normal file.....$normal_file"
echo " normal stdout...$normal_stdout"
echo " local auto......$local_auto"
echo " local stdout....$local_stdout"
rm -f $compare $output $tmpfile