OCaml Forge
SCM

Detail: [#862] ounit: support timeouts and running tests in separate process

Feature Requests: Browse | Download .csv | Monitor

[#862] ounit: support timeouts and running tests in separate process

Date:
2011-01-04 13:08
Priority:
3
State:
Closed
Submitted by:
Török Edwin (edwin)
Assigned to:
Sylvain Le Gall (gildor-admin)
Component:
General
Operating System:
All
Product:
ounit
 
Summary:
ounit: support timeouts and running tests in separate process

Detailed description
there should be a way in ounit to use timeouts.
I can sort of do that now with something like this (see below), but I guess it won't work on windows, and won't work if ounit ever learns to run the tests in parallel.
Also it doesn't work if the testcase throws a stack overflow, (or otherwise wants to segfault), setting a signal handler will just keep ocaml in an infinite loop.

So I think ounit should have a way to run tests in subprocesses, that way I can tell exactly which test failed, and timeouts would work better (killing process won't kill entire testsuite), and you can also easily run multiple tests in parallel if you decide to support that in the future.
Of course spawning a process is not a cheap task, so this should be configurable (optional param to run_test_tt_main?) and by default off.

open OUnit;;
let rec forever () = forever ();;

let test1 () =
Unix.alarm 2;
forever ();;

let suite =
"suite">:::["test1">:: test1];;

let _ =
Sys.signal 14 (Sys.Signal_handle (fun _ -> failwith "timeout"));
run_test_tt_main suite;

Followup

Message
Date: 2013-09-30 00:38
Sender: Sylvain Le Gall

Close with OUnit v2.0.0.

Timeout is handled in the processes runner. I'll may implement the alarm as well for sequential in future release.
Date: 2011-01-14 14:44
Sender: Sylvain Le Gall

There are other possibilities:
- use thread and Thread.kill after a timeout
- use Lwt and Lwt.cancel

Need to think about it, this is not an easy feature request.

Attached Files:

Changes:

Field Old Value Date By
status_idOpen2013-09-30 00:38gildor-admin
close_dateNone2013-09-30 00:38gildor-admin
assigned_tonone2011-01-14 14:44gildor-admin