ocamltest: introduce the action_name variable
This variable makes the name of the currently executed action available in the ocamltest environment.master
parent
529b9132d8
commit
0912ecde6f
|
@ -21,14 +21,17 @@ ocamltest_stdlib_stubs.$(O): ocamltest_stdlib_stubs.c \
|
||||||
../runtime/caml/alloc.h ../runtime/caml/signals.h \
|
../runtime/caml/alloc.h ../runtime/caml/signals.h \
|
||||||
../runtime/caml/osdeps.h ../runtime/caml/memory.h
|
../runtime/caml/osdeps.h ../runtime/caml/memory.h
|
||||||
actions.cmo : \
|
actions.cmo : \
|
||||||
|
variables.cmi \
|
||||||
result.cmi \
|
result.cmi \
|
||||||
environments.cmi \
|
environments.cmi \
|
||||||
actions.cmi
|
actions.cmi
|
||||||
actions.cmx : \
|
actions.cmx : \
|
||||||
|
variables.cmx \
|
||||||
result.cmx \
|
result.cmx \
|
||||||
environments.cmx \
|
environments.cmx \
|
||||||
actions.cmi
|
actions.cmi
|
||||||
actions.cmi : \
|
actions.cmi : \
|
||||||
|
variables.cmi \
|
||||||
result.cmi \
|
result.cmi \
|
||||||
environments.cmi
|
environments.cmi
|
||||||
actions_helpers.cmo : \
|
actions_helpers.cmo : \
|
||||||
|
|
|
@ -25,6 +25,8 @@ type t = {
|
||||||
|
|
||||||
let name a = a.name
|
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 make n c = { name = n; body = c; hook = None }
|
||||||
|
|
||||||
let update action code = { action with body = code }
|
let update action code = { action with body = code }
|
||||||
|
@ -61,6 +63,7 @@ let run log env action =
|
||||||
let code = match action.hook with
|
let code = match action.hook with
|
||||||
| None -> action.body
|
| None -> action.body
|
||||||
| Some code -> code in
|
| Some code -> code in
|
||||||
|
let env = Environments.add action_name action.name env in
|
||||||
code log env
|
code log env
|
||||||
|
|
||||||
module ActionSet = Set.Make
|
module ActionSet = Set.Make
|
||||||
|
@ -68,3 +71,5 @@ module ActionSet = Set.Make
|
||||||
type nonrec t = t
|
type nonrec t = t
|
||||||
let compare = compare
|
let compare = compare
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
let _ = Variables.register_variable action_name
|
||||||
|
|
|
@ -21,6 +21,8 @@ type t
|
||||||
|
|
||||||
val name : t -> string
|
val name : t -> string
|
||||||
|
|
||||||
|
val action_name : Variables.t
|
||||||
|
|
||||||
val update : t -> code -> t
|
val update : t -> code -> t
|
||||||
|
|
||||||
val make : string -> code -> t
|
val make : string -> code -> t
|
||||||
|
|
Loading…
Reference in New Issue