You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some tests where I want to assert timing, for example:
(rcf/set-timeout! 1)
(tests
"Awaits all promise-chan in given vector and returns a vector of their results in order. Promise-chans obviously run concurrently, so the entire operation will take as long as the longest one."
(rcf/set-timeout! 210)
(async
(! (await (all [1 (timeout 100 2) (timeout 200 3)]))))
% := [1 2 3])
Now this test will fail, because it seems the call to (rcf/set-timeout! 210) won't change the timeout of the test. This is kind of annoying, because when I have many tests which I need to control timeouts differently I have to do:
(do
(rcf/set-timeout! 210)
(tests
"Awaits all promise-chan in given vector and returns a vector of their results in order. Promise-chan obviously run concurrently, so the entire operation will take as long as the longest one."
(async
(! (await (all [1 (timeout 100 2) (timeout 200 3)]))))
% := [1 2 3])
(rcf/set-timeout! 20)
(tests
"Short-circuits as soon as one promise-chan errors, returning the error."
(async
(try
(await (all [(timeout 10 #(/ 1 0)) (timeout 100 2) (timeout 200 3)]))
(catch Exception e
(! e))))
(type %) := ArithmeticException)
(rcf/set-timeout! 1000)
(tests
"Can contain non-promise-chan as well."
(async
(! (await (all [1 2 3]))))
% := [1 2 3]
"But since all is not a macro, if one of them throw it throws"
(try (all [1 (timeout 10 2) (/ 1 0)])
(catch Exception e
(! e)))
(type %) := ArithmeticException))
What I'd like to do instead is:
(tests
"Awaits all promise-chan in given vector and returns a vector of their results in order. Promise-chan obviously run concurrently, so the entire operation will take as long as the longest one."
(rcf/set-timeout! 210)
(async
(! (await (all [1 (timeout 100 2) (timeout 200 3)]))))
% := [1 2 3])
"Short-circuits as soon as one promise-chan errors, returning the error."
(rcf/set-timeout! 20)
(async
(try
(await (all [(timeout 10 #(/ 1 0)) (timeout 100 2) (timeout 200 3)]))
(catch Exception e
(! e))))
(type %) := ArithmeticException)
(rcf/set-timeout! 1000)
"Can contain non-promise-chan as well."
(async
(! (await (all [1 2 3]))))
% := [1 2 3]
"But since all is not a macro, if one of them throw it throws"
(try (all [1 (timeout 10 2) (/ 1 0)])
(catch Exception e
(! e)))
(type %) := ArithmeticException))
I'd be happy if I could use (binding [rcf/*timeout*]) or something similar as well to wrap my individual tests inside the tests block too.
The text was updated successfully, but these errors were encountered:
I have some tests where I want to assert timing, for example:
Now this test will fail, because it seems the call to (rcf/set-timeout! 210) won't change the timeout of the test. This is kind of annoying, because when I have many tests which I need to control timeouts differently I have to do:
What I'd like to do instead is:
I'd be happy if I could use
(binding [rcf/*timeout*])
or something similar as well to wrap my individual tests inside thetests
block too.The text was updated successfully, but these errors were encountered: