-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.sh
executable file
·71 lines (55 loc) · 1.53 KB
/
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
#!/bin/bash
cd test
# Set mdv to use the same theme... otherwise it picks a random one
export MDV_THEME=729.8953
function run_test {
cmp <($2) <($3)
if [ $? -ne 0 ]
then
echo "Missmatch when running test $1:"
echo
echo "Command 1 [$2] output:"
$2
echo
echo "Command 2 [$3] output:"
$3
exit 1
fi
}
function run_test_prepost {
$4
cmp <($2) <($3)
if [ $? -ne 0 ]
then
echo "Missmatch when running test $1:"
echo
echo "Command 1 [$2] output:"
$2
echo
echo "Command 2 [$3] output:"
$3
$5
exit 1
fi
$5
}
run_test "markdown" "./mog -nf README.md" "pygmentize README.md"
run_test "pygments extension" "./mog -n helloworld.py" "pygmentize -l python helloworld.py"
run_test "pygments mime" "./mog -n helloworld" "pygmentize -l python helloworld"
if [ `uname` != 'Darwin' ]
then
run_test "elf" "./mog -n /bin/cat" "objdump -ft /bin/cat"
fi
if [ `uname` == 'Darwin' ]
then
run_test "filesystem" "./mog -n mog.gif" "ls -lh mog.gif"
else
run_test "filesystem" "./mog -n mog.gif" "ls -lh mog.gif --color=always"
fi
run_test "image" "./mog -nf mog.gif" "mediainfo `python -c 'import os,sys;print(os.path.realpath(sys.argv[1]))' mog.gif`"
run_test_prepost "tar" "./mog -n foo.tar" "tar --list -f foo.tar" "tar cf foo.tar hello*" "rm foo.tar"
run_test "csv" "./mog -n data.csv" "column -xt -s, data.csv"
run_test "tsv" "./mog -n data.tsv" "column -xt data.tsv"
run_test "ascii" "./mog -n hello" "cat hello"
run_test_prepost "binary" "./mog -n foo" "xxd foo" "bash ./create_binary.sh" "rm foo"
echo "All tests passed"