diff --git a/test/test-core.lisp b/test/test-core.lisp index 1043a33..3de8995 100644 --- a/test/test-core.lisp +++ b/test/test-core.lisp @@ -17,7 +17,7 @@ (:t :scopes/testing)) (:export #:run #:user #:password #:test-receiver #:receiver #:suite - #:expect #:check-message #:check-expected + #:collect #:collected #:expect #:check-message #:check-expected #:setup #:test-suite) (:import-from :scopes/testing #:deftest #:== #:!=)) @@ -27,6 +27,7 @@ (defclass test-receiver (core:context) ((suite :reader suite :initarg :suite) + (collected :accessor collected :initform nil) (expected :accessor expected :initform (make-hash-table :test #'equalp)))) @@ -34,6 +35,9 @@ (funcall (core:make-setup :class 'test-receiver :args (list :suite t:*test-suite*)) cfg)) +(defun collect (ctx msg) + (push msg (collected ctx))) + (defun check-message (ctx msg) (let ((key (shape:head msg)) (t:*test-suite* (suite ctx))) diff --git a/test/test-csys.lisp b/test/test-csys.lisp index 7b00421..86cfc47 100644 --- a/test/test-csys.lisp +++ b/test/test-csys.lisp @@ -35,7 +35,8 @@ (config:add-action '(:csys :effect :e01) (value-in '(1 2 3 4))) (config:add-action '(:csys :effect :e02) (value-in '(1 2 3 4))) ;(config:add-action '(:csys :effect) #'tc:check-message) - (config:add-action '(:csys) (constantly nil))) + ;(config:add-action '(:csys) (constantly nil)) + (config:add-action '(:csys) #'tc:collect)) (defun proc-env (msg scope) (let ((t:*test-suite* (csys:environ scope))) @@ -50,10 +51,11 @@ (load (t:test-path "config-csys" "etc")) (async:init) (unwind-protect - (test-space) - (test-basic-0) - (test-basic-1) - (test-basic-2) + (progn + (test-space) + (test-basic-0) + (test-basic-1) + (test-basic-2)) (sleep 0.02) (tc:check-expected) (t:show-result)))) @@ -100,11 +102,12 @@ )) (deftest test-basic-0 () - (let ((environ:*env* (setup (list (basic:prog-b0))))) - ;(rcvr (tc:receiver t:*test-suite*)) + (let ((environ:*env* (setup (list (basic:prog-b0)))) + (rcvr (tc:receiver t:*test-suite*))) ;(tc:expect rcvr (message:create '(:csys :effect :e01) :data '(:value 1))) (environ:send-value '(:s00 #(0 1)) 1) (environ:send-value '(:s00 #(0 1)) 2) + ;(sleep 0.01) (print (tc:collected rcvr)) (teardown))) (deftest test-basic-1 ()