Skip to content
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

?length parameter doesn't seem to set timeout #88

Open
willbarkoff opened this issue Apr 6, 2021 · 3 comments
Open

?length parameter doesn't seem to set timeout #88

willbarkoff opened this issue Apr 6, 2021 · 3 comments

Comments

@willbarkoff
Copy link

willbarkoff commented Apr 6, 2021

Hi there!

I had a question about the ?length parameter on test_case. I wrote a test that should never complete, and I'm trying to get it to timeout, but it won't. I'm wondering if I'm using the ?length parameter correctly:

let suite =
  "main_test_suite"
  >::: [
         "timeout_test"
         >: test_case ~length:(OUnitTest.Custom_length 1.) (fun _ ->
                let rec call_self_tr n =
                  if n = 0 then 0 else call_self_tr (n + 1)
                in
                assert_equal 1 (call_self_tr 1));
       ]

let _ = run_test_tt_main suite

I think that this test should timeout after 1 second, but this doesn't seem to happen? Is there any documentation that i should be looking at for this parameter, or something that I'm doing wrong? I've taken a look here, but that seems to be pretty much the only documentation that I can find.

Thank you so much!

By the way, I'm using OUnit2 v2.2.4.

Thanks!

@gildor478
Copy link
Owner

What runner are you using? (Thread or Process)

What OS are you running on?

The code doesn't show if you are using "open OUnit" or "open OUnit2" (there is a difference).

Have you tried with a standard test length (OUnitTest.Immediate)?

@willbarkoff
Copy link
Author

willbarkoff commented Apr 6, 2021

What runner are you using? (Thread or Process)

I'm using -runner sequential, it seems to work when I remove this flag. Are timeouts not supported on the sequential runner?

What OS are you running on?

macOS 11.2.1

The code doesn't show if you are using "open OUnit" or "open OUnit2" (there is a difference).

I'm using open OUnit2

Have you tried with a standard test length (OUnitTest.Immediate)?

Yes, I've tried both OUnitTest.Immediate and OUnitTest.Short

Thank you so much for your help, and for making such an amazing testing library :)

@gildor478
Copy link
Owner

gildor478 commented Apr 6, 2021

Sequential runner doesn't support timeout

I have__totally__ documented this problem at the time of the release:
https://sylvain.le-gall.net/blog/index.php?post/2013/09/29/OUnit-2.0%2C-official-release

It might be worth adding that to the real documentation on this website (the blog post was really a bad idea for the documentation).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants