Skip to content

Commit ff83e1c

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 064ff9f commit ff83e1c

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

CHANGES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ Unreleased
253253

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

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

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,55 @@
1+
$ cat > dune-project << EOF
2+
> (lang dune 3.0)
3+
> (using mdx 0.2)
4+
> EOF
5+
6+
$ cat > dune << EOF
7+
> (mdx (files README.md))
8+
> EOF
9+
10+
$ cat > README.md << 'EOF'
11+
> ```ocaml
12+
> # "a";;
13+
> ```
14+
>
15+
> ```ocaml non-deterministic
16+
> # "b";;
17+
> ```
18+
> EOF
19+
20+
$ dune runtest --auto-promote
21+
File "README.md", line 1, characters 0-0:
22+
Error: Files _build/default/README.md and
23+
_build/default/.mdx/README.md.corrected differ.
24+
Promoting _build/default/.mdx/README.md.corrected to README.md.
25+
[1]
26+
27+
$ cat README.md
28+
```ocaml
29+
# "a";;
30+
- : string = "a"
31+
```
32+
33+
```ocaml non-deterministic
34+
# "b";;
35+
```
36+
37+
$ dune runtest
38+
39+
$ MDX_RUN_NON_DETERMINISTIC=1 dune runtest --auto-promote
40+
File "README.md", line 1, characters 0-0:
41+
Error: Files _build/default/README.md and
42+
_build/default/.mdx/README.md.corrected differ.
43+
Promoting _build/default/.mdx/README.md.corrected to README.md.
44+
[1]
45+
46+
$ cat README.md
47+
```ocaml
48+
# "a";;
49+
- : string = "a"
50+
```
51+
52+
```ocaml non-deterministic
53+
# "b";;
54+
- : string = "b"
55+
```

0 commit comments

Comments
 (0)