ocamltest: add the cd builtin action
This gives tests control over ocamltest's current working directorymaster
parent
dd34dd5350
commit
41bd4f2ebf
|
@ -37,6 +37,19 @@ let fail = make
|
|||
let result = Result.fail_with_reason "The fail action always fails." in
|
||||
(result, env))
|
||||
|
||||
let cd = make
|
||||
"cd"
|
||||
(fun _log env ->
|
||||
let cwd = Environments.safe_lookup Builtin_variables.cwd env in
|
||||
begin
|
||||
try
|
||||
Sys.chdir cwd; (Result.pass, env)
|
||||
with _ ->
|
||||
let reason = "Could not chidir to \"" ^ cwd ^ "\"" in
|
||||
let result = Result.fail_with_reason reason in
|
||||
(result, env)
|
||||
end)
|
||||
|
||||
let dumpenv = make
|
||||
"dumpenv"
|
||||
(fun log env ->
|
||||
|
@ -140,6 +153,7 @@ let _ =
|
|||
pass;
|
||||
skip;
|
||||
fail;
|
||||
cd;
|
||||
dumpenv;
|
||||
libunix;
|
||||
libwin32unix;
|
||||
|
|
|
@ -27,6 +27,9 @@ open Variables (* Should not be necessary with a ppx *)
|
|||
let arguments = make ("arguments",
|
||||
"Arguments passed to executed programs and scripts")
|
||||
|
||||
let cwd = make ("cwd",
|
||||
"Used to change current working directory, but not updated")
|
||||
|
||||
let exit_status = make ("exit_status",
|
||||
"Expected program exit status")
|
||||
|
||||
|
@ -96,6 +99,7 @@ let test_fail = make ("TEST_FAIL",
|
|||
let _ = List.iter register_variable
|
||||
[
|
||||
arguments;
|
||||
cwd;
|
||||
exit_status;
|
||||
files;
|
||||
ocamltest_response;
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
val arguments : Variables.t
|
||||
|
||||
val cwd : Variables.t
|
||||
|
||||
val exit_status : Variables.t
|
||||
|
||||
val files : Variables.t
|
||||
|
|
Loading…
Reference in New Issue