diff options
author | mescalinum <mescalinum@users.sourceforge.net> | 2011-11-17 10:36:08 +0000 |
---|---|---|
committer | mescalinum <mescalinum@users.sourceforge.net> | 2011-11-17 10:36:08 +0000 |
commit | 6e70f33a440fe6c7420c7406af83981be8691ef7 (patch) | |
tree | e31f6c13601a3ad71c95e5977729a767e5b71b3e | |
parent | 74ec984c0b4c7b009d103f1e7169a8c862d78ccb (diff) |
minimal test system. more testcases to come.
svn path=/trunk/externals/loaders/tclpd/; revision=15783
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | tests/Makefile | 9 | ||||
-rw-r--r-- | tests/_test_template.pd | 22 | ||||
-rw-r--r-- | tests/basic_output.pd | 20 | ||||
-rw-r--r-- | tests/basic_output.ref | 3 | ||||
-rw-r--r-- | tests/basic_output_helper.tcl | 22 | ||||
-rw-r--r-- | tests/helloworld.pd | 10 | ||||
-rw-r--r-- | tests/helloworld.ref | 1 | ||||
-rw-r--r-- | tests/runtest.pd.in | 17 | ||||
-rw-r--r-- | tests/runtest.sh | 36 |
10 files changed, 144 insertions, 0 deletions
@@ -287,6 +287,9 @@ $(LIBRARY_NAME): $(SOURCES:.c=.o) $(LIBRARY_NAME).o tcl_wrap.o $(TCLPD_SOURCES:. $(SHARED_LIB): $(SHARED_SOURCE:.c=.o) $(CC) $(SHARED_LDFLAGS) -o $(SHARED_LIB) $(SHARED_SOURCE:.c=.o) $(LIBS) +test: + make -C tests + install: single_install # The meta and help files are explicitly installed to make sure they are @@ -352,6 +355,7 @@ clean: -rm -f -- $(LIBRARY_NAME).o -rm -f -- $(LIBRARY_NAME).$(EXTENSION) -rm -f -- $(SHARED_LIB) + make -C tests clean distclean: clean -rm -f -- $(DISTBINDIR).tar.gz diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..c9f94e8 --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,9 @@ +all: + # check that test-system itself is functional + # TODO: check that this check is functional? :-D + sh runtest.sh helloworld + # basic output test + sh runtest.sh basic_output + +clean: + rm -fv *.out runtest-*.pd diff --git a/tests/_test_template.pd b/tests/_test_template.pd new file mode 100644 index 0000000..6ee49ad --- /dev/null +++ b/tests/_test_template.pd @@ -0,0 +1,22 @@ +#N canvas 237 169 450 300 10;
+#X obj 46 102 inlet;
+#X obj 46 236 outlet;
+#X obj 115 170 outlet;
+#X text 31 22 this is the template for a test;
+#X text 31 63 inlet 0 receives bang on load;
+#X text 160 119 send output to outlet 0 \; bang outlet 1 when test
+is complete;
+#N canvas 0 0 450 300 bang_swap 0;
+#X obj 63 58 inlet;
+#X obj 63 112 t b b;
+#X obj 112 172 outlet;
+#X obj 63 172 outlet;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 1 1 3 0;
+#X restore 46 139 pd bang_swap;
+#X msg 46 202 first output \, second output;
+#X connect 0 0 6 0;
+#X connect 6 0 7 0;
+#X connect 6 1 2 0;
+#X connect 7 0 1 0;
diff --git a/tests/basic_output.pd b/tests/basic_output.pd new file mode 100644 index 0000000..d1daaae --- /dev/null +++ b/tests/basic_output.pd @@ -0,0 +1,20 @@ +#N canvas 306 152 450 300 10;
+#X obj 48 53 inlet;
+#X obj 48 234 outlet;
+#X obj 48 187 basic_output_helper;
+#X msg 48 144 symbol float \, symbol symbol \, symbol list;
+#N canvas 0 0 450 300 bang_swap 0;
+#X obj 63 58 inlet;
+#X obj 63 112 t b b;
+#X obj 112 172 outlet;
+#X obj 63 172 outlet;
+#X connect 0 0 1 0;
+#X connect 1 0 2 0;
+#X connect 1 1 3 0;
+#X restore 48 89 pd bang_swap;
+#X obj 117 115 outlet;
+#X connect 0 0 4 0;
+#X connect 2 0 1 0;
+#X connect 3 0 2 0;
+#X connect 4 0 3 0;
+#X connect 4 1 5 0;
diff --git a/tests/basic_output.ref b/tests/basic_output.ref new file mode 100644 index 0000000..15e9b99 --- /dev/null +++ b/tests/basic_output.ref @@ -0,0 +1,3 @@ +123;
+baz;
+foo 123 bar;
diff --git a/tests/basic_output_helper.tcl b/tests/basic_output_helper.tcl new file mode 100644 index 0000000..c557778 --- /dev/null +++ b/tests/basic_output_helper.tcl @@ -0,0 +1,22 @@ +package require Tclpd 0.3.0 +package require TclpdLib 0.20 + +proc basic_output_helper::constructor {self args} { + pd::add_outlet $self list +} + +proc basic_output_helper::0_symbol {self args} { + switch -exact -- [pd::arg 0 symbol] { + float { + pd::outlet $self 0 float 123 + } + symbol { + pd::outlet $self 0 symbol baz + } + list { + pd::outlet $self 0 list {{symbol foo} {float 123} {symbol bar}} + } + } +} + +pd::class basic_output_helper diff --git a/tests/helloworld.pd b/tests/helloworld.pd new file mode 100644 index 0000000..453597a --- /dev/null +++ b/tests/helloworld.pd @@ -0,0 +1,10 @@ +#N canvas 0 0 450 300 10;
+#X obj 42 54 inlet;
+#X obj 45 179 outlet;
+#X msg 69 115 hello world;
+#X obj 42 86 t b b;
+#X obj 91 179 outlet;
+#X connect 0 0 3 0;
+#X connect 2 0 1 0;
+#X connect 3 0 4 0;
+#X connect 3 1 2 0;
diff --git a/tests/helloworld.ref b/tests/helloworld.ref new file mode 100644 index 0000000..e84e625 --- /dev/null +++ b/tests/helloworld.ref @@ -0,0 +1 @@ +hello world; diff --git a/tests/runtest.pd.in b/tests/runtest.pd.in new file mode 100644 index 0000000..308b934 --- /dev/null +++ b/tests/runtest.pd.in @@ -0,0 +1,17 @@ +#N canvas 0 0 473 353 10;
+#X obj 188 235 textfile;
+#X obj 37 124 list prepend add;
+#X obj 37 150 list trim;
+#X msg 188 196 write %OUTPUT%;
+#X msg 161 274 \; pd quit;
+#X obj 37 37 loadbang;
+#X obj 37 63 %TESTCASE%;
+#X obj 161 124 t b b;
+#X connect 1 0 2 0;
+#X connect 2 0 0 0;
+#X connect 3 0 0 0;
+#X connect 5 0 6 0;
+#X connect 6 0 1 0;
+#X connect 6 1 7 0;
+#X connect 7 0 4 0;
+#X connect 7 1 3 0;
diff --git a/tests/runtest.sh b/tests/runtest.sh new file mode 100644 index 0000000..8998b21 --- /dev/null +++ b/tests/runtest.sh @@ -0,0 +1,36 @@ +if [ -z "$1" ]; then + # no argument - run all tests found in current dir + set -e + for i in *.ref; do sh $0 "${i/.ref/}"; done + exit 0 +fi +KEEP_OUTPUT=0 +if [ "x$1" = "x-k" ]; then + KEEP_OUTPUT=1 + shift +fi +if [ ! -f "$1.pd" ]; then + echo -e "error: $1.pd does not exist" 1>&2 + exit 1 +fi +if [ ! -f "$1.ref" ]; then + echo -e "error: $1.ref does not exist" 1>&2 + exit 1 +fi +sed -e "s|%TESTCASE%|$1|" -e "s|%OUTPUT%|$1.out|" runtest.pd.in > "runtest-$1.pd" || exit 1 +echo -n "Running test '$1'... "; +"$PD_PATH/bin/pd" -noprefs -nogui -path .. -lib tclpd "runtest-$1.pd" +diff --strip-trailing-cr "$1.ref" "$1.out" 1>/dev/null 2>&1 +RESULT=$? +if [ $RESULT -eq 0 ]; then + echo "OK" +else + echo "FAIL" + # show differences: + diff -u --strip-trailing-cr "$1.ref" "$1.out" +fi +rm -f "runtest-$1.pd" +if [ $KEEP_OUTPUT -eq 0 ]; then + rm -f "$1.out" +fi +exit $RESULT |