]> git.donarmstrong.com Git - biopieces.git/commitdiff
added assert_no_diff_dir function to test code
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 12 Oct 2011 14:05:17 +0000 (14:05 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Wed, 12 Oct 2011 14:05:17 +0000 (14:05 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1544 74ccb610-7750-0410-82ae-013aeee3265d

bp_test/lib/test.sh

index 68b7d9e539a9a5c51ac719f871ed6042f10f05ed..530c7a4dd1cae809e7f5bfaf1694649ebf8d00f6 100755 (executable)
@@ -7,6 +7,7 @@ tmp="$BP_TMP/$bp.out"
 tmp_dir="$BP_TMP/test_tmp"
 log_file="$BP_TMP/$USER.test.log"
 
+# Function to run a given command (verbose).
 function run
 {
     local command=$1
@@ -18,6 +19,7 @@ function run
     eval $command > /dev/null 2>&1
 }
 
+# Function to run a given command (quiet).
 function run_quiet
 {
     local command=$1
@@ -25,6 +27,8 @@ function run_quiet
     eval $command > /dev/null 2>&1
 }
 
+# Function to assert no difference between
+# two given files.
 function assert_no_diff
 {
     local src=$1
@@ -53,6 +57,26 @@ function assert_no_diff
     fi     
 }
 
+# Function to assert no difference between the content
+# of two given direcories (recursive).
+function assert_no_diff_dir
+{
+    local src_dir=$1
+    local dst_dir=$2
+
+    src_cksum=`find $src_dir -type f | xargs cat | cksum`
+    dst_cksum=`find $dst_dir -type f | xargs cat | cksum`
+
+    if [ "$src_cksum" == "$dst_cksum" ]; then
+        echo_green "OK"
+        log "OK"
+    else
+        echo_red "FAIL"
+        log "FAIL"
+    fi
+}
+
+# Function to assert that all given files do exists.
 function assert_files_exists
 {
     error=0
@@ -72,6 +96,7 @@ function assert_files_exists
     fi
 }
 
+# Function to output a given message to the log file.
 function log
 {
     local msg=$1
@@ -79,6 +104,7 @@ function log
     echo "$msg" >> $log_file
 }
 
+# Function that renders a given message in ASCII green.
 function echo_green
 {
     local msg=$1
@@ -86,6 +112,7 @@ function echo_green
     echo -e "\033[32;38m$msg\033[0m"
 }
 
+# Function that renders a given message in ASCII yellow.
 function echo_yellow
 {
     local msg=$1
@@ -93,6 +120,7 @@ function echo_yellow
     echo -e "\033[33;38m$msg\033[0m"
 }
 
+# Function that renders a given message in ASCII red.
 function echo_red
 {
     local msg=$1
@@ -100,6 +128,7 @@ function echo_red
     echo -e "\033[31;38m$msg\033[0m"
 }
 
+# Function to clean the temporary file.
 function clean
 {
     if [ -f "$tmp" ]; then
@@ -107,6 +136,7 @@ function clean
     fi
 }
 
+# Function to test if the required version of Perl is installed.
 function test_perl
 {
     echo -n "Testing Perl version ... "
@@ -121,6 +151,7 @@ function test_perl
     fi  
 }
 
+# Function to test if a given Perl module is installed.
 function test_perl_module
 {
     local module=$1
@@ -137,6 +168,7 @@ function test_perl_module
     fi
 }
 
+# Function to test if the required version of Ruby is installed.
 function test_ruby
 {
     echo -n "Testing Ruby version ... "
@@ -151,6 +183,7 @@ function test_ruby
     fi  
 }
 
+# Function to test if a given Ruby gem is installed.
 function test_ruby_gem
 {
     local gem=$1
@@ -167,6 +200,7 @@ function test_ruby_gem
     fi
 }
 
+# Function to test is a given auxillary program is in $PATH.
 function test_aux_program
 {
     local program=$1