]> git.donarmstrong.com Git - biopieces.git/blob - bp_test/lib/test.sh
added testing suite
[biopieces.git] / bp_test / lib / test.sh
1 #!/usr/bin/env sh
2
3 bp=`basename $0 | sed s/^test_//`
4 in="$BP_DIR/bp_test/in/$bp.in"
5 out="$BP_DIR/bp_test/out/$bp.out"
6 tmp="$BP_TMP/$bp.out"
7 log_file="$BP_TMP/test.log"
8
9 function run
10 {
11     local command=$1
12
13     echo -n "Testing $command ... "
14     eval $command > /dev/null 2>&1
15 }
16
17
18 function assert_no_diff
19 {
20     local src=$1
21     local dst=$2
22
23     local diff=`diff -q $src $dst`
24      
25     if [ "$diff" != "" ]; then
26         echo_red "FAIL"
27         echo "FAIL" >> $log_file
28     else     
29         echo_green "OK"
30         echo "OK" >> $log_file
31     fi     
32 }
33
34
35 function echo_green
36 {
37     local msg=$1
38
39     echo -e "\033[32;38m$msg\033[0m"
40 }
41
42 function echo_red
43 {
44     local msg=$1
45
46     echo -e "\033[31;38m$msg\033[0m"
47 }