diff --git a/.github/workflows/ci-test.yaml b/.github/workflows/ci-test.yaml new file mode 100644 index 0000000..2dac483 --- /dev/null +++ b/.github/workflows/ci-test.yaml @@ -0,0 +1,21 @@ +name: ci-test + +on: push + +jobs: + test: + runs-on: ubuntu-latest + container: bdockerimg/quicklisp + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Run Tests + run: | + set -ex + sbcl --disable-debugger \ + --load /root/quicklisp/setup.lisp \ + --eval '(ql:update-all-dists)' \ + --load thespis.asd \ + --eval '(ql:quickload :thespis/test)' \ + --eval '(asdf:test-system :thespis/test)' \ + --eval '(quit)' \ No newline at end of file diff --git a/test.lisp b/test.lisp index 10ed9d7..00dd460 100644 --- a/test.lisp +++ b/test.lisp @@ -1,17 +1,14 @@ -(defpackage #:thespis/test - (:use #:cl #:fiveam #:thespis) - (:export :bruteforce)) +(fiasco:define-test-package #:thespis/test + (:use #:thespis) + (:export #:bruteforce)) (in-package #:thespis/test) (defun bruteforce (&optional (times 1024)) "Detect rare race conditions by brute force." (dotimes (i times) - (assert (eql t (fiveam:run! :thespis))))) + (assert (eql t (fiasco:run-tests :thespis/test))))) -(def-suite :thespis) -(in-suite :thespis) - -(test :counter +(deftest test-counter () (define-actor counter ((c 0)) (increment) (incf c increment)) @@ -27,7 +24,7 @@ (is (= -1 (ask actor 1))) (close-actor actor))) -(test :lambda-rest +(deftest test-lambda-rest () (define-actor square-summer ((c 0)) (&rest args) (incf c (apply #'+ (mapcar (lambda (x) (* x x)) args)))) @@ -36,7 +33,7 @@ (is (= 21 (ask actor 4))) (close-actor actor))) -(test :lambda-key +(deftest test-lambda-key () (define-actor point-actor ((x 0) (y 0) (z 0)) (&key (dx 0) (dy 0) (dz 0)) (list @@ -51,7 +48,7 @@ (is (equal '(:x -1 :y 100 :z 3) (ask actor))) (close-actor actor))) -(test :multiple-values +(deftest test-multiple-values () (define-actor multivaluer ((prev 0)) (next) (multiple-value-prog1 (values prev next) (setf prev next))) @@ -63,7 +60,7 @@ (close-actor actor) (is (equal '(2 1) (multiple-value-list (join-actor actor)))))) -(test :pong +(deftest test-pong () (let (pinger ponger (result 0)) (define-actor pinger () (c) (incf result) @@ -85,7 +82,7 @@ (join-actor pinger) (is (= 11 result)))) -(test :self +(deftest test-self () (let ((result 0)) (define-actor selfish-counter () () (incf result) @@ -98,7 +95,7 @@ (join-actor actor) (is (= result 11))))) -(test :error-handling +(deftest test-error-handling () (define-actor failer () (x) (/ 1 x)) @@ -109,7 +106,7 @@ (is (eq :failed (ask actor 0))) (close-actor actor))) -(test :closed-actor +(deftest test-closed-actor () (define-actor closer () (x) x) @@ -118,7 +115,7 @@ (handler-case (send actor 'x) (error (c) (is (typep c 'simple-error)))))) -(test :redefine-actor +(deftest test-redefine-actor () (define-actor counter ((c 0)) (increment) (incf c increment)) @@ -133,7 +130,7 @@ (is (= 10 (ask actor 1 7))) (close-actor actor))) -(test :registry +(deftest test-registry () (define-actor counter ((c 0)) (increment) (incf c increment)) @@ -147,12 +144,12 @@ ;; I need to create a Join Sync signal I think... -(test :close-and-join - (define-actor counter ((c 0)) (increment) - (incf c increment)) +;; (deftest test-close-and-join () +;; (define-actor counter ((c 0)) (increment) +;; (incf c increment)) - (counter :name :my-counter) - (send :my-counter 1) - (is (= 3 (ask :my-counter 2))) - (close-and-join-actors :my-counter) - (is (eql nil (gethash :my-counter *registry*)))) +;; (counter :name :my-counter) +;; (send :my-counter 1) +;; (is (= 3 (ask :my-counter 2))) +;; (close-and-join-actors :my-counter) +;; (is (eql nil (gethash :my-counter *registry*)))) diff --git a/thespis.asd b/thespis.asd index 7e4769c..779ce58 100644 --- a/thespis.asd +++ b/thespis.asd @@ -4,8 +4,15 @@ :license "MIT" :depends-on (#:bordeaux-threads #:queues.simple-cqueue) :components ((:file "package") - (:file "thespis"))) + (:file "thespis")) + :in-order-to ((test-op (test-op #:thespis/test)))) (asdf:defsystem #:thespis/test - :depends-on (#:thespis #:fiveam) - :components ((:file "test"))) + :depends-on (#:thespis #:fiasco) + :components ((:file "test")) + :perform (asdf:test-op + (o c) + (multiple-value-bind (stat result) + (uiop:symbol-call :fiasco :run-tests '(:thespis/test)) + (print result) + (assert (eql t stat)))))