]> git.donarmstrong.com Git - biopieces.git/blobdiff - bp_test/lib/test.sh
added tests for find_adaptor
[biopieces.git] / bp_test / lib / test.sh
index c58c531836b67939dabcc8d93e8a0d1ff923872a..68b83defc2beef6543b6ee6d2977c6ecd80ffb18 100755 (executable)
@@ -4,6 +4,7 @@ bp=`basename $0 | sed s/^test_//`
 in="$BP_DIR/bp_test/in/$bp.in"
 out="$BP_DIR/bp_test/out/$bp.out"
 tmp="$BP_TMP/$bp.out"
+tmp_dir="$BP_TMP/test_tmp"
 log_file="$BP_TMP/test.log"
 
 function run
@@ -14,23 +15,66 @@ function run
     eval $command > /dev/null 2>&1
 }
 
+function run_quiet
+{
+    local command=$1
+
+    eval $command > /dev/null 2>&1
+}
 
 function assert_no_diff
 {
     local src=$1
     local dst=$2
 
+    if [ ! -f $src ]; then
+        echo_red "FAIL"
+        log "FAIL"
+        return
+    fi
+
+    if [ ! -f $dst ]; then
+        echo_red "FAIL"
+        log "FAIL"
+        return
+    fi
+
     local diff=`diff -q $src $dst`
      
     if [ "$diff" != "" ]; then
         echo_red "FAIL"
-        echo "FAIL" >> $log_file
+        log "FAIL"
     else     
         echo_green "OK"
-        echo "OK" >> $log_file
+        log "OK"
     fi     
 }
 
+function assert_files_exists
+{
+    error=0
+
+    for arg in "$@"; do
+        if [ ! -f $arg ]; then
+            error=1
+        fi
+    done
+
+    if [ $error = 1 ]; then
+        echo_red "FAIL"
+        log "FAIL"
+    else
+        echo_green "OK"
+        log "OK"
+    fi
+}
+
+function log
+{
+    local msg=$1
+
+    echo "$msg" >> $log_file
+}
 
 function echo_green
 {
@@ -39,9 +83,49 @@ function echo_green
     echo -e "\033[32;38m$msg\033[0m"
 }
 
+function echo_yellow
+{
+    local msg=$1
+
+    echo -e "\033[33;38m$msg\033[0m"
+}
+
 function echo_red
 {
     local msg=$1
 
     echo -e "\033[31;38m$msg\033[0m"
 }
+
+function clean
+{
+    if [ -f "$tmp" ]; then
+        rm "$tmp"
+    fi
+}
+
+function test_perl
+{
+    echo -n "Testing Perl version ... "
+
+    if error=$( perl -e 'use 5.8.0;' 2>&1 ); then
+        echo_green "OK"
+    else
+        echo $error | sed "s/, stopped.*//"
+        echo_red "FAIL"
+        exit
+    fi  
+}
+
+function test_ruby
+{
+    echo -n "Testing Ruby version ... "
+
+    if error=$( ruby -e 'raise "Ruby version 1.9 reqauired--this is only #{RUBY_VERSION}" if RUBY_VERSION < "1.9"' 2>&1 ); then
+        echo_green "OK"
+    else
+        echo $error | sed "s/.*: //"
+        echo_red "FAIL"
+        exit
+    fi  
+}