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}"
17 msg="${msg/$BP_DIR/\$BP_DIR}"
19 echo -n "Testing $msg ... "
20 eval $command > /dev/null 2>&1
23 # Function to run a given command (quiet).
28 eval $command > /dev/null 2>&1
31 # Function to assert no difference between
33 function assert_no_diff
38 if [ ! -f $src ]; then
44 if [ ! -f $dst ]; then
50 local diff=`diff -q $src $dst`
52 if [ "$diff" != "" ]; then
61 # Function to assert no difference between the content
62 # of two given direcories (recursive).
63 function assert_no_diff_dir
68 if [ ! -d $src_dir ]; then
74 if [ ! -d $dst_dir ]; then
80 local src_cksum=`find $src_dir -type f | grep -v "\.svn" | sort | xargs cat | cksum`
81 local dst_cksum=`find $dst_dir -type f | grep -v "\.svn" | sort | xargs cat | cksum`
83 if [ "$src_cksum" == "$dst_cksum" ]; then
92 # Function to assert that all given files do exists.
93 function assert_files_exists
98 if [ ! -f $arg ]; then
103 if [ $error = 1 ]; then
112 # Function to output a given message to the log file.
117 echo "$msg" >> $log_file
120 # Function that renders a given message in ASCII green.
125 echo -e "\033[32;38m$msg\033[0m"
128 # Function that renders a given message in ASCII yellow.
133 echo -e "\033[33;38m$msg\033[0m"
136 # Function that renders a given message in ASCII red.
141 echo -e "\033[31;38m$msg\033[0m"
144 # Function to clean the temporary file.
147 if [ -f "$tmp" ]; then
152 # Function to test if the required version of Perl is installed.
155 echo -n "Testing Perl version ... "
157 if error=$( perl -e 'use 5.8.0;' 2>&1 ); then
161 echo $error | sed "s/, stopped.*//"
167 # Function to test if a given Perl module is installed.
168 function test_perl_module
172 echo -n "Testing required Perl module - \"$module\": "
174 if ! error=$( perl -M$module -e '' 2>&1 > /dev/null ); then
176 echo " Try: perl -MCPAN -e 'install $module'"
184 # Function to test if the required version of Ruby is installed.
187 echo -n "Testing Ruby version ... "
189 if error=$( ruby -e 'raise "Ruby version 1.9 required--this is only #{RUBY_VERSION}" if RUBY_VERSION < "1.9"' 2>&1 ); then
193 echo $error | sed "s/.*: //"
199 # Function to test if a given Ruby gem is installed.
200 function test_ruby_gem
204 echo -n "Testing required Ruby gem - \"$gem\": "
206 if error=$( gem list --local | grep $gem ); then
211 echo " Try: gem install $gem"
216 # Function to test is a given auxillary program is in $PATH.
217 function test_aux_program
221 echo -n "Testing auxiliary program - \"$program\": "
223 if command -v $program >/dev/null; then
227 echo_yellow "WARNING"