diff options
Diffstat (limited to 'ocamltest')
-rw-r--r-- | ocamltest/Makefile | 20 | ||||
-rw-r--r-- | ocamltest/actions_helpers.ml | 19 | ||||
-rw-r--r-- | ocamltest/actions_helpers.mli | 2 | ||||
-rw-r--r-- | ocamltest/builtin_actions.ml | 29 | ||||
-rw-r--r-- | ocamltest/builtin_actions.mli | 2 | ||||
-rw-r--r-- | ocamltest/builtin_variables.ml | 16 | ||||
-rw-r--r-- | ocamltest/builtin_variables.mli | 8 | ||||
-rw-r--r-- | ocamltest/dune | 3 | ||||
-rw-r--r-- | ocamltest/ocaml_actions.ml | 1 | ||||
-rw-r--r-- | ocamltest/ocaml_variables.ml | 4 | ||||
-rw-r--r-- | ocamltest/ocaml_variables.mli | 1 | ||||
-rw-r--r-- | ocamltest/ocamltest_config.ml.in | 2 | ||||
-rw-r--r-- | ocamltest/ocamltest_config.mli | 3 | ||||
-rw-r--r-- | ocamltest/ocamltest_stdlib.ml | 14 | ||||
-rw-r--r-- | ocamltest/ocamltest_stdlib.mli | 1 |
15 files changed, 105 insertions, 20 deletions
diff --git a/ocamltest/Makefile b/ocamltest/Makefile index bb7c1c0d0e..b552280d4c 100644 --- a/ocamltest/Makefile +++ b/ocamltest/Makefile @@ -52,23 +52,22 @@ endif ifeq "$(UNIX_OR_WIN32)" "win32" ocamlsrcdir := $(shell echo "$(abspath $(shell pwd)/..)" | cygpath -w -f -) + CSC := csc + ifeq "$(HOST:i686-%=i686)" "i686" + CSCFLAGS := /platform:x86 + else + CSCFLAGS := + endif + CSCFLAGS += /nologo /nowarn:1668 else ocamlsrcdir := $(abspath $(shell pwd)/..) + CSC := + CSCFLAGS := endif mkexe := $(MKEXE) ifeq "$(TOOLCHAIN)" "msvc" CPP := $(CPP) 2> nul -CSC := csc -ifeq "$(HOST)" "i686-pc-windows" -CSCFLAGS := /platform:x86 -else -CSCFLAGS := -endif -CSCFLAGS += /nologo /nowarn:1668 -else -CSC := -CSCFLAGS := endif ifeq "$(WITH_OCAMLDOC)" "ocamldoc" @@ -255,6 +254,7 @@ ocamltest_config.ml: ocamltest_config.ml.in Makefile ../Makefile.config $(call SUBST,WITH_OCAMLDOC) \ $(call SUBST,WITH_OCAMLDEBUG) \ $(call SUBST,O) \ + $(call SUBST,A) \ $(call SUBST,S) \ $(call SUBST,NATIVE_COMPILER) \ $(call SUBST,NATDYNLINK) \ diff --git a/ocamltest/actions_helpers.ml b/ocamltest/actions_helpers.ml index 3bf920d39d..840ae5fbe1 100644 --- a/ocamltest/actions_helpers.ml +++ b/ocamltest/actions_helpers.ml @@ -58,7 +58,9 @@ let exit_status_of_variable env variable = (Environments.safe_lookup variable env) with _ -> 0 -let files env = words_of_variable env Builtin_variables.files +let readonly_files env = words_of_variable env Builtin_variables.readonly_files + +let subdirectories env = words_of_variable env Builtin_variables.subdirectories let setup_symlinks test_source_directory build_directory files = let symlink filename = @@ -84,14 +86,25 @@ let setup_symlinks test_source_directory build_directory files = Sys.make_directory build_directory; List.iter f files +let setup_subdirectories source_directory build_directory subdirs = + let full_src_path name = Filename.concat source_directory name in + let full_dst_path name = Filename.concat build_directory name in + let cp_dir name = + Sys.copy_directory (full_src_path name) (full_dst_path name) + in + List.iter cp_dir subdirs + let setup_build_env add_testfile additional_files (_log : out_channel) env = + let source_dir = (test_source_directory env) in let build_dir = (test_build_directory env) in - let some_files = additional_files @ (files env) in + let some_files = additional_files @ (readonly_files env) in let files = if add_testfile then (testfile env) :: some_files else some_files in - setup_symlinks (test_source_directory env) build_dir files; + setup_symlinks source_dir build_dir files; + let subdirs = subdirectories env in + setup_subdirectories source_dir build_dir subdirs; Sys.chdir build_dir; (Result.pass, env) diff --git a/ocamltest/actions_helpers.mli b/ocamltest/actions_helpers.mli index 8c305ff74b..3db31205a1 100644 --- a/ocamltest/actions_helpers.mli +++ b/ocamltest/actions_helpers.mli @@ -33,7 +33,7 @@ val words_of_variable : Environments.t -> Variables.t -> string list val exit_status_of_variable : Environments.t -> Variables.t -> int -val files : Environments.t -> string list +val readonly_files : Environments.t -> string list val setup_symlinks : string -> string -> string list -> unit diff --git a/ocamltest/builtin_actions.ml b/ocamltest/builtin_actions.ml index c1bc015c9c..2cee238016 100644 --- a/ocamltest/builtin_actions.ml +++ b/ocamltest/builtin_actions.ml @@ -238,6 +238,34 @@ let file_exists_action _log env = end let file_exists = make "file-exists" file_exists_action +let copy_action log env = + let do_copy src dst = + let (entry_type, f) = + if Sys.is_directory src + then ("directory", Sys.copy_directory) + else ("file", Sys.copy_file) + in + Printf.fprintf log "Copying %s %s to %s\n%!" entry_type src dst; + f src dst + in + let src = Environments.lookup Builtin_variables.src env in + let dst = Environments.lookup Builtin_variables.dst env in + match (src, dst) with + | (None, _) | (_, None) -> + let reason = reason_with_fallback env "src or dst are undefined" in + let result = Result.fail_with_reason reason in + (result, env) + | (Some src, Some dst) -> + let f = + if String.ends_with ~suffix:"/" dst + then fun src -> do_copy src (dst ^ (Filename.basename src)) + else fun src -> do_copy src dst + in + List.iter f (String.words src); + (Result.pass, env) + +let copy = make "copy" copy_action + let initialize_test_exit_status_variables _log env = Environments.add_bindings [ @@ -281,4 +309,5 @@ let _ = function_sections; naked_pointers; file_exists; + copy; ] diff --git a/ocamltest/builtin_actions.mli b/ocamltest/builtin_actions.mli index aa9ac8f51a..8797377d1c 100644 --- a/ocamltest/builtin_actions.mli +++ b/ocamltest/builtin_actions.mli @@ -49,3 +49,5 @@ val script : Actions.t val check_program_output : Actions.t val file_exists : Actions.t + +val copy : Actions.t diff --git a/ocamltest/builtin_variables.ml b/ocamltest/builtin_variables.ml index df5bb461a6..c6b19d0d8d 100644 --- a/ocamltest/builtin_variables.ml +++ b/ocamltest/builtin_variables.ml @@ -31,14 +31,16 @@ let cwd = Variables.make ("cwd", let commandline = Variables.make ("commandline", "Specify the commandline of a tool") +let dst = Variables.make ("dst", "Location where to copy files and directories") + let exit_status = Variables.make ("exit_status", "Expected program exit status") let file = Variables.make ("file", "File whose existence should be tested") -let files = Variables.make ("files", - "Files used by the tests") +let readonly_files = Variables.make ("readonly_files", + "Files which are only read by the tests") let make = Variables.make ("MAKE", "Command used to invoke make") @@ -79,10 +81,15 @@ let skip_header_bytes = let script = Variables.make ("script", "External script to run") +let src = Variables.make ("src", "Files and directories to copy") + let stdin = Variables.make ("stdin", "Default standard input") let stdout = Variables.make ("stdout", "Default standard output") let stderr = Variables.make ("stderr", "Default standard error") +let subdirectories = Variables.make ("subdirectories", + "Subdirectories to copy recursively from test source to test build directory") + let test_build_directory = Variables.make ("test_build_directory", "Directory for files produced during a test") @@ -112,9 +119,10 @@ let _ = List.iter Variables.register_variable arguments; cwd; commandline; + dst; exit_status; file; - files; + readonly_files; make; ocamltest_response; ocamltest_log; @@ -122,12 +130,14 @@ let _ = List.iter Variables.register_variable program; program2; reason; reference; + src; skip_header_lines; skip_header_bytes; script; stdin; stdout; stderr; + subdirectories; test_build_directory; test_file; test_source_directory; diff --git a/ocamltest/builtin_variables.mli b/ocamltest/builtin_variables.mli index b28553159e..b7ebf56fea 100644 --- a/ocamltest/builtin_variables.mli +++ b/ocamltest/builtin_variables.mli @@ -23,11 +23,13 @@ val cwd : Variables.t val commandline : Variables.t +val dst : Variables.t + val exit_status : Variables.t val file : Variables.t -val files : Variables.t +val readonly_files : Variables.t val make : Variables.t @@ -51,10 +53,14 @@ val skip_header_bytes : Variables.t val script : Variables.t +val src : Variables.t + val stdin : Variables.t val stdout : Variables.t val stderr : Variables.t +val subdirectories : Variables.t + val test_build_directory : Variables.t val test_build_directory_prefix : Variables.t diff --git a/ocamltest/dune b/ocamltest/dune index f10cab7988..518c335959 100644 --- a/ocamltest/dune +++ b/ocamltest/dune @@ -29,8 +29,7 @@ ../Makefile.common ../Makefile.best_binaries Makefile - ./ocamltest_config.ml.in - ./getocamloptdefaultflags) + ./ocamltest_config.ml.in) (action (run make %{targets} COMPUTE_DEPS=false))) ;; FIXME: handle UNIX_OR_WIN32 or something similar diff --git a/ocamltest/ocaml_actions.ml b/ocamltest/ocaml_actions.ml index 1eb6fd7922..ce3798a3ed 100644 --- a/ocamltest/ocaml_actions.ml +++ b/ocamltest/ocaml_actions.ml @@ -1109,6 +1109,7 @@ let config_variables _log env = Ocaml_variables.shared_library_cflags, Ocamltest_config.shared_library_cflags; Ocaml_variables.objext, Ocamltest_config.objext; + Ocaml_variables.libext, Ocamltest_config.libext; Ocaml_variables.asmext, Ocamltest_config.asmext; Ocaml_variables.sharedobjext, Ocamltest_config.sharedobjext; Ocaml_variables.ocamlc_default_flags, diff --git a/ocamltest/ocaml_variables.ml b/ocamltest/ocaml_variables.ml index 78c138ef90..616b03e433 100644 --- a/ocamltest/ocaml_variables.ml +++ b/ocamltest/ocaml_variables.ml @@ -123,6 +123,9 @@ let nativecc_libs = make ("nativecc_libs", let objext = make ("objext", "Extension of object files") +let libext = make ("libext", + "Extension of library files") + let asmext = make ("asmext", "Extension of assembly files") @@ -260,6 +263,7 @@ let _ = List.iter register_variable modules; nativecc_libs; objext; + libext; asmext; ocamlc_byte; ocamlopt_byte; diff --git a/ocamltest/ocaml_variables.mli b/ocamltest/ocaml_variables.mli index 5487ea2f7a..3346c433b3 100644 --- a/ocamltest/ocaml_variables.mli +++ b/ocamltest/ocaml_variables.mli @@ -76,6 +76,7 @@ val nativecc_libs : Variables.t (** Libraries to link with for native code *) val objext : Variables.t +val libext : Variables.t val asmext : Variables.t val ocamlc_byte : Variables.t diff --git a/ocamltest/ocamltest_config.ml.in b/ocamltest/ocamltest_config.ml.in index defcb88ed3..db4dd221ad 100644 --- a/ocamltest/ocamltest_config.ml.in +++ b/ocamltest/ocamltest_config.ml.in @@ -37,6 +37,8 @@ let str = %%str%% let objext = "%%O%%" +let libext = "%%A%%" + let asmext = "%%S%%" let system = "%%SYSTEM%%" diff --git a/ocamltest/ocamltest_config.mli b/ocamltest/ocamltest_config.mli index 7262b0dd90..3ce8c9558e 100644 --- a/ocamltest/ocamltest_config.mli +++ b/ocamltest/ocamltest_config.mli @@ -49,6 +49,9 @@ val str : bool val objext : string (** Extension of object files *) +val libext : string +(** Extension of library files *) + val asmext : string (** Extension of assembly files *) diff --git a/ocamltest/ocamltest_stdlib.ml b/ocamltest/ocamltest_stdlib.ml index 8f2478a6b2..274e234527 100644 --- a/ocamltest/ocamltest_stdlib.ml +++ b/ocamltest/ocamltest_stdlib.ml @@ -185,6 +185,20 @@ module Sys = struct with_output_file ~bin:true dest @@ fun oc -> copy_chan ic oc + let rec copy_directory src dst = + let full_src_path name = Filename.concat src name in + let full_dst_path name = Filename.concat dst name in + make_directory dst; + let content = Array.to_list (readdir src) in + let is_directory d = is_directory (full_src_path d) in + let (subdirs, files) = List.partition is_directory content in + let cp_file name = copy_file (full_src_path name) (full_dst_path name) in + List.iter cp_file files; + let cp_dir name = + copy_directory (full_src_path name) (full_dst_path name) + in + List.iter cp_dir subdirs + let force_remove file = if file_exists file then remove file diff --git a/ocamltest/ocamltest_stdlib.mli b/ocamltest/ocamltest_stdlib.mli index f28bf05a3b..cdd14f7e4a 100644 --- a/ocamltest/ocamltest_stdlib.mli +++ b/ocamltest/ocamltest_stdlib.mli @@ -53,6 +53,7 @@ module Sys : sig val dump_file : out_channel -> ?prefix:string -> string -> unit val copy_chan : in_channel -> out_channel -> unit val copy_file : string -> string -> unit + val copy_directory : string -> string -> unit val force_remove : string -> unit val with_chdir : string -> (unit -> 'a) -> 'a val getenv_with_default_value : string -> string -> string |