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/$USER.$bp.out"
7 tmp_dir="$BP_TMP/$USER.test_tmp"
8 log_file="$BP_TMP/$USER.test.log"
10 # Function to run a given command (verbose).
15 msg="${command/$BP_DIR/\$BP_DIR}"
16 msg="${msg//$BP_TMP/\$BP_TMP}"
18 echo -n "Testing $msg ... "
19 eval $command > /dev/null 2>&1
22 # Function to run a given command (quiet).
27 eval $command > /dev/null 2>&1
30 # Function to assert no difference between
32 function assert_no_diff
37 if [ ! -f $src ]; then
43 if [ ! -f $dst ]; then
49 local diff=`diff -q $src $dst`
51 if [ "$diff" != "" ]; then
60 # Function to assert no difference between the content
61 # of two given direcories (recursive).
62 function assert_no_diff_dir
67 if [ ! -d $src_dir ]; then
73 if [ ! -d $dst_dir ]; then
79 local src_cksum=`find $src_dir -type f | grep -v "\.svn" | sort | xargs cat | cksum`
80 local dst_cksum=`find $dst_dir -type f | grep -v "\.svn" | sort | xargs cat | cksum`
82 if [ "$src_cksum" == "$dst_cksum" ]; then
91 # Function to assert that all given files do exists.
92 function assert_files_exists
97 if [ ! -f $arg ]; then
102 if [ $error = 1 ]; then
111 # Function to output a given message to the log file.
116 echo "$msg" >> $log_file
119 # Function that renders a given message in ASCII green.
124 echo -e "\033[32;38m$msg\033[0m"
127 # Function that renders a given message in ASCII yellow.
132 echo -e "\033[33;38m$msg\033[0m"
135 # Function that renders a given message in ASCII red.
140 echo -e "\033[31;38m$msg\033[0m"
143 # Function to clean the temporary file.
146 if [ -f "$tmp" ]; then
151 # Function to test if the required version of Perl is installed.
154 echo -n "Testing Perl version ... "
156 if error=$( perl -e 'use 5.8.0;' 2>&1 ); then
160 echo $error | sed "s/, stopped.*//"
166 # Function to test if a given Perl module is installed.
167 function test_perl_module
171 echo -n "Testing required Perl module - \"$module\": "
173 if ! error=$( perl -M$module -e '' 2>&1 > /dev/null ); then
175 echo " Try: perl -MCPAN -e 'install $module'"
183 # Function to test if the required version of Ruby is installed.
186 echo -n "Testing Ruby version ... "
188 if error=$( ruby -e 'raise "Ruby version 1.9 required--this is only #{RUBY_VERSION}" if RUBY_VERSION < "1.9"' 2>&1 ); then
192 echo $error | sed "s/.*: //"
198 # Function to test if a given Ruby gem is installed.
199 function test_ruby_gem
203 echo -n "Testing required Ruby gem - \"$gem\": "
205 if error=$( gem list --local | grep $gem ); then
210 echo " Try: gem install $gem"
215 # Function to test is a given auxillary program is in $PATH.
216 function test_aux_program
220 echo -n "Testing auxiliary program - \"$program\": "
222 if command -v $program >/dev/null; then
226 echo_yellow "WARNING"