@@ -75,7 +75,7 @@ open OUnitTypes
7575
7676(** Most simple heuristic, just pick the first test. *)
7777let simple state =
78- (* 118 *) List.hd state.tests_planned
78+ (* 119 *) List.hd state.tests_planned
7979
8080end
8181module OUnitUtils
@@ -98,22 +98,22 @@ let is_success =
9898let is_failure =
9999 function
100100 | RFailure _ -> (* 0 *) true
101- | RSuccess _ | RError _ | RSkip _ | RTodo _ -> (* 236 *) false
101+ | RSuccess _ | RError _ | RSkip _ | RTodo _ -> (* 238 *) false
102102
103103let is_error =
104104 function
105105 | RError _ -> (* 0 *) true
106- | RSuccess _ | RFailure _ | RSkip _ | RTodo _ -> (* 236 *) false
106+ | RSuccess _ | RFailure _ | RSkip _ | RTodo _ -> (* 238 *) false
107107
108108let is_skip =
109109 function
110110 | RSkip _ -> (* 0 *) true
111- | RSuccess _ | RFailure _ | RError _ | RTodo _ -> (* 236 *) false
111+ | RSuccess _ | RFailure _ | RError _ | RTodo _ -> (* 238 *) false
112112
113113let is_todo =
114114 function
115115 | RTodo _ -> (* 0 *) true
116- | RSuccess _ | RFailure _ | RError _ | RSkip _ -> (* 236 *) false
116+ | RSuccess _ | RFailure _ | RError _ | RSkip _ -> (* 238 *) false
117117
118118let result_flavour =
119119 function
@@ -145,7 +145,7 @@ let rec was_successful =
145145 | [] -> (* 3 *) true
146146 | RSuccess _::t
147147 | RSkip _::t ->
148- (* 354 *) was_successful t
148+ (* 357 *) was_successful t
149149
150150 | RFailure _::_
151151 | RError _::_
@@ -155,22 +155,22 @@ let rec was_successful =
155155let string_of_node =
156156 function
157157 | ListItem n ->
158- (* 472 *) string_of_int n
158+ (* 476 *) string_of_int n
159159 | Label s ->
160- (* 708 *) s
160+ (* 714 *) s
161161
162162(* Return the number of available tests *)
163163let rec test_case_count =
164164 function
165- | TestCase _ -> (* 118 *) 1
166- | TestLabel (_, t) -> (* 139 *) test_case_count t
165+ | TestCase _ -> (* 119 *) 1
166+ | TestLabel (_, t) -> (* 140 *) test_case_count t
167167 | TestList l ->
168168 (* 21 *) List.fold_left
169- (fun c t -> (* 138 *) c + test_case_count t)
169+ (fun c t -> (* 139 *) c + test_case_count t)
170170 0 l
171171
172172let string_of_path path =
173- (* 236 *) String.concat ":" (List.rev_map string_of_node path)
173+ (* 238 *) String.concat ":" (List.rev_map string_of_node path)
174174
175175let buff_format_printf f =
176176 (* 0 *) let buff = Buffer.create 13 in
@@ -194,12 +194,12 @@ let mapi f l =
194194
195195let fold_lefti f accu l =
196196 (* 21 *) let rec rfold_lefti cnt accup l =
197- (* 159 *) match l with
197+ (* 160 *) match l with
198198 | [] ->
199199 (* 21 *) accup
200200
201201 | h::t ->
202- (* 138 *) rfold_lefti (cnt + 1) (f accup h cnt) t
202+ (* 139 *) rfold_lefti (cnt + 1) (f accup h cnt) t
203203 in
204204 rfold_lefti 0 accu l
205205
@@ -217,7 +217,7 @@ open OUnitUtils
217217type event_type = GlobalEvent of global_event | TestEvent of test_event
218218
219219let format_event verbose event_type =
220- (* 710 *) match event_type with
220+ (* 716 *) match event_type with
221221 | GlobalEvent e ->
222222 (* 2 *) begin
223223 match e with
@@ -276,31 +276,31 @@ let format_event verbose event_type =
276276 end
277277
278278 | TestEvent e ->
279- (* 708 *) begin
279+ (* 714 *) begin
280280 let string_of_result =
281281 if verbose then
282- (* 354 *) function
283- | RSuccess _ -> (* 118 *) "ok\n"
282+ (* 357 *) function
283+ | RSuccess _ -> (* 119 *) "ok\n"
284284 | RFailure (_, _) -> (* 0 *) "FAIL\n"
285285 | RError (_, _) -> (* 0 *) "ERROR\n"
286286 | RSkip (_, _) -> (* 0 *) "SKIP\n"
287287 | RTodo (_, _) -> (* 0 *) "TODO\n"
288288 else
289- (* 354 *) function
290- | RSuccess _ -> (* 118 *) "."
289+ (* 357 *) function
290+ | RSuccess _ -> (* 119 *) "."
291291 | RFailure (_, _) -> (* 0 *) "F"
292292 | RError (_, _) -> (* 0 *) "E"
293293 | RSkip (_, _) -> (* 0 *) "S"
294294 | RTodo (_, _) -> (* 0 *) "T"
295295 in
296296 if verbose then
297- (* 354 *) match e with
297+ (* 357 *) match e with
298298 | EStart p ->
299- (* 118 *) Printf.sprintf "%s start\n" (string_of_path p)
299+ (* 119 *) Printf.sprintf "%s start\n" (string_of_path p)
300300 | EEnd p ->
301- (* 118 *) Printf.sprintf "%s end\n" (string_of_path p)
301+ (* 119 *) Printf.sprintf "%s end\n" (string_of_path p)
302302 | EResult result ->
303- (* 118 *) string_of_result result
303+ (* 119 *) string_of_result result
304304 | ELog (lvl, str) ->
305305 (* 0 *) let prefix =
306306 match lvl with
@@ -312,21 +312,21 @@ let format_event verbose event_type =
312312 | ELogRaw str ->
313313 (* 0 *) str
314314 else
315- (* 354 *) match e with
316- | EStart _ | EEnd _ | ELog _ | ELogRaw _ -> (* 236 *) ""
317- | EResult result -> (* 118 *) string_of_result result
315+ (* 357 *) match e with
316+ | EStart _ | EEnd _ | ELog _ | ELogRaw _ -> (* 238 *) ""
317+ | EResult result -> (* 119 *) string_of_result result
318318 end
319319
320320let file_logger fn =
321321 (* 1 *) let chn = open_out fn in
322322 (fun ev ->
323- (* 355 *) output_string chn (format_event true ev);
323+ (* 358 *) output_string chn (format_event true ev);
324324 flush chn),
325325 (fun () -> (* 1 *) close_out chn)
326326
327327let std_logger verbose =
328328 (* 1 *) (fun ev ->
329- (* 355 *) print_string (format_event verbose ev);
329+ (* 358 *) print_string (format_event verbose ev);
330330 flush stdout),
331331 (fun () -> (* 1 *) ())
332332
@@ -343,7 +343,7 @@ let create output_file_opt verbose (log,close) =
343343 (* 0 *) null_logger
344344 in
345345 (fun ev ->
346- (* 355 *) std_log ev; file_log ev; log ev),
346+ (* 358 *) std_log ev; file_log ev; log ev),
347347 (fun () ->
348348 (* 1 *) std_close (); file_close (); close ())
349349
@@ -705,7 +705,7 @@ let assert_failure msg =
705705 (* 0 *) failwith ("OUnit: " ^ msg)
706706
707707let assert_bool msg b =
708- (* 2005362 *) if not b then (* 0 *) assert_failure msg
708+ (* 2005363 *) if not b then (* 0 *) assert_failure msg
709709
710710let assert_string str =
711711 (* 0 *) if not (str = "") then (* 0 *) assert_failure str
@@ -951,7 +951,7 @@ let (@?) = assert_bool
951951
952952(* Some shorthands which allows easy test construction *)
953953let (>:) s t = (* 0 *) TestLabel(s, t) (* infix *)
954- let (>::) s f = (* 118 *) TestLabel(s, TestCase(f)) (* infix *)
954+ let (>::) s f = (* 119 *) TestLabel(s, TestCase(f)) (* infix *)
955955let (>:::) s l = (* 21 *) TestLabel(s, TestList(l)) (* infix *)
956956
957957(* Utility function to manipulate test *)
@@ -1087,7 +1087,7 @@ let maybe_backtrace = ""
10871087(* Run all tests, report starts, errors, failures, and return the results *)
10881088let perform_test report test =
10891089 (* 1 *) let run_test_case f path =
1090- (* 118 *) try
1090+ (* 119 *) try
10911091 f ();
10921092 RSuccess path
10931093 with
@@ -1106,22 +1106,22 @@ let perform_test report test =
11061106 let rec flatten_test path acc =
11071107 function
11081108 | TestCase(f) ->
1109- (* 118 *) (path, f) :: acc
1109+ (* 119 *) (path, f) :: acc
11101110
11111111 | TestList (tests) ->
11121112 (* 21 *) fold_lefti
11131113 (fun acc t cnt ->
1114- (* 138 *) flatten_test
1114+ (* 139 *) flatten_test
11151115 ((ListItem cnt)::path)
11161116 acc t)
11171117 acc tests
11181118
11191119 | TestLabel (label, t) ->
1120- (* 139 *) flatten_test ((Label label)::path) acc t
1120+ (* 140 *) flatten_test ((Label label)::path) acc t
11211121 in
11221122 let test_cases = List.rev (flatten_test [] [] test) in
11231123 let runner (path, f) =
1124- (* 118 *) let result =
1124+ (* 119 *) let result =
11251125 report (EStart path);
11261126 run_test_case f path
11271127 in
@@ -1130,18 +1130,18 @@ let perform_test report test =
11301130 result
11311131 in
11321132 let rec iter state =
1133- (* 119 *) match state.tests_planned with
1133+ (* 120 *) match state.tests_planned with
11341134 | [] ->
11351135 (* 1 *) state.results
11361136 | _ ->
1137- (* 118 *) let (path, f) = !global_chooser state in
1137+ (* 119 *) let (path, f) = !global_chooser state in
11381138 let result = runner (path, f) in
11391139 iter
11401140 {
11411141 results = result :: state.results;
11421142 tests_planned =
11431143 List.filter
1144- (fun (path', _) -> (* 7021 *) path <> path') state.tests_planned
1144+ (fun (path', _) -> (* 7140 *) path <> path') state.tests_planned
11451145 }
11461146 in
11471147 iter {results = []; tests_planned = test_cases}
@@ -1171,7 +1171,7 @@ let run_test_tt ?verbose test =
11711171 time_fun
11721172 perform_test
11731173 (fun ev ->
1174- (* 354 *) log (OUnitLogger.TestEvent ev))
1174+ (* 357 *) log (OUnitLogger.TestEvent ev))
11751175 test
11761176 in
11771177
@@ -1894,33 +1894,33 @@ let equal (x : string) y = (* 0 *) x = y
18941894
18951895
18961896let unsafe_is_sub ~sub i s j ~len =
1897- (* 589 *) let rec check k =
1898- (* 753 *) if k = len
1899- then (* 33 *) true
1897+ (* 681 *) let rec check k =
1898+ (* 864 *) if k = len
1899+ then (* 34 *) true
19001900 else
1901- (* 720 *) String.unsafe_get sub (i+k) =
1901+ (* 830 *) String.unsafe_get sub (i+k) =
19021902 String.unsafe_get s (j+k) && check (k+1)
19031903 in
19041904 j+len <= String.length s && check 0
19051905
19061906
19071907exception Local_exit
19081908let find ?(start=0) ~sub s =
1909- (* 39 *) let n = String.length sub in
1909+ (* 40 *) let n = String.length sub in
19101910 let s_len = String.length s in
19111911 let i = ref start in
19121912 try
19131913 while !i + n <= s_len do
1914- (* 581 *) if unsafe_is_sub ~sub 0 s !i ~len:n then
1915- (* 31 *) raise_notrace Local_exit;
1914+ (* 673 *) if unsafe_is_sub ~sub 0 s !i ~len:n then
1915+ (* 32 *) raise_notrace Local_exit;
19161916 incr i
19171917 done;
19181918 -1
19191919 with Local_exit ->
1920- (* 31 *) !i
1920+ (* 32 *) !i
19211921
19221922let contain_substring s sub =
1923- (* 9 *) find s ~sub >= 0
1923+ (* 10 *) find s ~sub >= 0
19241924
19251925(** TODO: optimize
19261926 avoid nonterminating when string is empty
@@ -3528,7 +3528,7 @@ let rec safe_dup fd =
35283528 end
35293529
35303530let safe_close fd =
3531- (* 18 *) try Unix.close fd with Unix.Unix_error(_,_,_) -> (* 0 *) ()
3531+ (* 20 *) try Unix.close fd with Unix.Unix_error(_,_,_) -> (* 0 *) ()
35323532
35333533
35343534type output = {
@@ -3538,7 +3538,7 @@ type output = {
35383538}
35393539
35403540let perform command args =
3541- (* 9 *) let new_fd_in, new_fd_out = Unix.pipe () in
3541+ (* 10 *) let new_fd_in, new_fd_out = Unix.pipe () in
35423542 let err_fd_in, err_fd_out = Unix.pipe () in
35433543 match Unix.fork () with
35443544 | 0 ->
@@ -3557,28 +3557,28 @@ let perform command args =
35573557 when all the descriptiors on a pipe's output are closed, a call to
35583558 [write] on its input kills the writing process (EPIPE).
35593559 *)
3560- (* 9 *) safe_close new_fd_out ;
3560+ (* 10 *) safe_close new_fd_out ;
35613561 safe_close err_fd_out ;
35623562 let in_chan = Unix.in_channel_of_descr new_fd_in in
35633563 let err_in_chan = Unix.in_channel_of_descr err_fd_in in
35643564 let buf = Buffer.create 1024 in
35653565 let err_buf = Buffer.create 1024 in
35663566 (try
35673567 while true do
3568- (* 67 *) Buffer.add_string buf (input_line in_chan );
3568+ (* 68 *) Buffer.add_string buf (input_line in_chan );
35693569 Buffer.add_char buf '\n'
35703570 done;
35713571 with
3572- End_of_file -> (* 9 *) ()) ;
3572+ End_of_file -> (* 10 *) ()) ;
35733573 (try
35743574 while true do
3575- (* 106 *) Buffer.add_string err_buf (input_line err_in_chan );
3575+ (* 109 *) Buffer.add_string err_buf (input_line err_in_chan );
35763576 Buffer.add_char err_buf '\n'
35773577 done;
35783578 with
3579- End_of_file -> (* 9 *) ()) ;
3579+ End_of_file -> (* 10 *) ()) ;
35803580 let exit_code = match snd @@ Unix.waitpid [] pid with
3581- | Unix.WEXITED exit_code -> (* 9 *) exit_code
3581+ | Unix.WEXITED exit_code -> (* 10 *) exit_code
35823582 | Unix.WSIGNALED _signal_number
35833583 | Unix.WSTOPPED _signal_number -> (* 0 *) 127 in
35843584 {
@@ -3589,7 +3589,7 @@ let perform command args =
35893589
35903590
35913591let perform_bsc args =
3592- (* 9 *) perform bsc_exe
3592+ (* 10 *) perform bsc_exe
35933593 (Array.append
35943594 [|bsc_exe ;
35953595 "-bs-package-name" ; "bs-platform";
@@ -3606,7 +3606,7 @@ let perform_bsc args =
36063606 |] args)
36073607
36083608let bsc_eval str =
3609- (* 6 *) perform_bsc [|"-bs-eval"; str|]
3609+ (* 7 *) perform_bsc [|"-bs-eval"; str|]
36103610
36113611 let debug_output o =
36123612 (* 0 *) Printf.printf "\nexit_code:%d\nstdout:%s\nstderr:%s\n"
@@ -3751,10 +3751,22 @@ external err :
37513751 external err :
37523752 ?hi_should_error:([`a of int | `b of string ] [@bs.string]) ->
37533753 unit -> _ = "" [@@bs.obj]
3754+ |} in
3755+ OUnit.assert_bool __LOC__
3756+ (Ext_string.contain_substring output.stderr "hi_should_error")
3757+ end;
3758+ __LOC__ >:: begin fun _ ->
3759+ (* 1 *) let output = bsc_eval {|
3760+ external err :
3761+ ?hi_should_error:([`a of int | `b of string ] [@bs.string]) ->
3762+ unit -> unit = "" [@@bs.val]
37543763 |} in
37553764 OUnit.assert_bool __LOC__
37563765 (Ext_string.contain_substring output.stderr "hi_should_error")
37573766 end
3767+
3768+
3769+
37583770 ]
37593771end
37603772module Ext_util : sig
0 commit comments