summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Hinderer <Sebastien.Hinderer@inria.fr>2017-10-09 13:51:25 +0200
committerSébastien Hinderer <Sebastien.Hinderer@inria.fr>2017-10-09 17:09:53 +0200
commitcee23d79a9eb158d8141162d161b80de105ac9db (patch)
tree341259c4b310f92b09016e03b57ed0b4ebf29df6
parent6bf807936af654ecb00ec4acdba61e297e27ec59 (diff)
downloadocaml-cee23d79a9eb158d8141162d161b80de105ac9db.tar.gz
ocamltest: add actions to test whether tests are run on Unix or Windows
-rw-r--r--ocamltest/Makefile3
-rw-r--r--ocamltest/builtin_actions.ml28
-rw-r--r--ocamltest/builtin_actions.mli3
-rw-r--r--ocamltest/ocamltest_config.ml.in2
-rw-r--r--ocamltest/ocamltest_config.mli3
5 files changed, 39 insertions, 0 deletions
diff --git a/ocamltest/Makefile b/ocamltest/Makefile
index 64c2411250..b674e15d6b 100644
--- a/ocamltest/Makefile
+++ b/ocamltest/Makefile
@@ -18,8 +18,10 @@
include ../config/Makefile
ifeq "$(UNIX_OR_WIN32)" "win32"
+ unix := false
ocamlsrcdir := $(shell echo "$(abspath $(shell pwd)/..)"|cygpath -m -f -)
else
+ unix := true
ocamlsrcdir := $(abspath $(shell pwd)/..)
endif
@@ -153,6 +155,7 @@ ocamltest.opt$(EXE): $(native_modules)
ocamltest_config.ml: ocamltest_config.ml.in
sed \
-e 's|@@ARCH@@|$(ARCH)|' \
+ -e 's|@@UNIX@@|$(unix)|' \
-e 's|@@CPP@@|$(CPP)|' \
-e 's|@@OCAMLCDEFAULTFLAGS@@|$(ocamlcdefaultflags)|' \
-e 's|@@OCAMLOPTDEFAULTFLAGS@@|$(ocamloptdefaultflags)|' \
diff --git a/ocamltest/builtin_actions.ml b/ocamltest/builtin_actions.ml
index 752e06f340..105a804b32 100644
--- a/ocamltest/builtin_actions.ml
+++ b/ocamltest/builtin_actions.ml
@@ -41,6 +41,32 @@ let fail = {
action_body = fun _log _env -> Fail "The fail action always fails."
}
+let unix = {
+ action_name = "unix";
+ action_environment = env_id;
+ action_body = fun log env ->
+ if Ocamltest_config.unix then
+ begin
+ Printf.fprintf log
+ "The unix action succeeds because we are on a Unix system.\n%!";
+ Pass env
+ end else
+ Skip "The unix action skips because we are on a Windows system."
+}
+
+let windows = {
+ action_name = "windows";
+ action_environment = env_id;
+ action_body = fun log env ->
+ if not Ocamltest_config.unix then
+ begin
+ Printf.fprintf log
+ "The windows action succeeds because we are on a Windows system.\n%!";
+ Pass env
+ end else
+ Skip "The windows action skips because we are on a Unix system."
+}
+
let run_command
?(stdin_variable=Builtin_variables.stdin)
?(stdout_variable=Builtin_variables.stdout)
@@ -869,6 +895,8 @@ let _ =
pass;
skip;
fail;
+ unix;
+ windows;
compile_bytecode_with_bytecode_compiler;
compile_bytecode_with_native_compiler;
compile_native_with_bytecode_compiler;
diff --git a/ocamltest/builtin_actions.mli b/ocamltest/builtin_actions.mli
index ff12d2cfb7..74ea5e8cbb 100644
--- a/ocamltest/builtin_actions.mli
+++ b/ocamltest/builtin_actions.mli
@@ -19,6 +19,9 @@ val pass : Actions.t
val skip : Actions.t
val fail : Actions.t
+val unix : Actions.t
+val windows : Actions.t
+
val compile_bytecode_with_bytecode_compiler : Actions.t
val compile_bytecode_with_native_compiler : Actions.t
val compile_native_with_bytecode_compiler : Actions.t
diff --git a/ocamltest/ocamltest_config.ml.in b/ocamltest/ocamltest_config.ml.in
index 05f4b1eb5e..19be897071 100644
--- a/ocamltest/ocamltest_config.ml.in
+++ b/ocamltest/ocamltest_config.ml.in
@@ -17,6 +17,8 @@
let arch = "@@ARCH@@"
+let unix = @@UNIX@@
+
let c_preprocessor = "@@CPP@@"
let ocamlsrcdir = "@@OCAMLSRCDIR@@"
diff --git a/ocamltest/ocamltest_config.mli b/ocamltest/ocamltest_config.mli
index 51531c9f5e..1c480ee7b5 100644
--- a/ocamltest/ocamltest_config.mli
+++ b/ocamltest/ocamltest_config.mli
@@ -18,6 +18,9 @@
val arch : string
(** Architecture for the native compiler, "none" if it is disabled *)
+val unix : bool
+(** [true] on Unix systems, [false] on non-Unix systems *)
+
val c_preprocessor : string
(** Command to use to invoke the C preprocessor *)