From 1f3b96991af4e774ce72292b1e085a6c2165db06 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Wed, 24 Jul 2024 14:44:32 +0200 Subject: [PATCH] Tests: add an example using dune site and build info --- compiler/tests-build-info/dune | 22 ++++++++++++++++++++++ compiler/tests-build-info/dune-project | 6 ++++++ compiler/tests-build-info/main.ml | 18 ++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 compiler/tests-build-info/dune create mode 100644 compiler/tests-build-info/dune-project create mode 100644 compiler/tests-build-info/main.ml diff --git a/compiler/tests-build-info/dune b/compiler/tests-build-info/dune new file mode 100644 index 0000000000..33300c3c3c --- /dev/null +++ b/compiler/tests-build-info/dune @@ -0,0 +1,22 @@ + +(env + (_ + (js_of_ocaml + (compilation_mode separate)))) + +(executable + (name main) + (modes js byte native) + (modules main mysites) + (libraries dune-build-info dune-site)) + +(generate_sites_module + (module mysites) + (sites js_of_ocaml-tests)) + +(install + (section libexec) + (package js_of_ocaml-tests) + (files + (main.bc.js as test-build-info.bc.js) + (main.exe as test-build-info.exe))) \ No newline at end of file diff --git a/compiler/tests-build-info/dune-project b/compiler/tests-build-info/dune-project new file mode 100644 index 0000000000..cc4062c406 --- /dev/null +++ b/compiler/tests-build-info/dune-project @@ -0,0 +1,6 @@ +(lang dune 3.7) +(using dune_site 0.1) + +(package + (name js_of_ocaml-tests) + (sites (share tests))) \ No newline at end of file diff --git a/compiler/tests-build-info/main.ml b/compiler/tests-build-info/main.ml new file mode 100644 index 0000000000..de400af4e0 --- /dev/null +++ b/compiler/tests-build-info/main.ml @@ -0,0 +1,18 @@ +let version = + match Build_info.V1.version () with + | None -> "unknown" + | Some v -> Build_info.V1.Version.to_string v + +let () = + print_endline "Version:"; + match String.split_on_char '-' version with + | [ tag; plus; _commit; dirty ] -> + Printf.printf "%s-%s-%s-%s\n%!" tag plus "xxxxx" dirty + | [ tag; plus; _commit ] -> + Printf.printf "%s-%s-%s\n%!" tag plus "xxxxx" + | [ x ] -> print_endline x + | _ -> Printf.printf "unexpected: %s\n%!" version + +let () = + print_endline "Sites:"; + List.iter print_endline Mysites.Sites.tests