From da492c9df8c3f387ccb06b66c7b7c0d9d598a217 Mon Sep 17 00:00:00 2001 From: hugo heuzard Date: Tue, 25 Jun 2024 17:01:28 +0200 Subject: [PATCH] tune testsuite for msvc --- testsuite/findlibonly_test_header.ml | 2 +- testsuite/internal.ml | 24 ++++++++++------------ testsuite/ocamlbuild_test.ml | 30 ++++++++++++++++++---------- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/testsuite/findlibonly_test_header.ml b/testsuite/findlibonly_test_header.ml index 50863015..7370a17d 100644 --- a/testsuite/findlibonly_test_header.ml +++ b/testsuite/findlibonly_test_header.ml @@ -1,4 +1,4 @@ -match Sys.command "ocamlfind ocamlc -version" with +match sys_command "ocamlfind ocamlc -version" with | 0 -> () | _ -> prerr_endline "Having ocamlfind installed is a prerequisite \ diff --git a/testsuite/internal.ml b/testsuite/internal.ml index f974e52a..0b9ac319 100644 --- a/testsuite/internal.ml +++ b/testsuite/internal.ml @@ -91,7 +91,7 @@ let () = test "BasicNativeTree" "dummy.ml"; "dummy.ml.depends"; "dummy.native"; - "dummy.o"; + "dummy" -.- o; "_log"]))] ~targets:("dummy.native",[]) ();; @@ -250,9 +250,7 @@ let () = test "OutputObj" ~description:"output_obj targets for native and bytecode (PR #6049)" ~requirements:ocamlopt_available ~tree:[T.f "hello.ml" ~content:{|print_endline "Hello, World!"|}] - ~targets:("hello.byte.o",["hello.byte.c";"hello.native.o"]) ();; - -let so = if Sys.win32 then "dll" else "so" + ~targets:("hello.byte" -.- o,["hello.byte.c";"hello.native" -.- o]) ();; let () = test "OutputShared" ~options:[`no_ocamlfind] @@ -260,7 +258,7 @@ let () = test "OutputShared" ~requirements:ocamlopt_available ~tree:[T.f "hello.ml" ~content:{|print_endline "Hello, World!"|}; T.f "_tags" ~content:"<*.so>: runtime_variant(_pic)"] - ~targets:("hello.byte."^so,["hello.native."^so]) ();; + ~targets:("hello.byte" -.- so,["hello.native" -.- so]) ();; let () = test "CmxsStubLink" ~options:[`no_ocamlfind] @@ -268,7 +266,7 @@ let () = test "CmxsStubLink" ~requirements:ocamlopt_available ~tree:[T.d "src" [ T.f "foo_stubs.c" ~content:""; - T.f "libfoo_stubs.clib" ~content:"foo_stubs.o"; + T.f "libfoo_stubs.clib" ~content:("foo_stubs" -.- o) ; T.f "foo.ml" ~content:""; ]; T.f "_tags" ~content:{| @@ -280,9 +278,9 @@ open Ocamlbuild_plugin let () = dispatch begin function | After_rules -> - dep ["record_foo_stubs"] ["src/libfoo_stubs.a"]; + dep ["record_foo_stubs"] ["src/libfoo_stubs" -.- !Options.ext_lib]; flag_and_dep - ["link"; "ocaml"; "link_foo_stubs"] (P "src/libfoo_stubs.a"); + ["link"; "ocaml"; "link_foo_stubs"] (P ("src/libfoo_stubs" -.- !Options.ext_lib)); flag ["library"; "ocaml"; "record_foo_stubs"] (S ([A "-cclib"; A "-lfoo_stubs"])); | _ -> () @@ -414,14 +412,12 @@ pflag ["link"] "toto" (fun arg -> A arg);; ~matching:[M.f "main.byte"] ~targets:("main.byte",[]) ();; -let exe_suf = if Sys.win32 then ".exe" else "" - let () = test "PluginCompilation1" ~description:"check that the plugin is not compiled when -no-plugin is passed" ~options:[`no_ocamlfind; `no_plugin] ~tree:[T.f "main.ml" ~content:"let x = 1"; T.f "myocamlbuild.ml" ~content:{|prerr_endline "foo";;|}] - ~matching:[_build [M.Not (M.f ("myocamlbuild" ^ exe_suf))]] + ~matching:[_build [M.Not (M.f ("myocamlbuild" ^ Ocamlbuild_config.exe))]] ~targets:("main.byte",[]) ();; let () = test "PluginCompilation2" @@ -429,7 +425,7 @@ let () = test "PluginCompilation2" ~options:[`no_ocamlfind; `just_plugin] ~tree:[T.f "main.ml" ~content:"let x = 1"; T.f "myocamlbuild.ml" ~content:{|print_endline "foo";;|}] - ~matching:[_build [M.f ("myocamlbuild" ^ exe_suf)]] + ~matching:[_build [M.f ("myocamlbuild" ^ Ocamlbuild_config.exe)]] ~targets:("", []) ();; let () = test "PluginCompilation3" @@ -516,7 +512,7 @@ let () = test "TargetsStartingWithUnderscore" *) ~options:[`no_ocamlfind] ~tree:[ T.f "_a.c" ~content:"" ] - ~targets:("_a.o", []) ();; + ~targets:("_a" -.- o, []) ();; let () = test "OpaqueEverything" ~description:"Check that tagging everything opaque does not break build" @@ -563,7 +559,7 @@ CAMLprim value hello_world(value unit) } |}; ] - ~targets:("libtest.a", []) ();; + ~targets:("libtest" -.- a, []) ();; let () = test "JustNoPlugin" ~description:"(ocamlbuild -just-plugin) should do nothing when no plugin is there" diff --git a/testsuite/ocamlbuild_test.ml b/testsuite/ocamlbuild_test.ml index 55830dd9..e520c002 100644 --- a/testsuite/ocamlbuild_test.ml +++ b/testsuite/ocamlbuild_test.ml @@ -11,8 +11,17 @@ (* *) (***********************************************************************) +#directory "../plugin-lib/";; +#directory "../src/";; + +#load "../src/ocamlbuild_config.cmo" +#load "../plugin-lib/ocamlbuildlib.cma";; + open Format +module My_std = Ocamlbuild_pack.My_std +open Ocamlbuild_pack.Pathname.Operators + external (|>) : 'a -> ('a -> 'b) -> 'b = "%revapply" let print_list ~sep f ppf = function @@ -30,7 +39,7 @@ let print_string_list = print_list_com pp_print_string let print_string_list_com = print_list_com pp_print_string let print_string_list_blank = print_list_blank pp_print_string -let exists filename = Sys.file_exists filename +let exists filename = My_std.sys_file_exists filename let execute cmd = let ic = Unix.open_process_in cmd and lst = ref [] in @@ -40,11 +49,7 @@ let execute cmd = let ret_code = Unix.close_process_in ic in ret_code, List.rev !lst -(* Simplified implementation of My_std.sys_command to avoid duplicating code. *) -let sys_command cmd = - if Sys.win32 - then Sys.command (Printf.sprintf "bash --norc --noprofile -c %S" cmd) - else Sys.command cmd +let sys_command cmd = My_std.sys_command cmd let rm f = if exists f then @@ -113,6 +118,7 @@ module Match = struct let x ?(atts=()) name ~output = X ((atts,name), (0,output)) let match_with_fs ~root m = + My_std.reset_readdir_cache (); let rec visit ~exact ~successes ~errors path m = let string_of_path path = "./" ^ String.concat "/" (List.rev path) in let file name = string_of_path (name :: path) in @@ -386,6 +392,10 @@ module Tree = struct end +let a = Ocamlbuild_config.a +let o = Ocamlbuild_config.o +let so = Ocamlbuild_config.so + type content = string type filename = string type run = filename * content @@ -468,16 +478,16 @@ let run ~root = copy [ "plugin-lib/ocamlbuildlib.cma"; "plugin-lib/ocamlbuildlib.cmxa"; - "plugin-lib/ocamlbuildlib.a"; + "plugin-lib/ocamlbuildlib" -.- a; "bin/ocamlbuild.cmo"; "bin/ocamlbuild.cmx"; - "bin/ocamlbuild.o"; + "bin/ocamlbuild" -.- o; "src/ocamlbuild_pack.cmi"; "src/ocamlbuild_pack.cmx"; - "src/ocamlbuild_pack.o"; + "src/ocamlbuild_pack" -.- o; "plugin-lib/ocamlbuild_plugin.cmi"; "plugin-lib/ocamlbuild_plugin.cmx"; - "plugin-lib/ocamlbuild_plugin.o" ] + "plugin-lib/ocamlbuild_plugin" -.- o ] install_lib_dir; copy [ "ocamlbuild.byte";