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 Dec 4, 2024
1 parent 9cfbfc4 commit b4515d6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
23 changes: 23 additions & 0 deletions compiler/tests-build-info/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(env
(_
(js_of_ocaml
(compilation_mode separate))))

(executable
(name main)
(modes js wasm 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)
(main.bc.wasm.js as test-build-info.bc.wasm.js))
(dirs main.bc.wasm.assets))
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.17)
(using dune_site 0.1)

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

Please sign in to comment.