Closed phoe closed 5 years ago
I can't reproduce this.
(parachute:define-test foo
(parachute:is = 5 5)
(parachute:is eq "a" "b"))
(defmethod parachute:eval-in-context :around (context (test (eql (parachute:find-test 'foo))))
(print "before")
(call-next-method)
(print "after"))
(trace parachute:eval-in-context)
(parachute:test 'foo)
Output:
0: (PARACHUTE:EVAL-IN-CONTEXT #<PARACHUTE:PLAIN 1 results> #<PARACHUTE:TEST-RESULT :UNKNOWN COMMON-LISP-USER::FOO>)
? COMMON-LISP-USER::FOO
1: (PARACHUTE:EVAL-IN-CONTEXT #<PARACHUTE:PLAIN 1 results> #<PARACHUTE:TEST COMMON-LISP-USER::FOO>)
"before" 2: (PARACHUTE:EVAL-IN-CONTEXT #<PARACHUTE:PLAIN 2 results> #<PARACHUTE:COMPARISON-RESULT :UNKNOWN (is = 5 5)>)
0.000 ✔ (is = 5 5)
2: PARACHUTE:EVAL-IN-CONTEXT returned "(is = 5 5)"
2: (PARACHUTE:EVAL-IN-CONTEXT #<PARACHUTE:PLAIN 3 results> #<PARACHUTE:COMPARISON-RESULT :UNKNOWN (is eq "a" "b")>)
0.000 ✘ (is eq "a" "b")
2: PARACHUTE:EVAL-IN-CONTEXT returned "(is eq \"a\" \"b\")"
"after" 1: PARACHUTE:EVAL-IN-CONTEXT returned "after"
0.012 ✘ COMMON-LISP-USER::FOO
0: PARACHUTE:EVAL-IN-CONTEXT returned "COMMON-LISP-USER::FOO"
;; Summary:
Passed: 1
Failed: 1
Skipped: 0
;; Failures:
1/ 2 tests failed in COMMON-LISP-USER::FOO
The test form "b"
evaluated to "b"
when "a"
was expected to be equal under EQ.
Oh right - I forgot to mention it's for test suites.
(parachute:define-test foo)
(parachute:define-test bar
:parent foo
(parachute:is = 5 5)
(parachute:is eq "a" "b"))
(defmethod parachute:eval-in-context :around (context (test (eql (parachute:find-test 'foo))))
(print "before")
(call-next-method)
(print "after"))
(trace parachute:eval-in-context)
(parachute:test 'foo)
0: (PARACHUTE:EVAL-IN-CONTEXT #<PARACHUTE:PLAIN 1 results> #<PARACHUTE:TEST-RESULT :UNKNOWN GATEWAY.SQL/TEST::FOO>)
? GATEWAY.SQL/TEST::FOO
1: (PARACHUTE:EVAL-IN-CONTEXT #<PARACHUTE:PLAIN 1 results> #<PARACHUTE:TEST GATEWAY.SQL/TEST::FOO>)
"before"
"after" 1: PARACHUTE:EVAL-IN-CONTEXT returned "after"
1: (PARACHUTE:EVAL-IN-CONTEXT #<PARACHUTE:PLAIN 2 results> #<PARACHUTE:TEST-RESULT :UNKNOWN GATEWAY.SQL/TEST::BAR>)
? GATEWAY.SQL/TEST::BAR
2: (PARACHUTE:EVAL-IN-CONTEXT #<PARACHUTE:PLAIN 2 results> #<PARACHUTE:TEST GATEWAY.SQL/TEST::BAR>)
3: (PARACHUTE:EVAL-IN-CONTEXT #<PARACHUTE:PLAIN 3 results> #<PARACHUTE:COMPARISON-RESULT :UNKNOWN (is = 5 5)>)
0.000 ✔ (is = 5 5)
3: PARACHUTE:EVAL-IN-CONTEXT returned "(is = 5 5)"
3: (PARACHUTE:EVAL-IN-CONTEXT #<PARACHUTE:PLAIN 4 results> #<PARACHUTE:COMPARISON-RESULT :UNKNOWN (is eq "a" "b")>)
0.000 ✘ (is eq "a" "b")
3: PARACHUTE:EVAL-IN-CONTEXT returned "(is eq \"a\" \"b\")"
2: PARACHUTE:EVAL-IN-CONTEXT returned NIL
0.008 ✘ GATEWAY.SQL/TEST::BAR
1: PARACHUTE:EVAL-IN-CONTEXT returned "GATEWAY.SQL/TEST::BAR"
0.008 ✘ GATEWAY.SQL/TEST::FOO
0: PARACHUTE:EVAL-IN-CONTEXT returned "GATEWAY.SQL/TEST::FOO"
;; Summary:
Passed: 1
Failed: 1
Skipped: 0
;; Failures:
1/ 1 tests failed in GATEWAY.SQL/TEST::FOO
1/ 2 tests failed in GATEWAY.SQL/TEST::BAR
1/ 2 tests failed in GATEWAY.SQL/TEST::BAR
The test form "b"
evaluated to "b"
when "a"
was expected to be equal under EQ.
Actually, the situation is that you're expecting test children to be run within the test itself, which is not a valid expectation.
Got it. Let me jump back up and describe what I want and not what is going on.
I want to be able to evaluate some dynamically scoped code around all children of a particular test. Something like:
(defvar *frob* nil)
(parachute:define-test foo)
(parachute:define-test bar
:parent foo
(print *frob*))
(defmethod parachute:somehow-eval-around-children
:around (context (test (eql (parachute:find-test 'foo))))
(let ((*frob* t))
(call-next-method)))
I expect T
to be printed and not NIL
.
Should be solved by 79ac98e
T
gets printed, so yes, I have dynamic scope around children now. Thanks!
If I try to define an
:around
method onEVAL-IN-CONTEXT
on a test class (or instance), I would expect that the code will be executed around the test. However, it is not the case.Example definition:
Fragment of the test running:
Trace fragment: