Install runtime artifacts and verify external builds
This commit is contained in:
5 files changed
+76
-5
No files matched your search
@@ -23,6 +23,23 @@ let run command =
|
||||
(try Sys.remove log with _ -> ());
|
||||
(status, text)
|
||||
|
||||
let run_env environment command =
|
||||
let log = Filename.temp_file "delta_test" ".log" in
|
||||
let fd = Unix.openfile log [ Unix.O_WRONLY; Unix.O_CREAT; Unix.O_TRUNC ] 0o600 in
|
||||
let argv = Array.of_list command in
|
||||
let pid = Unix.create_process_env argv.(0) argv environment Unix.stdin fd fd in
|
||||
let status = snd (Unix.waitpid [] pid) in
|
||||
Unix.close fd;
|
||||
let text = Native.read_file log in
|
||||
(try Sys.remove log with _ -> ());
|
||||
(status, text)
|
||||
|
||||
let environment_without name =
|
||||
Array.of_list
|
||||
(List.filter
|
||||
(fun entry -> not (Util.starts_with (name ^ "=") entry))
|
||||
(Array.to_list (Unix.environment ())))
|
||||
|
||||
let compile source_path output_path =
|
||||
let command =
|
||||
[ ocamlopt (); "-I"; build_dir (); "-I"; "+unix"; "-o"; output_path;
|
||||
@@ -692,3 +709,52 @@ let generated_differential_cases =
|
||||
("generated programs match full evaluation on a short run",
|
||||
fun () -> generated_differential_case 2 3);
|
||||
]
|
||||
|
||||
let install_cases =
|
||||
[
|
||||
( "the installed compiler builds programs outside the source tree",
|
||||
fun () ->
|
||||
let destdir = Filename.concat (Filename.get_temp_dir_name ()) (unique "delta_install") in
|
||||
Unix.mkdir destdir 0o700;
|
||||
let make = try Sys.getenv "DELTA_MAKE" with Not_found -> "make" in
|
||||
let status, output =
|
||||
run [ make; "-C"; root (); "install"; "DESTDIR=" ^ destdir; "PREFIX=/usr/local" ]
|
||||
in
|
||||
check ("install succeeds: " ^ output) (status = Unix.WEXITED 0);
|
||||
let bindir = Filename.concat destdir "usr/local/bin" in
|
||||
let libdir = Filename.concat destdir "usr/local/lib/delta" in
|
||||
check "deltac is installed" (Sys.file_exists (Filename.concat bindir "deltac"));
|
||||
check "the native runtime is installed"
|
||||
(Sys.file_exists (Filename.concat libdir "delta_runtime.cmxa"));
|
||||
check "the bytecode runtime is installed"
|
||||
(Sys.file_exists (Filename.concat libdir "delta_runtime.cma"));
|
||||
check "the wire interface is installed" (Sys.file_exists (Filename.concat libdir "wire.cmi"));
|
||||
let source = Filename.concat destdir "outside.delta" in
|
||||
write_file source (read_fixture "expensive_order.delta");
|
||||
let application = Filename.concat destdir "application" in
|
||||
let status, output =
|
||||
run_env (environment_without "DELTA_RUNTIME_DIR")
|
||||
[ Filename.concat bindir "deltac"; "build"; source; "-o"; application ]
|
||||
in
|
||||
check ("the installed compiler builds: " ^ output) (status = Unix.WEXITED 0);
|
||||
check "the executable exists" (Sys.file_exists application);
|
||||
let input = Filename.concat destdir "order.sexp" in
|
||||
write_file input "(1 (record (customer \"Ada\") (total 1500)))\n(2 (record (customer \"Bo\") (total 40)))\n";
|
||||
let updates = Filename.concat destdir "update.sexp" in
|
||||
write_file updates "(batch (insert 3 (record (customer \"Lin\") (total 2200))))\n";
|
||||
let status, output =
|
||||
run_env (environment_without "DELTA_RUNTIME_DIR")
|
||||
[ application; "--input"; input; "--updates"; updates; "--print-result" ]
|
||||
in
|
||||
check "the installed compiler's output runs" (status = Unix.WEXITED 0);
|
||||
check_equal_string "result"
|
||||
"(collection (1 (tuple \"Ada\" 300)) (3 (tuple \"Lin\" 440)))" (String.trim output);
|
||||
let status, _ =
|
||||
run [ make; "-C"; root (); "uninstall"; "DESTDIR=" ^ destdir; "PREFIX=/usr/local" ]
|
||||
in
|
||||
check "uninstall succeeds" (status = Unix.WEXITED 0);
|
||||
check "deltac is removed" (not (Sys.file_exists (Filename.concat bindir "deltac")));
|
||||
check "the runtime is removed"
|
||||
(not (Sys.file_exists (Filename.concat libdir "delta_runtime.cmxa")));
|
||||
Native.remove_dir destdir );
|
||||
]
|
||||
Reference in new issue
Block a user