Include test machinery in the new build system.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 19 Aug 2015 16:47:15 +0000 (17:47 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 19 Aug 2015 16:47:15 +0000 (17:47 +0100)
Makefile.am
configure.ac
src/parser/parser-test.lisp
src/sod-test.asd
src/sod.asd
test/Makefile.am [new file with mode: 0644]
test/chimaera.ref [new file with mode: 0644]

index 55757e0..515031e 100644 (file)
@@ -36,4 +36,7 @@ SUBDIRS                       += src
 ## The runtime support library.
 SUBDIRS                        += lib
 
+## The tests and examples.
+SUBDIRS                        += test
+
 ###----- That's all, folks --------------------------------------------------
index 264bef2..cb1c5a6 100644 (file)
@@ -79,7 +79,7 @@ AC_SUBST([lispsysdir], [$with_lisp_system_dir])
 dnl--------------------------------------------------------------------------
 dnl Output.
 
-AC_CONFIG_FILES([Makefile src/Makefile lib/Makefile])
+AC_CONFIG_FILES([Makefile src/Makefile lib/Makefile test/Makefile])
 AC_OUTPUT
 
 dnl----- That's all, folks --------------------------------------------------
index 6718d5c..1fb292d 100644 (file)
 ;;;--------------------------------------------------------------------------
 ;;; Test expression parser.
 
-(defparse token (:context (context character-parser-context) parser)
-  (with-gensyms (value)
-    (expand-parser-spec context
-                       `(seq ((,value ,parser) :whitespace) ,value))))
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defparse token (:context (context character-parser-context) parser)
+    (with-gensyms (value)
+      (expand-parser-spec context
+                         `(seq ((,value ,parser) :whitespace) ,value)))))
 
 (let ((add (binop "+" (x y 5) `(+ ,x ,y)))
       (sub (binop "-" (x y 5) `(- ,x ,y)))
index 38b5095..a0a3972 100644 (file)
 ;;; Testing.
 
 (defmethod perform ((op test-op) (system (eql (find-system "sod-test"))))
-  (operate 'load-op system)
-  (funcall (find-symbol "RUN-TESTS" "SOD-TEST")))
-
-;;;--------------------------------------------------------------------------
-;;; Hacks.
-
-(defmethod perform :around
-    ((op compile-op) (component (eql (find-system "sod-test"))))
-  (let ((*compile-file-failure-behaviour* :warn))
-    (call-next-method)))
+  (handler-bind (((or warning style-warning)
+                 (lambda (cond)
+                   (declare (ignore cond))
+                   (invoke-restart 'muffle-warning))))
+    (operate 'load-op system)
+    (funcall (find-symbol "RUN-TESTS" "SOD-TEST"))))
 
 ;;;----- That's all, folks --------------------------------------------------
index af2cd64..a618e39 100644 (file)
 
 (defmethod perform ((op test-op) (component (eql (find-system "sod"))))
   (declare (ignore op component))
-  (operate 'test-op "sod-test" :force t))
+  (handler-bind (((or warning style-warning)
+                 (lambda (cond)
+                   (declare (ignore cond))
+                   (invoke-restart 'muffle-warning))))
+    (operate 'test-op "sod-test")))
 
 ;;;----- That's all, folks --------------------------------------------------
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644 (file)
index 0000000..300ad69
--- /dev/null
@@ -0,0 +1,43 @@
+### -*-makefile-*-
+###
+### Build script for SOD examples and tests
+###
+### (c) 2015 Straylight/Edgeware
+###
+
+###----- Licensing notice ---------------------------------------------------
+###
+### This file is part of the Sensble Object Design, an object system for C.
+###
+### SOD is free software; you can redistribute it and/or modify
+### it under the terms of the GNU General Public License as published by
+### the Free Software Foundation; either version 2 of the License, or
+### (at your option) any later version.
+###
+### SOD is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+### GNU General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with SOD; if not, write to the Free Software Foundation,
+### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+include        $(top_srcdir)/vars.am
+
+###--------------------------------------------------------------------------
+### The silly Chimaera example.
+
+check_PROGRAMS         += chimaera
+
+EXTRA_DIST             += chimaera.sod
+nodist_chimaera_SOURCES         = chimaera.c chimaera.h
+BUILT_SOURCES          += $(nodist_chimaera_SOURCES)
+
+EXTRA_DIST             += chimaera.ref
+CLEANFILES             += chimaera.out
+check-local:: chimaera chimaera.ref
+       ./chimaera >chimaera.out
+       diff -u $(srcdir)/chimaera.ref chimaera.out
+
+###----- That's all, folks --------------------------------------------------
diff --git a/test/chimaera.ref b/test/chimaera.ref
new file mode 100644 (file)
index 0000000..1842c08
--- /dev/null
@@ -0,0 +1,36 @@
+provoking Lion as a lion
+Munch!
+tickle Lion #0...
+Munch!
+tickle Lion #1...
+Munch!
+tickle Lion #2...
+Munch!
+provoking Goat as a goat
+Bonk!
+tickle Goat #0...
+Bonk!
+tickle Goat #1...
+Bonk!
+tickle Goat #2...
+Bonk!
+provoking Serpent as a serpent
+Nom!
+tickle Serpent #0...
+Sssss!
+tickle Serpent #1...
+Sssss!
+tickle Serpent #2...
+Nom!
+provoking Chimaera as a lion
+Munch!
+provoking Chimaera as a goat
+Bonk!
+provoking Chimaera as a serpent
+Nom!
+tickle Chimaera #0...
+Munch!
+tickle Chimaera #1...
+Munch!
+tickle Chimaera #2...
+Munch!