Skip to content

Commit

Permalink
* update run_tests.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
brainpower committed Jun 1, 2014
1 parent 73051be commit 6af226d
Showing 1 changed file with 74 additions and 14 deletions.
88 changes: 74 additions & 14 deletions cpp/tests/run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,76 @@
#!/bin/sh
script_dir="$(dirname $(readlink -f "${0}"))"

printf " * Testing --help ... "
if tests/test_args --help >/dev/null; then
printf "[ok]\n"
else
printf "[fail]\n"
fi

printf " * Testing missing value return code ... "
tests/test_args -i 2>/dev/null
if [ $? = 4 ]; then
printf "[ok]\n"
else
printf "[fail]\n"
fi
compile_sources(){
compile_$type
}

compile_cpp(){
g++ -std=c++11 "${sources[@]}" -o $name
}

clean(){
rm -f *.o
rm -f "$name"
}

test_rc(){
local tname="$1"
local expect="$2"
shift 2;

printf " - Running test: ${tname}... "
./$name "$@" >/dev/null

if [[ $expect == $? ]]; then
printf "[ ok ]\n"
else
printf "[ failed ]\n"
fi

}

test_stdout(){
local tname="$1"
local expect="$2"
shift 2
local tmpout="${name}.${tname// /_}.out"

printf " - Running test: ${tname}... "
./$name "$@" > "$tmpout"

if diff -Nru $expect "$tmpout"; then
printf "[ ok ]\n"
else
printf "[ failed ]\n"
fi
rm -f "$tmpout"
}

cd "${script_dir}"
for test in *.bpt; do
if [ -x "$test" ]; then
(
. ./"$test"
printf "\n * Running test set ${name}...\n"
prepare
run
clean
)
fi
done

#printf " * Testing --help ... "
#if tests/test_args --help >/dev/null; then
# printf "[ok]\n"
#else
# printf "[fail]\n"
#fi

#printf " * Testing missing value return code ... "
#tests/test_args -i 2>/dev/null
#if [ $? = 4 ]; then
# printf "[ok]\n"
#else
# printf "[fail]\n"
#fi

0 comments on commit 6af226d

Please sign in to comment.