Skip to content

Commit be2dd2e

Browse files
authored
Merge pull request #162 from Julow/gen-test-rules
- Generate test rules - Fix printing of --prelude-str option
2 parents 58d4c56 + 672efd1 commit be2dd2e

File tree

4 files changed

+237
-172
lines changed

4 files changed

+237
-172
lines changed

bin/rule.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ let pp_direction fmt = function
9999
| `To_ml -> Fmt.pf fmt "--direction=to-ml"
100100

101101
let pp_prelude fmt s = Fmt.pf fmt "--prelude=%s" s
102-
let pp_prelude_str fmt s = Fmt.pf fmt "--prelude-str=%S" s
102+
let pp_prelude_str fmt s = Fmt.pf fmt "--prelude-str %S" s
103103

104104
let add_opt e s = match e with None -> s | Some e -> String.Set.add e s
105105

test/dune

Lines changed: 38 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
1+
(include dune.inc)
2+
3+
; Generates rules
4+
5+
(rule
6+
(targets dune.inc.gen)
7+
(deps (package mdx))
8+
(action
9+
(with-stdout-to %{targets}
10+
(progn
11+
(run ocaml-mdx rule %{dep:pp.md})
12+
(run ocaml-mdx rule %{dep:ellipsis.md})
13+
(run ocaml-mdx rule %{dep:envs.md})
14+
(run ocaml-mdx rule %{dep:empty_line.md})
15+
(run ocaml-mdx rule %{dep:spaces.md})
16+
(run ocaml-mdx rule %{dep:errors.md})
17+
(run ocaml-mdx rule %{dep:heredoc.md})
18+
(run ocaml-mdx rule %{dep:mlt.md})
19+
(run ocaml-mdx rule %{dep:semisemi.md})
20+
(run ocaml-mdx rule %{dep:exit.md})
21+
(run ocaml-mdx rule %{dep:padding.md})
22+
(run ocaml-mdx rule %{dep:multilines.md})
23+
(run ocaml-mdx rule %{dep:lines.md})
24+
(run ocaml-mdx rule %{dep:lwt.md})
25+
(run ocaml-mdx rule %{dep:non-det.md})
26+
(run ocaml-mdx rule %{dep:code.md})
27+
(run ocaml-mdx rule %{dep:set_environment_variable.md})
28+
(run ocaml-mdx rule %{dep:unset_environment_variable.md})
29+
(run ocaml-mdx rule --prelude-str "#require \"lwt\"" --prelude-str "toto:let x = \"42\"" %{dep:prelude.md})
30+
(run ocaml-mdx rule --prelude prelude.ml %{dep:prelude_file.md})
31+
(run ocaml-mdx rule --direction=to-ml %{dep:dune_rules.md})
32+
(run ocaml-mdx rule %{dep:require/require-package.md})
33+
))))
34+
35+
(alias
36+
(name runtest)
37+
(action (diff dune.inc dune.inc.gen)))
38+
139
(alias
240
(name runtest)
341
(deps (:x section.md) (:y section.md.expected) (package mdx))
@@ -26,27 +64,6 @@
2664
(run ocaml-mdx test --force-output %{x})
2765
(diff? %{y} %{x}.corrected))))
2866

29-
(alias
30-
(name runtest)
31-
(deps (:x ellipsis.md) (package mdx))
32-
(action (progn
33-
(run ocaml-mdx test %{x})
34-
(diff? %{x} %{x}.corrected))))
35-
36-
(alias
37-
(name runtest)
38-
(deps (:x envs.md) (package mdx))
39-
(action (progn
40-
(run ocaml-mdx test %{x})
41-
(diff? %{x} %{x}.corrected))))
42-
43-
(alias
44-
(name runtest)
45-
(deps (:x empty_line.md) (package mdx))
46-
(action (progn
47-
(run ocaml-mdx test %{x})
48-
(diff? %{x} %{x}.corrected))))
49-
5067
(alias
5168
(name runtest)
5269
(deps (:x empty_lines.md) (:y empty_lines.md.expected) (package mdx))
@@ -61,97 +78,13 @@
6178
(run ocaml-mdx output %{x} -o output.html)
6279
(diff? %{y} output.html))))
6380

64-
(alias
65-
(name runtest)
66-
(deps (:x spaces.md) (package mdx))
67-
(action (progn
68-
(run ocaml-mdx test %{x})
69-
(diff? %{x} %{x}.corrected))))
70-
7181
(alias
7282
(name runtest)
7383
(deps (:x cram.t) (package mdx))
7484
(action (progn
7585
(run ocaml-mdx test --syntax=cram %{x})
7686
(diff? %{x} %{x}.corrected))))
7787

78-
(alias
79-
(name runtest)
80-
(deps (:x errors.md) (package mdx))
81-
(action (progn
82-
(run ocaml-mdx test %{x})
83-
(diff? %{x} %{x}.corrected))))
84-
85-
(alias
86-
(name runtest)
87-
(deps (:x heredoc.md) section.md (package mdx))
88-
(action (progn
89-
(run ocaml-mdx test %{x})
90-
(diff? %{x} %{x}.corrected))))
91-
92-
(alias
93-
(name runtest)
94-
(deps (:x mlt.md) (package mdx))
95-
(action (progn
96-
(run ocaml-mdx test %{x})
97-
(diff? %{x} %{x}.corrected))))
98-
99-
(alias
100-
(name runtest)
101-
(deps (:x semisemi.md) (package mdx))
102-
(action (progn
103-
(run ocaml-mdx test %{x})
104-
(diff? %{x} %{x}.corrected))))
105-
106-
(alias
107-
(name runtest)
108-
(deps (:x exit.md) (package mdx))
109-
(action (progn
110-
(run ocaml-mdx test %{x})
111-
(diff? %{x} %{x}.corrected))))
112-
113-
(alias
114-
(name runtest)
115-
(deps (:x padding.md) (package mdx))
116-
(action (progn
117-
(run ocaml-mdx test %{x})
118-
(diff? %{x} %{x}.corrected))))
119-
120-
(alias
121-
(name runtest)
122-
(deps (:x multilines.md) (package mdx))
123-
(action (progn
124-
(run ocaml-mdx test %{x})
125-
(diff? %{x} %{x}.corrected))))
126-
127-
(alias
128-
(name runtest)
129-
(deps (:x lines.md) (package mdx))
130-
(action (progn
131-
(run ocaml-mdx test %{x})
132-
(diff? %{x} %{x}.corrected))))
133-
134-
(alias
135-
(name runtest)
136-
(deps (:x lwt.md) (package mdx))
137-
(action (progn
138-
(run ocaml-mdx test %{x})
139-
(diff? %{x} %{x}.corrected))))
140-
141-
(alias
142-
(name runtest)
143-
(deps (:x non-det.md) (package mdx))
144-
(action (progn
145-
(run ocaml-mdx test %{x})
146-
(diff? %{x} %{x}.corrected))))
147-
148-
(alias
149-
(name runtest)
150-
(deps (:x code.md) (package mdx))
151-
(action (progn
152-
(run ocaml-mdx test %{x})
153-
(diff? %{x} %{x}.corrected))))
154-
15588
(alias
15689
(name runtest)
15790
(deps (:x dir.md) (package mdx))
@@ -167,40 +100,6 @@
167100
(action (progn
168101
(run ocaml-mdx test --force-output --root=.. %{x})
169102
(diff? %{y} %{x}.corrected))))
170-
171-
(alias
172-
(name runtest)
173-
(deps (:x set_environment_variable.md) (package mdx))
174-
(action (progn
175-
(run ocaml-mdx test %{x})
176-
(diff? %{x} %{x}.corrected))))
177-
178-
(alias
179-
(name runtest)
180-
(deps (:x unset_environment_variable.md) (package mdx))
181-
(action (progn
182-
(run ocaml-mdx test %{x})
183-
(diff? %{x} %{x}.corrected))))
184-
185-
(alias
186-
(name runtest)
187-
(deps (:x prelude.md) (package mdx))
188-
(action (progn
189-
(run ocaml-mdx
190-
test
191-
--prelude-str "#require \"lwt\""
192-
--prelude-str "toto:let x = \"42\""
193-
%{x})
194-
(diff? %{x} %{x}.corrected))))
195-
196-
(alias
197-
(name runtest)
198-
(deps (:x prelude_file.md) prelude.ml (package mdx))
199-
(action (progn
200-
(run ocaml-mdx test --prelude prelude.ml %{x})
201-
(diff? %{x} %{x}.corrected))))
202-
203-
204103
(alias
205104
(name runtest)
206105
(deps (:x sync_to_md.md)
@@ -257,23 +156,3 @@
257156
(name runtest)
258157
(deps (:x section.out) (:y section.out.expected))
259158
(action (diff? %{x} %{y})))
260-
261-
(include dune_rules.inc)
262-
263-
(rule
264-
(targets dune_rules.inc.gen)
265-
(deps (source_tree test-cases) (:x dune_rules.md) (package mdx))
266-
(action (with-stdout-to %{targets} (run ocaml-mdx rule --direction=to-ml %{x}))))
267-
268-
(alias
269-
(name runtest)
270-
(action (diff dune_rules.inc dune_rules.inc.gen)))
271-
272-
(alias
273-
(name runtest)
274-
(deps (:x require/require-package.md)
275-
(package mdx)
276-
(package example_lib))
277-
(action (progn
278-
(run ocaml-mdx test --direction=infer-timestamp %{x})
279-
(diff? %{x} %{x}.corrected))))

0 commit comments

Comments
 (0)