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
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
{
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
+}