Skip to content

Commit fcedc4e

Browse files
Julowjonludlam
authored andcommitted
Remove some duplicated code in generators tests
- Factorize the code generating dune rules - Avoid reading .targets files several time - Simplify some path logic
1 parent 68238a3 commit fcedc4e

File tree

3 files changed

+4600
-5763
lines changed

3 files changed

+4600
-5763
lines changed

test/generators/gen_rules/gen_rules.ml

Lines changed: 33 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,40 @@ let die s =
22
prerr_endline s;
33
exit 1
44

5-
let html_target_rule path : Gen_rules_lib.sexp =
6-
List
7-
[
8-
Atom "action";
9-
List
10-
[
11-
Atom "progn";
12-
List
13-
[
14-
Atom "run";
15-
Atom "odoc";
16-
Atom "html-generate";
17-
Atom "--indent";
18-
Atom "--flat";
19-
Atom "--extra-suffix";
20-
Atom "gen";
21-
Atom "-o";
22-
Atom ".";
23-
Atom ("%{dep:" ^ Fpath.to_string path ^ "}");
24-
];
25-
];
26-
]
5+
let html_target_rule path =
6+
[
7+
"odoc";
8+
"html-generate";
9+
"--indent";
10+
"--flat";
11+
"--extra-suffix";
12+
"gen";
13+
"-o";
14+
".";
15+
Gen_rules_lib.Dune.arg_dep path;
16+
]
2717

28-
let latex_target_rule path : Gen_rules_lib.sexp =
29-
List
30-
[
31-
Atom "action";
32-
List
33-
[
34-
Atom "progn";
35-
List
36-
[
37-
Atom "run";
38-
Atom "odoc";
39-
Atom "latex-generate";
40-
Atom "-o";
41-
Atom ".";
42-
Atom "--extra-suffix";
43-
Atom "gen";
44-
Atom ("%{dep:" ^ Fpath.to_string path ^ "}");
45-
];
46-
];
47-
]
18+
let latex_target_rule path =
19+
[
20+
"odoc";
21+
"latex-generate";
22+
"-o";
23+
".";
24+
"--extra-suffix";
25+
"gen";
26+
Gen_rules_lib.Dune.arg_dep path;
27+
]
4828

49-
let man_target_rule path : Gen_rules_lib.sexp =
50-
List
51-
[
52-
Atom "action";
53-
List
54-
[
55-
Atom "progn";
56-
List
57-
[
58-
Atom "run";
59-
Atom "odoc";
60-
Atom "man-generate";
61-
Atom "-o";
62-
Atom ".";
63-
Atom "--extra-suffix";
64-
Atom "gen";
65-
Atom ("%{dep:" ^ Fpath.to_string path ^ "}");
66-
];
67-
];
68-
]
29+
let man_target_rule path =
30+
[
31+
"odoc";
32+
"man-generate";
33+
"-o";
34+
".";
35+
"--extra-suffix";
36+
"gen";
37+
Gen_rules_lib.Dune.arg_dep path;
38+
]
6939

7040
(** Returns filenames, not paths. *)
7141
let read_files_from_dir dir =
@@ -91,7 +61,7 @@ let test_cases_dir = Fpath.v "cases"
9161
(** Make a test cases or return the empty list if the given file should be
9262
ignored. Might abort the program with an error. *)
9363
let make_test_case case_name =
94-
let input = Fpath.(/) test_cases_dir case_name in
64+
let input = Fpath.( / ) test_cases_dir case_name in
9565
let mk odoc_prefix cmt_suffix =
9666
let base_out_path = Fpath.v (odoc_prefix ^ case_name) in
9767
let cmt =

0 commit comments

Comments
 (0)