| 1 |
The project has an `.mld` file that needs to be fixed. At first, we determine |
| 2 |
that that file is not being picked up: |
| 3 |
|
| 4 |
$ cat > dune-project <<EOF |
| 5 |
> (lang dune 3.7) |
| 6 |
> (using mdx 0.3) |
| 7 |
> EOF |
| 8 |
$ cat > dune <<EOF |
| 9 |
> (mdx) |
| 10 |
> EOF |
| 11 |
> cat > needs-fixes.md <<'EOF' |
| 12 |
> This is a sample md file. It has some code that is invalid. |
| 13 |
> |
| 14 |
> ```ocaml |
| 15 |
> # List.map (fun x -> x * x) [(1 + 9); 2; 3; 4];; |
| 16 |
> - : int list = [1; 2; 3; 8] |
| 17 |
> ``` |
| 18 |
> |
| 19 |
> A run of MDX should output a fixed version. |
| 20 |
> EOF |
| 21 |
$ cat > needs-fixes.mld <<EOF |
| 22 |
> This is a sample mld file. It has some code that is invalid. |
| 23 |
> |
| 24 |
> {[ |
| 25 |
> # List.map (fun x -> x * x) [(1 + 9); 2; 3; 4];; |
| 26 |
> - : int list = [1; 2; 3; 8] |
| 27 |
> ]} |
| 28 |
> |
| 29 |
> A run of MDX should output a fixed version. |
| 30 |
> EOF |
| 31 |
$ dune runtest |
| 32 |
File "needs-fixes.md", line 1, characters 0-0: |
| 33 |
--- needs-fixes.md |
| 34 |
+++ .mdx/needs-fixes.md.corrected |
| 35 |
@@ -2,7 +2,7 @@ |
| 36 |
|
| 37 |
```ocaml |
| 38 |
# List.map (fun x -> x * x) [(1 + 9); 2; 3; 4];; |
| 39 |
- - : int list = [1; 2; 3; 8] |
| 40 |
+ - : int list = [100; 4; 9; 16] |
| 41 |
``` |
| 42 |
|
| 43 |
A run of MDX should output a fixed version. |
| 44 |
[1] |
| 45 |
|
| 46 |
It did pick up the error in the `.md` file, so let's promote the fix. |
| 47 |
|
| 48 |
$ dune promote |
| 49 |
Promoting _build/default/.mdx/needs-fixes.md.corrected to needs-fixes.md. |
| 50 |
$ dune runtest |
| 51 |
|
| 52 |
So the tests pass now, but it only uses the default `.md` glob for files to |
| 53 |
process. |
| 54 |
|
| 55 |
Let's also run the test for `.mld` files. These need to be manually passed, at |
| 56 |
least as of mdx stanza version 0.3 and require MDX 2.3.0 at minimum. |
| 57 |
|
| 58 |
$ cat > dune <<EOF |
| 59 |
> (mdx |
| 60 |
> (files needs-fixes.md needs-fixes.mld)) |
| 61 |
> EOF |
| 62 |
$ dune runtest |
| 63 |
File "needs-fixes.mld", line 1, characters 0-0: |
| 64 |
--- needs-fixes.mld |
| 65 |
+++ .mdx/needs-fixes.mld.corrected |
| 66 |
@@ -2,7 +2,7 @@ |
| 67 |
|
| 68 |
{[ |
| 69 |
# List.map (fun x -> x * x) [(1 + 9); 2; 3; 4];; |
| 70 |
- - : int list = [1; 2; 3; 8] |
| 71 |
+ - : int list = [100; 4; 9; 16] |
| 72 |
]} |
| 73 |
|
| 74 |
A run of MDX should output a fixed version. |
| 75 |
[1] |
| 76 |
|
| 77 |
The error in the `.mld` file was found, promoting should work and re-running |
| 78 |
the test should succeed this time. |
| 79 |
|
| 80 |
$ dune promote |
| 81 |
Promoting _build/default/.mdx/needs-fixes.mld.corrected to needs-fixes.mld. |
| 82 |
$ dune runtest |
| 83 |
|
| 84 |
The 0.4 version of the stanza adds support for `.mld` files by default, so bump |
| 85 |
the stanza version. |
| 86 |
|
| 87 |
$ cat > dune-project <<EOF |
| 88 |
> (lang dune 3.7) |
| 89 |
> (using mdx 0.4) |
| 90 |
> EOF |
| 91 |
$ cat > dune <<EOF |
| 92 |
> (mdx) |
| 93 |
> EOF |
| 94 |
$ cat > needs-fixes.mld <<EOF |
| 95 |
> This is a sample mld file. It has some code that is invalid. |
| 96 |
> |
| 97 |
> {[ |
| 98 |
> # List.map (fun x -> x * x) [(1 + 9); 2; 3; 4];; |
| 99 |
> - : int list = [1; 2; 3; 8] |
| 100 |
> ]} |
| 101 |
> |
| 102 |
> A run of MDX should output a fixed version. |
| 103 |
> EOF |
| 104 |
|
| 105 |
0.4 is only supported since dune-lang 3.8, so attempting to use it should fail: |
| 106 |
|
| 107 |
$ dune runtest |
| 108 |
File "dune-project", line 2, characters 11-14: |
| 109 |
2 | (using mdx 0.4) |
| 110 |
^^^ |
| 111 |
Error: Version 0.4 of mdx extension to verify code blocks in .md files is not |
| 112 |
supported until version 3.8 of the dune language. |
| 113 |
Supported versions of this extension in version 3.7 of the dune language: |
| 114 |
- 0.1 to 0.3 |
| 115 |
[1] |
| 116 |
|
| 117 |
Updating the dune-lang should make the test run. |
| 118 |
|
| 119 |
$ cat > dune-project <<EOF |
| 120 |
> (lang dune 3.8) |
| 121 |
> (using mdx 0.4) |
| 122 |
> EOF |
| 123 |
$ dune runtest |
| 124 |
File "needs-fixes.mld", line 1, characters 0-0: |
| 125 |
--- needs-fixes.mld |
| 126 |
+++ .mdx/needs-fixes.mld.corrected |
| 127 |
@@ -2,7 +2,7 @@ |
| 128 |
|
| 129 |
{[ |
| 130 |
# List.map (fun x -> x * x) [(1 + 9); 2; 3; 4];; |
| 131 |
- - : int list = [1; 2; 3; 8] |
| 132 |
+ - : int list = [100; 4; 9; 16] |
| 133 |
]} |
| 134 |
|
| 135 |
A run of MDX should output a fixed version. |
| 136 |
[1] |
| 137 |
$ dune promote |
| 138 |
Promoting _build/default/.mdx/needs-fixes.mld.corrected to needs-fixes.mld. |
| 139 |
$ dune runtest |
| 140 |
|
| 141 |
We also make sure that `:standard` resolves properly: |
| 142 |
|
| 143 |
$ cat > dune <<EOF |
| 144 |
> (mdx |
| 145 |
> (files :standard)) |
| 146 |
> EOF |
| 147 |
$ cat > needs-fixes.mld <<EOF |
| 148 |
> This is a sample mld file. It has some code that is invalid. |
| 149 |
> |
| 150 |
> {[ |
| 151 |
> # List.map (fun x -> x * x) [(1 + 9); 2; 3; 4];; |
| 152 |
> - : int list = [1; 2; 3; 8] |
| 153 |
> ]} |
| 154 |
> |
| 155 |
> A run of MDX should output a fixed version. |
| 156 |
> EOF |
| 157 |
$ dune runtest |
| 158 |
File "needs-fixes.mld", line 1, characters 0-0: |
| 159 |
--- needs-fixes.mld |
| 160 |
+++ .mdx/needs-fixes.mld.corrected |
| 161 |
@@ -2,7 +2,7 @@ |
| 162 |
|
| 163 |
{[ |
| 164 |
# List.map (fun x -> x * x) [(1 + 9); 2; 3; 4];; |
| 165 |
- - : int list = [1; 2; 3; 8] |
| 166 |
+ - : int list = [100; 4; 9; 16] |
| 167 |
]} |
| 168 |
|
| 169 |
A run of MDX should output a fixed version. |
| 170 |
[1] |
| 171 |
$ dune promote |
| 172 |
Promoting _build/default/.mdx/needs-fixes.mld.corrected to needs-fixes.mld. |
| 173 |
$ dune runtest |