diff options
author | Sébastien Hinderer <Sebastien.Hinderer@inria.fr> | 2018-01-27 15:03:27 +0100 |
---|---|---|
committer | Sébastien Hinderer <Sebastien.Hinderer@inria.fr> | 2018-01-31 09:14:43 +0100 |
commit | a828e36d37b5887b872514de40783210b2a5c65b (patch) | |
tree | f626258adc545a43b3e971a60965de0496124fe1 | |
parent | 3ba9315ebcb23ccd37a2cc71e38fec8d66880fa6 (diff) | |
download | ocaml-a828e36d37b5887b872514de40783210b2a5c65b.tar.gz |
ocamltest: introduce the ocaml_files module
-rw-r--r-- | ocamltest/.depend | 7 | ||||
-rw-r--r-- | ocamltest/Makefile | 1 | ||||
-rw-r--r-- | ocamltest/ocaml_actions.ml | 92 | ||||
-rw-r--r-- | ocamltest/ocaml_files.ml | 66 | ||||
-rw-r--r-- | ocamltest/ocaml_files.mli | 43 |
5 files changed, 137 insertions, 72 deletions
diff --git a/ocamltest/.depend b/ocamltest/.depend index ff3cfaf859..b7e77d349b 100644 --- a/ocamltest/.depend +++ b/ocamltest/.depend @@ -45,17 +45,20 @@ main.cmx : tsl_semantics.cmx tsl_parser.cmx tsl_lexer.cmx tests.cmx \ actions_helpers.cmx actions.cmx main.cmi main.cmi : ocaml_actions.cmo : variables.cmi ocamltest_stdlib.cmi ocamltest_config.cmi \ - ocaml_variables.cmi ocaml_modifiers.cmi ocaml_backends.cmi filetype.cmi \ + ocaml_variables.cmi ocaml_files.cmi ocaml_backends.cmi filetype.cmi \ filecompare.cmi environments.cmi builtin_variables.cmi \ actions_helpers.cmi actions.cmi ocaml_actions.cmi ocaml_actions.cmx : variables.cmx ocamltest_stdlib.cmx ocamltest_config.cmx \ - ocaml_variables.cmx ocaml_modifiers.cmx ocaml_backends.cmx filetype.cmx \ + ocaml_variables.cmx ocaml_files.cmx ocaml_backends.cmx filetype.cmx \ filecompare.cmx environments.cmx builtin_variables.cmx \ actions_helpers.cmx actions.cmx ocaml_actions.cmi ocaml_actions.cmi : actions.cmi ocaml_backends.cmo : ocamltest_stdlib.cmi ocaml_backends.cmi ocaml_backends.cmx : ocamltest_stdlib.cmx ocaml_backends.cmi ocaml_backends.cmi : ocamltest_stdlib.cmi +ocaml_files.cmo : ocamltest_stdlib.cmi ocamltest_config.cmi ocaml_files.cmi +ocaml_files.cmx : ocamltest_stdlib.cmx ocamltest_config.cmx ocaml_files.cmi +ocaml_files.cmi : ocaml_modifiers.cmo : ocamltest_stdlib.cmi ocamltest_config.cmi \ ocaml_variables.cmi environments.cmi builtin_variables.cmi \ ocaml_modifiers.cmi diff --git a/ocamltest/Makefile b/ocamltest/Makefile index 1da1e7565d..eb5e0cc7c6 100644 --- a/ocamltest/Makefile +++ b/ocamltest/Makefile @@ -64,6 +64,7 @@ ocaml_plugin := \ ocaml_backends.mli ocaml_backends.ml \ ocaml_variables.mli ocaml_variables.ml \ ocaml_modifiers.mli ocaml_modifiers.ml \ + ocaml_files.mli ocaml_files.ml \ ocaml_actions.mli ocaml_actions.ml \ ocaml_tests.mli ocaml_tests.ml diff --git a/ocamltest/ocaml_actions.ml b/ocamltest/ocaml_actions.ml index 6236b420b9..b76e97e46e 100644 --- a/ocamltest/ocaml_actions.ml +++ b/ocamltest/ocaml_actions.ml @@ -20,72 +20,24 @@ open Actions (* Compilers and flags *) -let ocamlsrcdir () = - try Sys.getenv "OCAMLSRCDIR" - with Not_found -> Ocamltest_config.ocamlsrcdir - -type runtime_variant = - | Normal - | Debug - | Instrumented - -let runtime_variant() = - let use_runtime = try Sys.getenv "USE_RUNTIME" with Not_found -> "" in - if use_runtime="d" then Debug - else if use_runtime="i" then Instrumented - else Normal - -let ocamlrun ocamlsrcdir = - let runtime = match runtime_variant () with - | Normal -> "ocamlrun" - | Debug -> "ocamlrund" - | Instrumented -> "ocamlruni" in - let ocamlrunfile = Filename.mkexe runtime in - Filename.make_path [ocamlsrcdir; "byterun"; ocamlrunfile] - -let ocamlc ocamlsrcdir = - Filename.make_path [ocamlsrcdir; "ocamlc"] - -let ocaml ocamlsrcdir = - Filename.make_path [ocamlsrcdir; "ocaml"] - let ocamlc_dot_byte ocamlsrcdir = - let ocamlrun = ocamlrun ocamlsrcdir in - let ocamlc = ocamlc ocamlsrcdir in + let ocamlrun = Ocaml_files.ocamlrun ocamlsrcdir in + let ocamlc = Ocaml_files.ocamlc ocamlsrcdir in ocamlrun ^ " " ^ ocamlc -let ocamlc_dot_opt ocamlsrcdir = - Filename.make_path [ocamlsrcdir; "ocamlc.opt"] - -let ocamlopt ocamlsrcdir = - Filename.make_path [ocamlsrcdir; "ocamlopt"] - let ocamlopt_dot_byte ocamlsrcdir = - let ocamlrun = ocamlrun ocamlsrcdir in - let ocamlopt = ocamlopt ocamlsrcdir in + let ocamlrun = Ocaml_files.ocamlrun ocamlsrcdir in + let ocamlopt = Ocaml_files.ocamlopt ocamlsrcdir in ocamlrun ^ " " ^ ocamlopt -let ocamlopt_dot_opt ocamlsrcdir = - Filename.make_path [ocamlsrcdir; "ocamlopt.opt"] - let ocaml_dot_byte ocamlsrcdir = - let ocamlrun = ocamlrun ocamlsrcdir in - let ocaml = ocaml ocamlsrcdir in + let ocamlrun = Ocaml_files.ocamlrun ocamlsrcdir in + let ocaml = Ocaml_files.ocaml ocamlsrcdir in ocamlrun ^ " " ^ ocaml -let ocaml_dot_opt ocamlsrcdir = - Filename.make_path [ocamlsrcdir; Filename.mkexe "ocamlnat"] - -let cmpbyt ocamlsrcdir = - Filename.make_path [ocamlsrcdir; "tools"; "cmpbyt"] - -let expect_program ocamlsrcdir = - Filename.make_path - [ocamlsrcdir; "testsuite"; "tools"; Filename.mkexe "expect_test"] - let expect_command ocamlsrcdir = - let ocamlrun = ocamlrun ocamlsrcdir in - let expect_test = expect_program ocamlsrcdir in + let ocamlrun = Ocaml_files.ocamlrun ocamlsrcdir in + let expect_test = Ocaml_files.expect_test ocamlsrcdir in ocamlrun ^ " " ^ expect_test let stdlib ocamlsrcdir = @@ -110,15 +62,15 @@ let c_includes_flags ocamlsrcdir = let use_runtime backend ocamlsrcdir = match backend with | Sys.Bytecode -> - let ocamlrun = ocamlrun ocamlsrcdir in + let ocamlrun = Ocaml_files.ocamlrun ocamlsrcdir in "-use-runtime " ^ ocamlrun | _ -> "" let runtime_variant_flags backend ocamlsrcdir = - let variant = runtime_variant() in - if variant=Normal then "" + let variant = Ocaml_files.runtime_variant() in + if variant=Ocaml_files.Normal then "" else begin - let variant_str = if variant=Debug then "d" else "i" in + let variant_str = if variant=Ocaml_files.Debug then "d" else "i" in let backend_lib = match backend with | Sys.Bytecode -> "byterun" | Sys.Native -> "asmrun" @@ -154,7 +106,7 @@ let ocamlc_byte_compiler = let ocamlc_opt_compiler = { - compiler_name = ocamlc_dot_opt; + compiler_name = Ocaml_files.ocamlc_dot_opt; compiler_flags = ""; compiler_directory = "ocamlc.opt"; compiler_backend = Sys.Bytecode; @@ -178,7 +130,7 @@ let ocamlopt_byte_compiler = let ocamlopt_opt_compiler = { - compiler_name = ocamlopt_dot_opt; + compiler_name = Ocaml_files.ocamlopt_dot_opt; compiler_flags = ""; compiler_directory = "ocamlopt.opt"; compiler_backend = Sys.Native; @@ -200,7 +152,7 @@ let ocaml_compiler = { } let ocamlnat_compiler = { - compiler_name = ocaml_dot_opt; + compiler_name = Ocaml_files.ocamlnat; compiler_flags = "-S"; (* Keep intermediate assembly files *) compiler_directory = "ocamlnat"; compiler_backend = Sys.Native; @@ -436,7 +388,7 @@ let compile_test_program program_variable compiler log env = ] env in if Sys.file_exists compiler_output_filename then Sys.remove compiler_output_filename; - let ocamlsrcdir = ocamlsrcdir () in + let ocamlsrcdir = Ocaml_files.ocamlsrcdir () in let compilername = compiler.compiler_name ocamlsrcdir in let source_modules = Actions_helpers.words_of_variable env Ocaml_variables.source_modules in @@ -509,7 +461,7 @@ let run_expect_twice ocamlsrcdir input_file log env = ) let run_expect log env = - let ocamlsrcdir = ocamlsrcdir () in + let ocamlsrcdir = Ocaml_files.ocamlsrcdir () in let input_file = Actions_helpers.testfile env in run_expect_twice ocamlsrcdir input_file log env @@ -584,15 +536,15 @@ let compare_programs backend comparison_tool log env = end else really_compare_programs backend comparison_tool log env let make_bytecode_programs_comparison_tool ocamlsrcdir = - let ocamlrun = ocamlrun ocamlsrcdir in - let cmpbyt = cmpbyt ocamlsrcdir in + let ocamlrun = Ocaml_files.ocamlrun ocamlsrcdir in + let cmpbyt = Ocaml_files.cmpbyt ocamlsrcdir in let tool_name = ocamlrun ^ " " ^ cmpbyt in Filecompare.make_comparison_tool tool_name "" let native_programs_comparison_tool = Filecompare.default_comparison_tool let compare_bytecode_programs_code log env = - let ocamlsrcdir = ocamlsrcdir () in + let ocamlsrcdir = Ocaml_files.ocamlsrcdir () in let bytecode_programs_comparison_tool = make_bytecode_programs_comparison_tool ocamlsrcdir in compare_programs Sys.Bytecode bytecode_programs_comparison_tool log env @@ -709,7 +661,7 @@ let run_test_program_in_toplevel toplevel log env = end in if Sys.file_exists compiler_output then Sys.remove compiler_output; - let ocamlsrcdir = ocamlsrcdir () in + let ocamlsrcdir = Ocaml_files.ocamlsrcdir () in let compiler = match toplevel.compiler_backend with | Sys.Native -> ocamlopt_byte_compiler | Sys.Bytecode -> ocamlc_byte_compiler @@ -775,7 +727,7 @@ let config_variables _log env = Environments.add_bindings Ocamltest_config.ocamlc_default_flags; Ocaml_variables.ocamlopt_default_flags, Ocamltest_config.ocamlopt_default_flags; - Ocaml_variables.ocamlsrcdir, ocamlsrcdir(); + Ocaml_variables.ocamlsrcdir, Ocaml_files.ocamlsrcdir(); Ocaml_variables.os_type, Sys.os_type; ] env diff --git a/ocamltest/ocaml_files.ml b/ocamltest/ocaml_files.ml new file mode 100644 index 0000000000..6ff3497f42 --- /dev/null +++ b/ocamltest/ocaml_files.ml @@ -0,0 +1,66 @@ +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Sebastien Hinderer, projet Gallium, INRIA Paris *) +(* *) +(* Copyright 2018 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) + +(* Locations of files and directories inside the OCaml source tree *) + +open Ocamltest_stdlib + +let ocamlsrcdir () = + try Sys.getenv "OCAMLSRCDIR" + with Not_found -> Ocamltest_config.ocamlsrcdir + +type runtime_variant = + | Normal + | Debug + | Instrumented + +let runtime_variant() = + let use_runtime = try Sys.getenv "USE_RUNTIME" with Not_found -> "" in + if use_runtime="d" then Debug + else if use_runtime="i" then Instrumented + else Normal + +let ocamlrun ocamlsrcdir = + let runtime = match runtime_variant () with + | Normal -> "ocamlrun" + | Debug -> "ocamlrund" + | Instrumented -> "ocamlruni" in + let ocamlrunfile = Filename.mkexe runtime in + Filename.make_path [ocamlsrcdir; "byterun"; ocamlrunfile] + +let ocamlc ocamlsrcdir = + Filename.make_path [ocamlsrcdir; "ocamlc"] + +let ocaml ocamlsrcdir = + Filename.make_path [ocamlsrcdir; "ocaml"] + +let ocamlc_dot_opt ocamlsrcdir = + Filename.make_path [ocamlsrcdir; "ocamlc.opt"] + +let ocamlopt ocamlsrcdir = + Filename.make_path [ocamlsrcdir; "ocamlopt"] + +let ocamlopt_dot_opt ocamlsrcdir = + Filename.make_path [ocamlsrcdir; "ocamlopt.opt"] + +let ocamlnat ocamlsrcdir = + Filename.make_path [ocamlsrcdir; Filename.mkexe "ocamlnat"] + +let cmpbyt ocamlsrcdir = + Filename.make_path [ocamlsrcdir; "tools"; "cmpbyt"] + +let expect_test ocamlsrcdir = + Filename.make_path + [ocamlsrcdir; "testsuite"; "tools"; Filename.mkexe "expect_test"] diff --git a/ocamltest/ocaml_files.mli b/ocamltest/ocaml_files.mli new file mode 100644 index 0000000000..143b84eaf9 --- /dev/null +++ b/ocamltest/ocaml_files.mli @@ -0,0 +1,43 @@ +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Sebastien Hinderer, projet Gallium, INRIA Paris *) +(* *) +(* Copyright 2018 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) + +(* Locations of files and directories inside the OCaml source tree *) + +val ocamlsrcdir : unit -> string + +type runtime_variant = + | Normal + | Debug + | Instrumented + +val runtime_variant : unit -> runtime_variant + +val ocamlrun : string -> string + +val ocamlc : string -> string + +val ocaml : string -> string + +val ocamlc_dot_opt : string -> string + +val ocamlopt : string -> string + +val ocamlopt_dot_opt : string -> string + +val ocamlnat : string -> string + +val cmpbyt : string -> string + +val expect_test : string -> string |