Skip to content

Commit

Permalink
Copied over test packaging and travis build changes from the diverged…
Browse files Browse the repository at this point in the history
… branch.
  • Loading branch information
genelkim committed Oct 19, 2020
1 parent 90d9aa2 commit 34796ac
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 48 deletions.
78 changes: 45 additions & 33 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/package.lisp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/run-tests.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(ql:quickload :ttt/tests)
(in-package :ttt/tests)
(run)
7 changes: 1 addition & 6 deletions src/test/deepest-match.lisp
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
74 changes: 74 additions & 0 deletions src/test/package.lisp
Original file line number Diff line number Diff line change
@@ -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)))))

14 changes: 9 additions & 5 deletions src/tests.lisp
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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))))
Expand Down
21 changes: 18 additions & 3 deletions src/ttt.asd
Original file line number Diff line number Diff line change
@@ -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 <gkim21@cs.rochester.edu>"
:license "GPLv3"
:depends-on ()
:components ((:file "package")
(:file "operators")
(:file "expressions")
Expand All @@ -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 <gkim21@cs.rochester.edu>"
: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)))

0 comments on commit 34796ac

Please sign in to comment.