Skip to content

Commit f84f469

Browse files
committed
mdx stanza: record env var dependency
Since realworldocaml/mdx#366, the executable output by `ocaml-mdx dune-gen` supports `MDX_RUN_NON_DETERMINISTIC` like `ocaml-mdx test` itself. Dune needs to know about that to rerun the tests if the variable has been set in the meantime. Signed-off-by: Etienne Millon <me@emillon.org>
1 parent e674955 commit f84f469

File tree

4 files changed

+63
-2
lines changed

4 files changed

+63
-2
lines changed

CHANGES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ Unreleased
256256

257257
- Introduce mdx stanza 0.2, requiring mdx >= 1.9.0, with a new generic `deps`
258258
field and the possibility to statically link `libraries` in the test
259-
executable. (#3956, fixes #3955)
259+
executable. (#3956, #5391, fixes #3955)
260260

261261
- Improve lookup of optional or disabled binaries. Previously, we'd treat every
262262
executable with missing libraries as optional. Now, we treat make sure to

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ core_bench \
1818
"csexp>=1.3.0" \
1919
js_of_ocaml \
2020
js_of_ocaml-compiler \
21-
mdx \
21+
"mdx>=2.1.0" \
2222
menhir \
2323
"merlin>=3.4.0" \
2424
ocamlfind \

src/dune_rules/mdx.ml

+2
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ let gen_rules_for_single_file stanza ~sctx ~dir ~expander ~mdx_prog
258258
Dep_conf_eval.unnamed ~expander (mdx_package_deps @ mdx_generic_deps)
259259
in
260260
Action_builder.with_no_targets deps
261+
>>> Action_builder.with_no_targets
262+
(Action_builder.env_var "MDX_RUN_NON_DETERMINISTIC")
261263
>>> Action_builder.with_no_targets (Action_builder.dyn_deps dyn_deps)
262264
>>> Command.run ~dir:(Path.build dir) ~stdout_to:files.corrected
263265
executable command_line
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
Dune should know about the fact that mdx reads the MDX_RUN_NON_DETERMINISTIC
2+
variable. When using the stanza 0.2, it is the mdx driver that reads that
3+
variable. This is only the case since mdx 2.1.0.
4+
5+
$ cat > dune-project << EOF
6+
> (lang dune 3.0)
7+
> (using mdx 0.2)
8+
> EOF
9+
10+
$ cat > dune << EOF
11+
> (mdx (files README.md))
12+
> EOF
13+
14+
$ cat > README.md << 'EOF'
15+
> ```ocaml
16+
> # "a";;
17+
> ```
18+
>
19+
> ```ocaml non-deterministic
20+
> # "b";;
21+
> ```
22+
> EOF
23+
24+
$ dune runtest --auto-promote
25+
File "README.md", line 1, characters 0-0:
26+
Error: Files _build/default/README.md and
27+
_build/default/.mdx/README.md.corrected differ.
28+
Promoting _build/default/.mdx/README.md.corrected to README.md.
29+
[1]
30+
31+
$ cat README.md
32+
```ocaml
33+
# "a";;
34+
- : string = "a"
35+
```
36+
37+
```ocaml non-deterministic
38+
# "b";;
39+
```
40+
41+
$ dune runtest
42+
43+
$ MDX_RUN_NON_DETERMINISTIC=1 dune runtest --auto-promote
44+
File "README.md", line 1, characters 0-0:
45+
Error: Files _build/default/README.md and
46+
_build/default/.mdx/README.md.corrected differ.
47+
Promoting _build/default/.mdx/README.md.corrected to README.md.
48+
[1]
49+
50+
$ cat README.md
51+
```ocaml
52+
# "a";;
53+
- : string = "a"
54+
```
55+
56+
```ocaml non-deterministic
57+
# "b";;
58+
- : string = "b"
59+
```

0 commit comments

Comments
 (0)