summaryrefslogtreecommitdiff
path: root/testsuite/tests/backtrace/pr2195.ml
blob: e0442a34051308e12580fe3c362a96ab4145f1a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
(* TEST
   flags += "-g"
   exit_status = "2"
   * bytecode
     ocamlrunparam += ",b=0"
     reference = "${test_source_directory}/pr2195-nolocs.byte.reference"
   * bytecode
     ocamlrunparam += ",b=1"
     reference = "${test_source_directory}/pr2195-nolocs.byte.reference"
   * bytecode
     ocamlrunparam += ",b=2"
     reference = "${test_source_directory}/pr2195-locs.byte.reference"
   * native
     reference = "${test_source_directory}/pr2195.opt.reference"
     compare_programs = "false"
*)

let () =
  Printexc.record_backtrace true;
  let c = open_out "foo" in
  close_out c;
  try
    while true do
      open_in "foo" |> ignore
    done
  with Sys_error _ ->
    (* The message is platform-specific, so convert the exception to Exit *)
    let bt = Printexc.get_raw_backtrace () in
    Printexc.raise_with_backtrace Exit bt