From 0912ecde6f71012a506d136f219430ae6edfac77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Hinderer?= Date: Wed, 5 Jun 2019 14:11:44 +0200 Subject: [PATCH] ocamltest: introduce the action_name variable This variable makes the name of the currently executed action available in the ocamltest environment. --- ocamltest/.depend | 3 +++ ocamltest/actions.ml | 5 +++++ ocamltest/actions.mli | 2 ++ 3 files changed, 10 insertions(+) diff --git a/ocamltest/.depend b/ocamltest/.depend index 8ffbcd6e5..320fe4f51 100644 --- a/ocamltest/.depend +++ b/ocamltest/.depend @@ -21,14 +21,17 @@ ocamltest_stdlib_stubs.$(O): ocamltest_stdlib_stubs.c \ ../runtime/caml/alloc.h ../runtime/caml/signals.h \ ../runtime/caml/osdeps.h ../runtime/caml/memory.h actions.cmo : \ + variables.cmi \ result.cmi \ environments.cmi \ actions.cmi actions.cmx : \ + variables.cmx \ result.cmx \ environments.cmx \ actions.cmi actions.cmi : \ + variables.cmi \ result.cmi \ environments.cmi actions_helpers.cmo : \ diff --git a/ocamltest/actions.ml b/ocamltest/actions.ml index ef0cee2fd..cb436a604 100644 --- a/ocamltest/actions.ml +++ b/ocamltest/actions.ml @@ -25,6 +25,8 @@ type t = { let name a = a.name +let action_name = Variables.make ("action_name", "Name of the current action") + let make n c = { name = n; body = c; hook = None } let update action code = { action with body = code } @@ -61,6 +63,7 @@ let run log env action = let code = match action.hook with | None -> action.body | Some code -> code in + let env = Environments.add action_name action.name env in code log env module ActionSet = Set.Make @@ -68,3 +71,5 @@ module ActionSet = Set.Make type nonrec t = t let compare = compare end) + +let _ = Variables.register_variable action_name diff --git a/ocamltest/actions.mli b/ocamltest/actions.mli index 9735af27d..bdcf4258c 100644 --- a/ocamltest/actions.mli +++ b/ocamltest/actions.mli @@ -21,6 +21,8 @@ type t val name : t -> string +val action_name : Variables.t + val update : t -> code -> t val make : string -> code -> t