/video-contact-sheet/branches/1.13/tests/GNUmakefile |
---|
1,25 → 1,37 |
# $Id$ |
VCS:=../vcs |
extract=sed -n "/$*()"'/,/^}$$/p' "$(VCS)" |
#VCS:=../portability/oldvcs/vcs-1.11.2 |
extract=sed -n "/^$*()"'/,/^}$$/p' "$(VCS)" |
TESTS_FILE=src/tests.txt |
TEST_MAKER=src/make_test.bash |
get_interval_reqs = $(addprefix inc/, \ |
$(addsuffix .func.bash,get_interval trace error \ |
is_number tolower assert awkexf fptest \ |
fsimeq) \ |
$(addsuffix .inc.bash,constants) \ |
) |
all: get_interval |
constants.inc.bash: |
sed -n '/{{{ # Constants/,/}}}/p' "$(VCS)" > $@ |
inc/constants.inc.bash: $(VCS) |
mkdir -p inc/ |
echo 'declare -r RELEASE=0' > $@ |
echo 'declare DEBUG=1' >> $@ |
echo '$(shell grep -m1 'VERSION=' "$(VCS)")' >> $@ |
sed -n '/{{{ # Constants/,/}}}/p' "$(VCS)" >> $@ |
get_interval: $(addsuffix .func.bash,get_interval trace error is_number tolower) \ |
$(addsuffix .inc.bash,constants) |
{ \ |
echo '#!/bin/bash' ; \ |
for req in $^; do \ |
echo "source $$req" ; \ |
done ; \ |
} |
%.func.bash: |
get_interval: $(TESTS_FILE) $(get_interval_reqs) |
$(TEST_MAKER) $@ $(get_interval_reqs) > $@.test.bash |
chmod +x $@.test.bash |
inc/%.func.bash: $(VCS) |
mkdir -p inc |
$(extract) >$@ |
clean: |
$(RM) *.func.bash *.inc.bash |
$(RM) inc/* *.test.bash |
-rmdir -p inc/ |
/video-contact-sheet/branches/1.13/tests/src/tests.txt |
---|
0,0 → 1,15 |
# $Id$ |
# Format: |
# test input [input ...] : expected_result |
# |
get_interval 1h : 3600 |
get_interval 1h1m : 3660 |
get_interval 1h1m1 : 3661 |
get_interval 1h1m1s : 3661 |
get_interval 1.22 : 1.22 |
get_interval 1s.22 : 1.22 |
get_interval .11.11.11 : 0.33 |
get_interval 1s.11.11 : 1.22 |
Property changes: |
Added: svn:keywords |
+Rev Id Date |
\ No newline at end of property |
/video-contact-sheet/branches/1.13/tests/src/make_test.bash |
---|
0,0 → 1,25 |
#!/bin/bash |
# This file can be used to generate a test script |
# The actual tests are contained in tests.txt |
testsfile=$(dirname "$0")/tests.txt |
TESTNAME=$1 |
shift |
REQS=$@ |
echo '#!/bin/bash' |
for req in $REQS; do |
echo "source $req" |
done |
echo "source src/unittest.bash" |
echo 'while read line ; do' |
echo ' unittest $line' |
echo 'done <<< "$(sed "/^[[:space:]]*#/d" "'$testsfile'" | grep "^'${TESTNAME}' ")"' |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
Added: svn:keywords |
+Rev Id Date |
\ No newline at end of property |
/video-contact-sheet/branches/1.13/tests/src/unittest.bash |
---|
0,0 → 1,32 |
# |
# $Id$ |
# Receives the raw input as found in tests.txt |
# |
TESTNUM=0 |
G=$(tput setaf 2 ; tput bold ) |
R=$(tput setaf 1 ; tput bold) |
CLR=$(tput sgr0) |
set +e |
function unittest { |
let 'TESTNUM++' |
a="$@" |
fn=$(cut -d' ' -f1 <<<"$a") |
if [[ $TESTNUM -eq 1 ]]; then |
type $fn |
fi |
args=$(cut -d' ' -f2- <<<"$a" | sed 's/:.*$//' | sed 's/ *$//') |
expected=$(cut -d' ' -f2- <<<"$a" | sed 's/.*://') |
echo "$fn($args) -> $expected" >&2 |
ret=$($fn $args) |
if [[ $ret != $expected ]] && ! fptest "$ret" ~ "$expected" ; then |
echo -n "${R}FAILED => $ret != '$expected'" |
else |
echo -n "${G}PASSED => $ret ~= $expected" |
fi |
echo $CLR |
} |
Property changes: |
Added: svn:keywords |
+Rev Id Date |
\ No newline at end of property |