Skip to content

Commit

Permalink
Tests: add an example using dune site and build info
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed Aug 30, 2024
1 parent 814035b commit 1f3b969
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
22 changes: 22 additions & 0 deletions compiler/tests-build-info/dune
Original file line number Diff line number Diff line change
@@ -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)))
6 changes: 6 additions & 0 deletions compiler/tests-build-info/dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(lang dune 3.7)
(using dune_site 0.1)

(package
(name js_of_ocaml-tests)
(sites (share tests)))
18 changes: 18 additions & 0 deletions compiler/tests-build-info/main.ml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1f3b969

Please sign in to comment.