Skip to content

Commit

Permalink
test: Specify which test belong to Odoc
Browse files Browse the repository at this point in the history
This is needed to be able to run Sherlodoc's and Odoc's tests
separately, for example in CI on in Opam.
  • Loading branch information
Julow committed Dec 13, 2024
1 parent b6606cd commit 4c0ea7c
Show file tree
Hide file tree
Showing 17 changed files with 1,181 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/html_support_files/dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
(rule
(aliases runtest support-files)
(target odoc_html_support_files.ml)
(package odoc)
(deps
(glob_files *.js)
(glob_files *.css)
Expand Down
1 change: 1 addition & 0 deletions test/frontmatter/dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
(../odoc_print/odoc_print.exe as odoc_print))))

(cram
(package odoc)
(deps %{bin:odoc} %{bin:odoc_print}))
3 changes: 3 additions & 0 deletions test/generators/dune
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
(glob_files html/*.targets)
(glob_files latex/*.targets)
(glob_files man/*.targets))
(package odoc)
(enabled_if
(>= %{ocaml_version} 4.04))
(action
Expand All @@ -17,6 +18,7 @@

(rule
(alias runtest)
(package odoc)
(enabled_if
(>= %{ocaml_version} 4.04))
(action
Expand All @@ -29,4 +31,5 @@
(>= %{ocaml_version} 4.04)))

(cram
(package odoc)
(deps %{bin:odoc}))
40 changes: 19 additions & 21 deletions test/generators/gen_rules_lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,29 @@ module Dune = struct

let run cmd = List (Atom "run" :: arg_list cmd)

let action x = List [ Atom "action"; x ]
let package = List [ Atom "package"; Atom "odoc" ]

let rule ?enabledif fields =
List ((Atom "rule" :: fields) @ render_enabledif enabledif)
let rule ?enabledif ?(fields = []) action =
List
((Atom "rule" :: fields)
@ (package :: List [ Atom "action"; action ] :: render_enabledif enabledif)
)

let simple_rule ?enabledif target cmd =
rule ?enabledif
[ List [ Atom "target"; Atom (arg_fpath target) ]; action (run cmd) ]
~fields:[ List [ Atom "target"; Atom (arg_fpath target) ] ]
(run cmd)

let rule_with_output_to ?enabledif target cmd =
let target = arg_fpath target in
rule ?enabledif
[
action
(List [ Atom "with-outputs-to"; Atom (arg_fpath target); run cmd ]);
]
~fields:[ List [ Atom "target"; Atom target ] ]
(List [ Atom "with-outputs-to"; Atom target; run cmd ])

let runtest_diff ?enabledif file_a file_b =
rule ?enabledif
[
List [ Atom "alias"; Atom "runtest" ];
action
(List
[ Atom "diff"; Atom (arg_fpath file_a); Atom (arg_fpath file_b) ]);
]
~fields:[ List [ Atom "alias"; Atom "runtest" ] ]
(List [ Atom "diff"; Atom (arg_fpath file_a); Atom (arg_fpath file_b) ])

let subdir dir rules = List (Atom "subdir" :: Atom (arg_fpath dir) :: rules)
end
Expand Down Expand Up @@ -148,16 +147,15 @@ let gen_backend_diff_rule enabledif ~targets (b_t_r, b, _) p =
| [] -> []
| _ ->
let targets_gen = List.map (Fpath.add_ext ".gen") targets in
let targets_field =
List
(Atom "targets"
:: List.map (fun t -> Atom (Dune.arg_fpath t)) targets_gen)
in
Dune.
[
subdir b
(rule ?enabledif
[
List
(Atom "targets"
:: List.map (fun t -> Atom (Dune.arg_fpath t)) targets_gen);
action (run (b_t_r p));
]
(rule ?enabledif ~fields:[ targets_field ] (run (b_t_r p))
:: List.map2 (Dune.runtest_diff ?enabledif) targets targets_gen);
]

Expand Down
Loading

0 comments on commit 4c0ea7c

Please sign in to comment.