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

Allow expect_tests to be DCE by jsoo .. #56

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions runtime/ppx_expect_runtime.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ module Write_corrected_file = Write_corrected_file
module Make_test_block = Test_block.Make
module For_external = Test_block.For_external
module For_apply_style = Test_spec.For_apply_style

let tests_should_run = Test_block.tests_should_run
8 changes: 8 additions & 0 deletions runtime/test_block.ml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ module Configured (C : Expect_test_config_types.S) = struct
;;
end

let tests_should_run =
try
ignore (Stdlib.Sys.getenv "FORCE_DROP_INLINE_TEST" : string);
false
with
| Not_found -> true
;;

(* The expect test currently being executed and some info we print if the program
crashes in the middle of a test. *)
module Current_test : sig
Expand Down
2 changes: 2 additions & 0 deletions runtime/test_block.mli
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ module For_external : sig
-> bool
end

val tests_should_run : bool

(** Action to perform when exiting from a program that runs expect tests. Alerts of
runtime failure if the program exited while executing an expect test. *)
val at_exit : unit -> unit
1 change: 1 addition & 0 deletions src/ppx_expect.ml
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ let transform_let_expect ~trailing_location ~tags ~expected_exn ~description ~lo
match Ppx_inline_test_lib.testing with
| `Not_testing -> ()
| `Testing _ ->
if Ppx_expect_runtime.tests_should_run then
let module Ppx_expect_test_block =
Ppx_expect_runtime.Make_test_block [@alert "-ppx_expect_runtime"]
(Expect_test_config)
Expand Down