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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
From: Stephane Glondu <steph@glondu.net>
Date: Sat, 18 Dec 2021 01:55:44 +0100
Subject: Fix compilation on bytecode architectures
Forwarded: https://github.com/mirage/alcotest/pull/335
---
examples/bad/dune | 2 +-
examples/dune | 2 +-
test/e2e/alcotest-lwt/failing/dune.inc | 2 +-
test/e2e/alcotest-lwt/passing/dune.inc | 2 +-
test/e2e/alcotest/failing/dune.inc | 2 +-
test/e2e/alcotest/passing/dune.inc | 2 +-
test/e2e/gen_dune_rules.ml | 2 +-
test/e2e/strip_randomness.ml | 25 ++++++++++++++++---------
8 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/examples/bad/dune b/examples/bad/dune
index fa43f7c..ab06b9a 100644
--- a/examples/bad/dune
+++ b/examples/bad/dune
@@ -1,6 +1,6 @@
(executable
(name bad)
- (modes native js)
+ (modes exe js)
(libraries alcotest astring))
; This fails at runtime, so just build the executable
diff --git a/examples/dune b/examples/dune
index bcce0b9..b987b36 100644
--- a/examples/dune
+++ b/examples/dune
@@ -1,7 +1,7 @@
(tests
(names simple floats)
(package alcotest)
- (modes native js)
+ (modes exe js)
(libraries alcotest))
(rule
diff --git a/test/e2e/alcotest-lwt/failing/dune.inc b/test/e2e/alcotest-lwt/failing/dune.inc
index b606e08..56b560d 100644
--- a/test/e2e/alcotest-lwt/failing/dune.inc
+++ b/test/e2e/alcotest-lwt/failing/dune.inc
@@ -4,7 +4,7 @@
fail_with
)
(libraries alcotest alcotest.stdlib_ext alcotest-lwt lwt lwt.unix)
- (modes native)
+ (modes exe)
(modules
async_failure
fail_with
diff --git a/test/e2e/alcotest-lwt/passing/dune.inc b/test/e2e/alcotest-lwt/passing/dune.inc
index 8e743c6..ba86788 100644
--- a/test/e2e/alcotest-lwt/passing/dune.inc
+++ b/test/e2e/alcotest-lwt/passing/dune.inc
@@ -3,7 +3,7 @@
cli_options
)
(libraries alcotest alcotest.stdlib_ext alcotest-lwt lwt lwt.unix)
- (modes native)
+ (modes exe)
(modules
cli_options
)
diff --git a/test/e2e/alcotest/failing/dune.inc b/test/e2e/alcotest/failing/dune.inc
index 87f535d..6482cf2 100644
--- a/test/e2e/alcotest/failing/dune.inc
+++ b/test/e2e/alcotest/failing/dune.inc
@@ -17,7 +17,7 @@
unknown_option
)
(libraries alcotest alcotest.stdlib_ext alcotest.engine)
- (modes native js)
+ (modes exe js)
(modules
bail
check_basic
diff --git a/test/e2e/alcotest/passing/dune.inc b/test/e2e/alcotest/passing/dune.inc
index e8fce33..decb107 100644
--- a/test/e2e/alcotest/passing/dune.inc
+++ b/test/e2e/alcotest/passing/dune.inc
@@ -23,7 +23,7 @@
verbose_newlines
)
(libraries alcotest alcotest.stdlib_ext alcotest.engine)
- (modes native js)
+ (modes exe js)
(modules
and_exit_false
and_exit_true
diff --git a/test/e2e/gen_dune_rules.ml b/test/e2e/gen_dune_rules.ml
index b589ae2..c40e616 100644
--- a/test/e2e/gen_dune_rules.ml
+++ b/test/e2e/gen_dune_rules.ml
@@ -53,7 +53,7 @@ let global_stanza ~libraries ~js filenames =
(pp_sexp_list Fmt.string) bases
Fmt.(list string)
libraries
- (if js then "(modes native js)" else "(modes native)")
+ (if js then "(modes exe js)" else "(modes exe)")
(pp_sexp_list Fmt.string) bases
let example_rule_stanza ~js ~expect_failure filename =
diff --git a/test/e2e/strip_randomness.ml b/test/e2e/strip_randomness.ml
index ee372b0..9d14bde 100644
--- a/test/e2e/strip_randomness.ml
+++ b/test/e2e/strip_randomness.ml
@@ -90,13 +90,17 @@ let stacktrace_replace =
in
let raised_at = stack_trace_line "Raised at "
and called_from = stack_trace_line "Called from " in
+ let called_from_unknown = str "Called from unknown location" |> compile in
fun s ->
match execp called_from s with
| true ->
(* The number of "Called from ..." lines is compiler-dependent, so we
remove them all. *)
- None
- | false -> Some (replace_string ~all:true raised_at s ~by:"<stacktrace>")
+ `None
+ | false ->
+ match execp called_from_unknown s with
+ | true -> `Unknown (replace_string ~all:true called_from_unknown s ~by:"<stacktrace>")
+ | false -> `Some (replace_string ~all:true raised_at s ~by:"<stacktrace>")
let executable_name_normalization =
let open Re in
@@ -109,9 +113,9 @@ let executable_name_normalization =
let () =
let in_channel = open_in Sys.argv.(1) in
let ( >>| ) x f = match x with None -> None | Some x -> Some (f x) in
- let ( >>= ) x f = match x with None -> None | Some x -> f x in
+ let ( >>= ) x f = match x with None -> `None | Some x -> f x in
try
- let rec loop () =
+ let rec loop unknown_last =
let sanitized_line =
Some (input_line in_channel)
>>| uuid_replace
@@ -120,10 +124,13 @@ let () =
>>| executable_name_normalization
>>= stacktrace_replace
in
- (match sanitized_line with
- | Some s -> Printf.printf "%s\n" s
- | None -> ());
- loop ()
+ let unknown_last =
+ match sanitized_line with
+ | `Some s -> Printf.printf "%s\n" s; false
+ | `None -> false
+ | `Unknown s -> if not unknown_last then Printf.printf "%s\n" s; true
+ in
+ loop unknown_last
in
- loop ()
+ loop false
with End_of_file -> close_in in_channel
|