From 34796ac62879fa0a6a8683fc9b4e4335bafcf724 Mon Sep 17 00:00:00 2001 From: Gene Kim Date: Sun, 18 Oct 2020 23:07:35 -0400 Subject: [PATCH] Copied over test packaging and travis build changes from the diverged branch. --- .travis.yml | 78 +++++++++++++++++++++---------------- src/package.lisp | 2 +- src/run-tests.lisp | 3 ++ src/test/deepest-match.lisp | 7 +--- src/test/package.lisp | 74 +++++++++++++++++++++++++++++++++++ src/tests.lisp | 14 ++++--- src/ttt.asd | 21 ++++++++-- 7 files changed, 151 insertions(+), 48 deletions(-) create mode 100644 src/run-tests.lisp create mode 100644 src/test/package.lisp diff --git a/.travis.yml b/.travis.yml index 1e32c81..1d92c4f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,49 +1,61 @@ language: lisp env: + global: + - PATH=~/.roswell/bin:$PATH + - ROSWELL_INSTALL_DIR=$HOME/.roswell matrix: - - LISP=sbcl - - LISP=sbcl32 + - LISP=sbcl COVERALLS=true - LISP=allegro - - LISP=allegromodern - - LISP=abcl - - LISP=ccl - - LISP=ccl32 - - LISP=clisp - - LISP=clisp32 - - LISP=cmucl - - LISP=ecl +# - LISP=abcl +# - LISP=ccl-bin +# - LISP=clisp +# - LISP=cmu-bin +# - LISP=ecl + #- LISP=allegromodern + #- LISP=abcl + #- LISP=ccl + #- LISP=ccl32 + #- LISP=clisp + #- LISP=clisp32 + #- LISP=cmucl + #- LISP=ecl matrix: allow_failures: # Only plan to support SBCL, but check compatilibity issues on other # distributions. - env: LISP=allegro - - env: LISP=allegromodern - - env: LISP=abcl - - env: LISP=ccl - - env: LISP=ccl32 - - env: LISP=clisp - - env: LISP=clisp32 - - env: LISP=ecl - # CIM not available for CMUCL - - env: LISP=cmucl + #- env: LISP=allegromodern + #- env: LISP=abcl + #- env: LISP=ccl + #- env: LISP=ccl32 + #- env: LISP=clisp + #- env: LISP=clisp32 + #- env: LISP=ecl + ## CIM not available for CMUCL + #- env: LISP=cmucl install: - - curl https://raw.githubusercontent.com/luismbo/cl-travis/master/install.sh | sh; + # Install roswell + #- curl -L https://raw.githubusercontent.com/roswell/roswell/release/scripts/install-for-ci.sh | sh; + - curl -L https://raw.githubusercontent.com/genelkim/custom-ci-scripts/master/install-for-ci-sbcl-2.0.7.sh | sh; + # Make current project accessible by roswell + - ln -s $(pwd) ~/.roswell/local-projects/ttt -before_script: - - echo "(defsystem :dummy-cl-travis-system)" > ~/lisp/dummy-cl-travis-system.asd + # Custom cl-coveralls + - ros install genelkim/cl-coveralls + +cache: + directories: + # Cache roswell + - $HOME/.roswell script: - - cd src; cl -e '(ql:quickload :ttt) - (ql:quickload :uiop) - (in-package :ttt) - (load-tests-all) - (format t "Original TTT tests...~%") - (compile-tests) - (run-tests) - (format t "New unit tests...~%") - (loop for test-file in (directory "test/*.lisp") - do (load test-file)) - (lisp-unit:run-tests)' + - if [[ "$LISP" == "sbcl" ]]; then + ros -s cl-coveralls -e '(or (coveralls:with-coveralls (:exclude (cons "tests.lisp" (directory "test/*.lisp"))) + (load "src/run-tests")) + (uiop:quit -1))'; + else + cd src; ros -l run-tests.lisp; + fi diff --git a/src/package.lisp b/src/package.lisp index 333ad6b..5d9d8db 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -1,6 +1,6 @@ (defpackage ttt (:documentation "the TTT (template to template transduction) package!") - (:use :cl :lisp-unit) + (:use :cl) (:shadow :run-tests) (:export :match-expr :apply-rules diff --git a/src/run-tests.lisp b/src/run-tests.lisp new file mode 100644 index 0000000..ac03b4d --- /dev/null +++ b/src/run-tests.lisp @@ -0,0 +1,3 @@ +(ql:quickload :ttt/tests) +(in-package :ttt/tests) +(run) diff --git a/src/test/deepest-match.lisp b/src/test/deepest-match.lisp index c762262..5b9009d 100644 --- a/src/test/deepest-match.lisp +++ b/src/test/deepest-match.lisp @@ -1,12 +1,7 @@ ;;; Gene Louis Kim, 4-6-2020 ;;; Unit tests for verifying more exhaustive fix for apply. -(in-package :ttt) - -(setq *print-failures* t) -(setq *print-errors* t) -(setq *print-summary* t) -(setq *summarize-results* t) +(in-package :ttt/tests) (define-test basic-deepest-match "Basic tests for deepest match." diff --git a/src/test/package.lisp b/src/test/package.lisp new file mode 100644 index 0000000..9817222 --- /dev/null +++ b/src/test/package.lisp @@ -0,0 +1,74 @@ +(defpackage #:ttt/tests + (:use #:cl #:lisp-unit #:ttt) + (:shadow :run-tests) + (:export #:run)) + +(in-package :ttt/tests) + +;; These functions are borrowed from the cl-util library. This is defined here +;; since cl-util currently depends on TTT so we can't import these functions. +;; TODO: Move TTT-dependant code to this repo and change dependency order. +;; Macro for pre- and post- interning symbols. +;; bgnval: initial symbol or s-expr of symbols +;; midval: name of variable storing bgnvar after it is interned into the ulf-lib package +;; callpkg: optional argument for the package that the output should be interned to +;; if nil, it defaults to the value *ulf-lib-caller-pkg* +;; body: body of the code (using midval) +;; outval: immediate output of the body +(defmacro inout-intern ((bgnval midval inpkg &key (callpkg nil)) &body body) + `(let* ((,midval (intern-symbols-recursive ,bgnval ,inpkg)) + (outval (multiple-value-list (progn ,@body)))) + (values-list + (cond + (,callpkg (intern-symbols-recursive outval ,callpkg)) + (*intern-caller-pkg* (intern-symbols-recursive outval *intern-caller-pkg*)) + (t outval))))) +;; Same as inout-intern macro but only performs the pre- interning portion. +;; Interns the incoming symbols and stores it in midval before evaluating +;; the body. +(defmacro in-intern ((bgnval midval inpkg) &body body) + `(let* ((,midval (intern-symbols-recursive ,bgnval ,inpkg))) + ,@body)) + +(defun run (&key tests tags + ;; lisp-unit verbosity parameters. + (print-failures t) + (print-errors t) + (print-summary t) + (summarize-results t)) + "Run all TTT tests. + + Optional arguments: + tests: list of test names, defaults to running all tests + tags: list of test tags + + `tests` and `tags` should not both be set. The `tags` argument will be + ignored if that is the case. + " + + (format t "Original TTT tests...~%") + (load-tests-all) + (compile-tests) + (run-tests) + + (format t "New unit tests...") + (let ((*print-failures* print-failures) + (*print-errors* print-errors) + (*print-summary* print-summary) + (*summarize-results* summarize-results)) + ;; Run tests. + (cond + ;; Specified tests. + (tests + (when tags + (warn (concatenate 'string + "Both the :tags and :tests keyword " + "arguments are given for ttt/tests:run. " + "Ignoring the :tags argument..."))) + (in-intern (tests pkgtests :ttt/tests) + (lisp-unit:run-tests pkgtests :ttt/tests))) + ;; Specified tags. + (tags (run-tags tags :ttt/tests)) + ;; Default, all tests. + (t (lisp-unit:run-tests :all :ttt/tests))))) + diff --git a/src/tests.lisp b/src/tests.lisp index 98783ff..573d70a 100644 --- a/src/tests.lisp +++ b/src/tests.lisp @@ -1,4 +1,4 @@ -(in-package :ttt) +(in-package :ttt/tests) ;; This was primarily used during inital development. ;; It is certainly not comprehensive in testing combinations of pattern operators. @@ -12,22 +12,26 @@ ;; when disp-counts is true, the overall pass/fail counts are displayed - ;; 2011-12-13 - added sticky tests ;(format t "testing hasn't been completely rewritten for oo version") +;; Test versions of TTT-internal functions. +(defun to-expr (x) + (ttt::to-expr x)) + + (defparameter *pattern-matching-tests* nil) (defun match-f (pattern tree) - (match pattern (list tree) t)) + (ttt::match pattern (list tree) t)) (defun compile-tests () (let (tmp) (dolist (pair *pattern-matching-tests*) - (push (list (build-pattern (test-getpat pair)) - (build-tree (test-getexpr pair)) + (push (list (ttt::build-pattern (test-getpat pair)) + (ttt::build-tree (test-getexpr pair)) (test-getbind pair)) tmp)) (setf *pattern-matching-tests* (nreverse tmp)))) diff --git a/src/ttt.asd b/src/ttt.asd index 857c180..6dc1dbb 100644 --- a/src/ttt.asd +++ b/src/ttt.asd @@ -1,6 +1,11 @@ (defpackage :ttt) (asdf:defsystem :ttt - :depends-on (:lisp-unit) + :name "Tree-to-Tree Transduction" + :serial t + :version "2.0.0" + :author "Adam Purtee and Gene Louis Kim " + :license "GPLv3" + :depends-on () :components ((:file "package") (:file "operators") (:file "expressions") @@ -18,9 +23,19 @@ (:file "predicates") (:file "template-construction") (:file "transductions") - (:file "tests") ; TODO: ; move this to a separate testing package.move this to a separate testing package. (:file "util") (:file "process-tb") (:file "search-tb")) - :serial t) + :in-order-to ((test-op (test-op :ttt/tests)))) + +(asdf:defsystem :ttt/tests + :serial t + :description "Tests for the TTT library" + :author "Adam Purtee and Gene Louis Kim " + :license "GPLv3" + :depends-on (:ttt :lisp-unit) + :components ((:file "test/package") + (:file "tests") + (:file "test/deepest-match")) + :perform (test-op (o c) (symbol-call :ttt/tests :run)))