Skip to content

Fiasco Workflow #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/ci-test.yaml
Original file line number Diff line number Diff line change
@@ -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)'
47 changes: 22 additions & 25 deletions test.lisp
Original file line number Diff line number Diff line change
@@ -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))

Expand All @@ -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))))

Expand All @@ -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
Expand All @@ -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)))
Expand All @@ -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)
Expand All @@ -85,7 +82,7 @@
(join-actor pinger)
(is (= 11 result))))

(test :self
(deftest test-self ()
(let ((result 0))
(define-actor selfish-counter () ()
(incf result)
Expand All @@ -98,7 +95,7 @@
(join-actor actor)
(is (= result 11)))))

(test :error-handling
(deftest test-error-handling ()
(define-actor failer () (x)
(/ 1 x))

Expand All @@ -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)

Expand All @@ -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))

Expand All @@ -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))

Expand All @@ -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*))))
13 changes: 10 additions & 3 deletions thespis.asd
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))
Loading