Install runtime artifacts and verify external builds
This commit is contained in:
5 files changed
+76
-5
No files matched your search
+1
-1
@@ -1,4 +1,4 @@
|
||||
_build/
|
||||
_build*/
|
||||
/deltac
|
||||
_bench_out/
|
||||
bench/bench_results.txt
|
||||
|
||||
@@ -49,7 +49,7 @@ LIBS = unix.cmxa
|
||||
|
||||
.PHONY: all clean test bench install uninstall
|
||||
|
||||
all: deltac $(LIB_ARCHIVE) $(RUNTIME_ARCHIVE) $(TEST_EXE)
|
||||
all: deltac $(LIB_ARCHIVE) $(RUNTIME_ARCHIVE) $(RUNTIME_BYTE) $(TEST_EXE)
|
||||
|
||||
$(BUILD):
|
||||
mkdir -p $(BUILD)
|
||||
@@ -139,9 +139,12 @@ $(RUNTIME_ARCHIVE) $(RUNTIME_NATIVE): $(RT_CMX)
|
||||
ifeq ($(strip $(RT_ML)),)
|
||||
@echo "no runtime sources"
|
||||
else
|
||||
$(OCAMLOPT) -a -o $@ $(RT_CMX)
|
||||
$(OCAMLOPT) -a -o $@ $(RT_ORDER)
|
||||
endif
|
||||
|
||||
$(RUNTIME_BYTE): $(patsubst $(RUNTIME_DIR)/%.ml,$(BUILD)/%.cmo,$(RT_ML))
|
||||
$(OCAMLC) -a -o $@ $(patsubst $(RUNTIME_DIR)/%.ml,$(BUILD)/%.cmo,$(RT_ML))
|
||||
|
||||
ifeq ($(strip $(TEST_ML)),)
|
||||
TEST_EXE =
|
||||
else
|
||||
@@ -157,12 +160,12 @@ $(BENCH_EXE): $(BUILD)/bench.cmx $(LIB_ARCHIVE) $(RUNTIME_ARCHIVE) deltac
|
||||
endif
|
||||
|
||||
test: $(TEST_EXE)
|
||||
DELTA_ROOT=$(CURDIR) DELTA_BUILD_DIR=$(CURDIR)/$(BUILD) DELTA_OCAMLOPT="$(OCAMLOPT)" ./$(TEST_EXE)
|
||||
DELTA_ROOT=$(CURDIR) DELTA_BUILD_DIR=$(CURDIR)/$(BUILD) DELTA_RUNTIME_DIR=$(CURDIR)/$(BUILD) DELTA_OCAMLOPT="$(OCAMLOPT)" ./$(TEST_EXE)
|
||||
|
||||
bench: $(BENCH_EXE)
|
||||
DELTA_ROOT=$(CURDIR) DELTA_BUILD_DIR=$(CURDIR)/$(BUILD) DELTA_OCAMLOPT="$(OCAMLOPT)" ./$(BENCH_EXE)
|
||||
|
||||
install: deltac $(RUNTIME_ARCHIVE)
|
||||
install: deltac $(RUNTIME_ARCHIVE) $(RUNTIME_BYTE)
|
||||
$(INSTALL) -d $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR)
|
||||
$(INSTALL) -m 755 deltac $(DESTDIR)$(BINDIR)/deltac
|
||||
$(INSTALL) -m 644 $(RUNTIME_ARTIFACTS) $(DESTDIR)$(LIBDIR)/
|
||||
|
||||
@@ -2,6 +2,7 @@ opam-version: "1.2"
|
||||
name: "delta"
|
||||
version: "0.1.0"
|
||||
maintainer: "deltac@localhost"
|
||||
authors: [ "deltac@localhost" ]
|
||||
build: [
|
||||
[make]
|
||||
]
|
||||
|
||||
@@ -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 );
|
||||
]
|
||||
@@ -388,6 +388,7 @@ let () =
|
||||
Test_harness.run_suite "generated updates" Test_codegen.update_cases;
|
||||
Test_harness.run_suite "wire" Test_codegen.wire_cases;
|
||||
Test_harness.run_suite "cli" Test_codegen.cli_cases;
|
||||
Test_harness.run_suite "install" Test_codegen.install_cases;
|
||||
Test_harness.run_suite "regression" Test_incremental.regression_cases;
|
||||
Test_harness.run_suite "differential" Test_incremental.differential_cases;
|
||||
Test_harness.run_suite "generated differential" Test_codegen.generated_differential_cases;
|
||||
|
||||
Reference in new issue
Block a user