From dd462ab111c75f6c1c57462c0d421e3cfbd109b0 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sat, 8 Aug 2026 16:13:52 -0300 Subject: [PATCH 1/6] Fix Windows CI --- .gitattributes | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..eba9d8483 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +* text=auto +*.snap text eol=lf +analysis/tests/**/expected/*.res.txt text eol=lf +analysis/tests/**/expected/*.resi.txt text eol=lf From 92fbc2b1f464115e99c979379ce31cdb06405da9 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sat, 8 Aug 2026 16:52:31 -0300 Subject: [PATCH 2/6] Regenerate the tests --- .../tests/src/expected/DocExtraction2.res.txt | 45 ----- .../src/expected/DocExtraction2.resi.txt | 44 ----- .../src/expected/DocExtractionRes.res.txt | 187 ------------------ 3 files changed, 276 deletions(-) delete mode 100644 analysis/tests/src/expected/DocExtraction2.res.txt delete mode 100644 analysis/tests/src/expected/DocExtraction2.resi.txt delete mode 100644 analysis/tests/src/expected/DocExtractionRes.res.txt diff --git a/analysis/tests/src/expected/DocExtraction2.res.txt b/analysis/tests/src/expected/DocExtraction2.res.txt deleted file mode 100644 index 74f2e9cc1..000000000 --- a/analysis/tests/src/expected/DocExtraction2.res.txt +++ /dev/null @@ -1,45 +0,0 @@ -Documentation extraction src/DocExtraction2.res -extracting docs for src/DocExtraction2.res -preferring found resi file for impl: src/DocExtraction2.resi - -{ - "name": "DocExtraction2", - "docstrings": ["Module level doc here."], - "items": [ - { - "id": "DocExtraction2.t", - "kind": "type", - "name": "t", - "signature": "type t", - "docstrings": ["Type t is pretty cool."] - }, - { - "id": "DocExtraction2.make", - "kind": "value", - "name": "make", - "signature": "let make: unit => t", - "docstrings": ["Makerz of stuffz."] - }, - { - "id": "DocExtraction2.InnerModule", - "name": "InnerModule", - "kind": "module", - "docstrings": [], - "items": [ - { - "id": "DocExtraction2.InnerModule.t", - "kind": "type", - "name": "t", - "signature": "type t", - "docstrings": ["This type is also t."] - }, - { - "id": "DocExtraction2.InnerModule.make", - "kind": "value", - "name": "make", - "signature": "let make: unit => t", - "docstrings": ["Maker of tea."] - }] - }] -} - diff --git a/analysis/tests/src/expected/DocExtraction2.resi.txt b/analysis/tests/src/expected/DocExtraction2.resi.txt deleted file mode 100644 index 074ce4ccf..000000000 --- a/analysis/tests/src/expected/DocExtraction2.resi.txt +++ /dev/null @@ -1,44 +0,0 @@ -Documentation extraction src/DocExtraction2.resi -extracting docs for src/DocExtraction2.resi - -{ - "name": "DocExtraction2", - "docstrings": ["Module level doc here."], - "items": [ - { - "id": "DocExtraction2.t", - "kind": "type", - "name": "t", - "signature": "type t", - "docstrings": ["Type t is pretty cool."] - }, - { - "id": "DocExtraction2.make", - "kind": "value", - "name": "make", - "signature": "let make: unit => t", - "docstrings": ["Makerz of stuffz."] - }, - { - "id": "DocExtraction2.InnerModule", - "name": "InnerModule", - "kind": "module", - "docstrings": [], - "items": [ - { - "id": "DocExtraction2.InnerModule.t", - "kind": "type", - "name": "t", - "signature": "type t", - "docstrings": ["This type is also t."] - }, - { - "id": "DocExtraction2.InnerModule.make", - "kind": "value", - "name": "make", - "signature": "let make: unit => t", - "docstrings": ["Maker of tea."] - }] - }] -} - diff --git a/analysis/tests/src/expected/DocExtractionRes.res.txt b/analysis/tests/src/expected/DocExtractionRes.res.txt deleted file mode 100644 index a197ecf56..000000000 --- a/analysis/tests/src/expected/DocExtractionRes.res.txt +++ /dev/null @@ -1,187 +0,0 @@ -Documentation extraction src/DocExtractionRes.res -extracting docs for src/DocExtractionRes.res - -{ - "name": "DocExtractionRes", - "docstrings": ["Module level documentation goes here."], - "items": [ - { - "id": "DocExtractionRes.t", - "kind": "type", - "name": "t", - "signature": "type t = {name: string, online: bool}", - "docstrings": ["This type represents stuff."], - "detail": - { - "kind": "record", - "items": [{ - "name": "name", - "optional": false, - "docstrings": ["The name of the stuff."], - "signature": "string" - }, { - "name": "online", - "optional": false, - "docstrings": ["Whether stuff is online."], - "signature": "bool" - }] - } - }, - { - "id": "DocExtractionRes.make", - "kind": "value", - "name": "make", - "signature": "let make: string => t", - "docstrings": ["Create stuff.\n\n```rescript example\nlet stuff = make(\"My name\")\n```"] - }, - { - "id": "DocExtractionRes.asOffline", - "kind": "value", - "name": "asOffline", - "signature": "let asOffline: t => t", - "docstrings": ["Stuff goes offline."] - }, - { - "id": "DocExtractionRes.SomeConstant\\", - "kind": "value", - "name": "SomeConstant\\", - "signature": "let SomeConstant\\: int", - "docstrings": ["exotic identifier"] - }, - { - "id": "DocExtractionRes.SomeInnerModule", - "name": "SomeInnerModule", - "kind": "module", - "docstrings": ["Another module level docstring here."], - "items": [ - { - "id": "DocExtractionRes.SomeInnerModule.status", - "kind": "type", - "name": "status", - "signature": "type status = Started(t) | Stopped | Idle", - "docstrings": [], - "detail": - { - "kind": "variant", - "items": [ - { - "name": "Started", - "docstrings": ["If this is started or not"], - "signature": "Started(t)" - }, - { - "name": "Stopped", - "docstrings": ["Stopped?"], - "signature": "Stopped" - }, - { - "name": "Idle", - "docstrings": ["Now idle."], - "signature": "Idle" - }] - } - }, - { - "id": "DocExtractionRes.SomeInnerModule.validInputs", - "kind": "type", - "name": "validInputs", - "signature": "type validInputs = [\n | #\"needs-escaping\"\n | #something\n | #status(status)\n | #withPayload(int)\n]", - "docstrings": ["These are all the valid inputs."] - }, - { - "id": "DocExtractionRes.SomeInnerModule.callback", - "kind": "type", - "name": "callback", - "signature": "type callback = (t, ~status: status) => unit", - "docstrings": [] - }] - }, - { - "id": "DocExtractionRes.AnotherModule", - "name": "AnotherModule", - "kind": "module", - "docstrings": ["Mighty fine module here too!"], - "items": [ - { - "id": "DocExtractionRes.LinkedModule", - "kind": "moduleAlias", - "name": "LinkedModule", - "docstrings": ["This links another module. Neat."], - "items": [] - }, - { - "id": "DocExtractionRes.AnotherModule.callback", - "kind": "type", - "name": "callback", - "signature": "type callback = SomeInnerModule.status => unit", - "docstrings": ["Testing what this looks like."] - }, - { - "id": "DocExtractionRes.AnotherModule.isGoodStatus", - "kind": "value", - "name": "isGoodStatus", - "signature": "let isGoodStatus: SomeInnerModule.status => bool", - "docstrings": [] - }, - { - "id": "DocExtractionRes.AnotherModule.someVariantWithInlineRecords", - "kind": "type", - "name": "someVariantWithInlineRecords", - "signature": "type someVariantWithInlineRecords =\n | SomeStuff({offline: bool, online?: bool})", - "docstrings": ["Trying how it looks with an inline record in a variant."], - "detail": - { - "kind": "variant", - "items": [ - { - "name": "SomeStuff", - "docstrings": ["This has inline records..."], - "signature": "SomeStuff({offline: bool, online?: bool})", - "payload": { - "kind": "inlineRecord", - "fields": [{ - "name": "offline", - "optional": false, - "docstrings": [], - "signature": "bool" - }, { - "name": "online", - "optional": true, - "docstrings": ["Is the user online?"], - "signature": "option" - }] - } - }] - } - }, - { - "id": "DocExtractionRes.AnotherModule.domRoot", - "kind": "type", - "name": "domRoot", - "signature": "type domRoot = unit => ReactDOM.Client.Root.t", - "docstrings": ["Callback to get the DOM root..."] - }] - }, - { - "id": "DocExtractionRes.ModuleWithThingsThatShouldNotBeExported", - "name": "ModuleWithThingsThatShouldNotBeExported", - "kind": "module", - "docstrings": [], - "items": [ - { - "id": "DocExtractionRes.ModuleWithThingsThatShouldNotBeExported.t", - "kind": "type", - "name": "t", - "signature": "type t", - "docstrings": ["The type t is stuff."] - }, - { - "id": "DocExtractionRes.ModuleWithThingsThatShouldNotBeExported.make", - "kind": "value", - "name": "make", - "signature": "let make: unit => t", - "docstrings": ["The maker of stuff!"] - }] - }] -} - From 6949d6c61ee6f54b6ff35d7aa14ffc3a702226cc Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sat, 8 Aug 2026 17:16:54 -0300 Subject: [PATCH 3/6] update tests --- .gitattributes | 4 ++-- analysis/tests-generic-jsx-transform/test.sh | 11 ++++++++++- analysis/tests-incremental-typechecking/test.sh | 11 ++++++++++- analysis/tests/test.sh | 13 +++++++++++-- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/.gitattributes b/.gitattributes index eba9d8483..830247de1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,4 @@ * text=auto *.snap text eol=lf -analysis/tests/**/expected/*.res.txt text eol=lf -analysis/tests/**/expected/*.resi.txt text eol=lf +analysis/tests*/**/expected/*.res.txt text eol=lf +analysis/tests*/**/expected/*.resi.txt text eol=lf diff --git a/analysis/tests-generic-jsx-transform/test.sh b/analysis/tests-generic-jsx-transform/test.sh index ec23433ba..f65f38562 100755 --- a/analysis/tests-generic-jsx-transform/test.sh +++ b/analysis/tests-generic-jsx-transform/test.sh @@ -1,9 +1,18 @@ +normalize_lf() { + node -e ' +const fs = require("fs"); +const file = process.argv[1]; +const text = fs.readFileSync(file, "utf8").replace(/\r\n/g, "\n").replace(/\r/g, "\n"); +fs.writeFileSync(file, text); +' "$1" +} + for file in src/*.res; do output="$(dirname $file)/expected/$(basename $file).txt" ../../rescript-editor-analysis.exe test $file &> $output # CI. We use LF, and the CI OCaml fork prints CRLF. Convert. if [ "$RUNNER_OS" == "Windows" ]; then - perl -pi -e 's/\r\n/\n/g' -- $output + normalize_lf "$output" fi done diff --git a/analysis/tests-incremental-typechecking/test.sh b/analysis/tests-incremental-typechecking/test.sh index ec23433ba..f65f38562 100755 --- a/analysis/tests-incremental-typechecking/test.sh +++ b/analysis/tests-incremental-typechecking/test.sh @@ -1,9 +1,18 @@ +normalize_lf() { + node -e ' +const fs = require("fs"); +const file = process.argv[1]; +const text = fs.readFileSync(file, "utf8").replace(/\r\n/g, "\n").replace(/\r/g, "\n"); +fs.writeFileSync(file, text); +' "$1" +} + for file in src/*.res; do output="$(dirname $file)/expected/$(basename $file).txt" ../../rescript-editor-analysis.exe test $file &> $output # CI. We use LF, and the CI OCaml fork prints CRLF. Convert. if [ "$RUNNER_OS" == "Windows" ]; then - perl -pi -e 's/\r\n/\n/g' -- $output + normalize_lf "$output" fi done diff --git a/analysis/tests/test.sh b/analysis/tests/test.sh index 71a43c26e..a78e75150 100755 --- a/analysis/tests/test.sh +++ b/analysis/tests/test.sh @@ -1,9 +1,18 @@ +normalize_lf() { + node -e ' +const fs = require("fs"); +const file = process.argv[1]; +const text = fs.readFileSync(file, "utf8").replace(/\r\n/g, "\n").replace(/\r/g, "\n"); +fs.writeFileSync(file, text); +' "$1" +} + for file in src/*.{res,resi}; do output="$(dirname $file)/expected/$(basename $file).txt" ../../rescript-editor-analysis.exe test $file &> $output # CI. We use LF, and the CI OCaml fork prints CRLF. Convert. if [ "$RUNNER_OS" == "Windows" ]; then - perl -pi -e 's/\r\n/\n/g' -- $output + normalize_lf "$output" fi done @@ -12,7 +21,7 @@ for file in not_compiled/*.{res,resi}; do ../../rescript-editor-analysis.exe test $file &> $output # CI. We use LF, and the CI OCaml fork prints CRLF. Convert. if [ "$RUNNER_OS" == "Windows" ]; then - perl -pi -e 's/\r\n/\n/g' -- $output + normalize_lf "$output" fi done From 9d0baa62fc55cbc8414cf7dee401542dca84f9d0 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sat, 8 Aug 2026 18:37:24 -0300 Subject: [PATCH 4/6] update --- .gitattributes | 1 + analysis/reanalyze/examples/deadcode/test.sh | 4 ++-- analysis/reanalyze/examples/termination/test.sh | 2 +- analysis/scripts/normalize-lf.js | 6 ++++++ analysis/tests-generic-jsx-transform/test.sh | 11 +---------- analysis/tests-incremental-typechecking/test.sh | 11 +---------- analysis/tests/test.sh | 13 ++----------- 7 files changed, 14 insertions(+), 34 deletions(-) create mode 100644 analysis/scripts/normalize-lf.js diff --git a/.gitattributes b/.gitattributes index 830247de1..46ccffcf7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,3 +2,4 @@ *.snap text eol=lf analysis/tests*/**/expected/*.res.txt text eol=lf analysis/tests*/**/expected/*.resi.txt text eol=lf +analysis/reanalyze/examples/**/expected/*.txt text eol=lf diff --git a/analysis/reanalyze/examples/deadcode/test.sh b/analysis/reanalyze/examples/deadcode/test.sh index ea28ad778..de971ac43 100755 --- a/analysis/reanalyze/examples/deadcode/test.sh +++ b/analysis/reanalyze/examples/deadcode/test.sh @@ -9,7 +9,7 @@ fi dune exec rescript-editor-analysis -- reanalyze -config -debug -ci -exclude-paths $exclude_dirs -live-names globallyLive1 -live-names globallyLive2,globallyLive3 -suppress $suppress > $output # CI. We use LF, and the CI OCaml fork prints CRLF. Convert. if [ "$RUNNER_OS" == "Windows" ]; then - perl -pi -e 's/\r\n/\n/g' -- $output + node ../../../scripts/normalize-lf.js "$output" fi output="expected/exception.txt" @@ -21,7 +21,7 @@ fi dune exec rescript-editor-analysis -- reanalyze -exception -ci -suppress src -unsuppress $unsuppress_dirs > $output # CI. We use LF, and the CI OCaml fork prints CRLF. Convert. if [ "$RUNNER_OS" == "Windows" ]; then - perl -pi -e 's/\r\n/\n/g' -- $output + node ../../../scripts/normalize-lf.js "$output" fi diff --git a/analysis/reanalyze/examples/termination/test.sh b/analysis/reanalyze/examples/termination/test.sh index 3897ae695..cadf918c8 100755 --- a/analysis/reanalyze/examples/termination/test.sh +++ b/analysis/reanalyze/examples/termination/test.sh @@ -2,7 +2,7 @@ output="expected/termination.txt" dune exec rescript-editor-analysis -- reanalyze -config -ci -debug > $output # CI. We use LF, and the CI OCaml fork prints CRLF. Convert. if [ "$RUNNER_OS" == "Windows" ]; then - perl -pi -e 's/\r\n/\n/g' -- $output + node ../../../scripts/normalize-lf.js "$output" fi warningYellow='\033[0;33m' diff --git a/analysis/scripts/normalize-lf.js b/analysis/scripts/normalize-lf.js new file mode 100644 index 000000000..b0bc34b63 --- /dev/null +++ b/analysis/scripts/normalize-lf.js @@ -0,0 +1,6 @@ +const fs = require("fs"); + +for (const file of process.argv.slice(2)) { + const text = fs.readFileSync(file, "utf8"); + fs.writeFileSync(file, text.replace(/\r\n/g, "\n").replace(/\r/g, "\n")); +} diff --git a/analysis/tests-generic-jsx-transform/test.sh b/analysis/tests-generic-jsx-transform/test.sh index f65f38562..0f0d14c81 100755 --- a/analysis/tests-generic-jsx-transform/test.sh +++ b/analysis/tests-generic-jsx-transform/test.sh @@ -1,18 +1,9 @@ -normalize_lf() { - node -e ' -const fs = require("fs"); -const file = process.argv[1]; -const text = fs.readFileSync(file, "utf8").replace(/\r\n/g, "\n").replace(/\r/g, "\n"); -fs.writeFileSync(file, text); -' "$1" -} - for file in src/*.res; do output="$(dirname $file)/expected/$(basename $file).txt" ../../rescript-editor-analysis.exe test $file &> $output # CI. We use LF, and the CI OCaml fork prints CRLF. Convert. if [ "$RUNNER_OS" == "Windows" ]; then - normalize_lf "$output" + node ../scripts/normalize-lf.js "$output" fi done diff --git a/analysis/tests-incremental-typechecking/test.sh b/analysis/tests-incremental-typechecking/test.sh index f65f38562..0f0d14c81 100755 --- a/analysis/tests-incremental-typechecking/test.sh +++ b/analysis/tests-incremental-typechecking/test.sh @@ -1,18 +1,9 @@ -normalize_lf() { - node -e ' -const fs = require("fs"); -const file = process.argv[1]; -const text = fs.readFileSync(file, "utf8").replace(/\r\n/g, "\n").replace(/\r/g, "\n"); -fs.writeFileSync(file, text); -' "$1" -} - for file in src/*.res; do output="$(dirname $file)/expected/$(basename $file).txt" ../../rescript-editor-analysis.exe test $file &> $output # CI. We use LF, and the CI OCaml fork prints CRLF. Convert. if [ "$RUNNER_OS" == "Windows" ]; then - normalize_lf "$output" + node ../scripts/normalize-lf.js "$output" fi done diff --git a/analysis/tests/test.sh b/analysis/tests/test.sh index a78e75150..a8e8039a4 100755 --- a/analysis/tests/test.sh +++ b/analysis/tests/test.sh @@ -1,18 +1,9 @@ -normalize_lf() { - node -e ' -const fs = require("fs"); -const file = process.argv[1]; -const text = fs.readFileSync(file, "utf8").replace(/\r\n/g, "\n").replace(/\r/g, "\n"); -fs.writeFileSync(file, text); -' "$1" -} - for file in src/*.{res,resi}; do output="$(dirname $file)/expected/$(basename $file).txt" ../../rescript-editor-analysis.exe test $file &> $output # CI. We use LF, and the CI OCaml fork prints CRLF. Convert. if [ "$RUNNER_OS" == "Windows" ]; then - normalize_lf "$output" + node ../scripts/normalize-lf.js "$output" fi done @@ -21,7 +12,7 @@ for file in not_compiled/*.{res,resi}; do ../../rescript-editor-analysis.exe test $file &> $output # CI. We use LF, and the CI OCaml fork prints CRLF. Convert. if [ "$RUNNER_OS" == "Windows" ]; then - normalize_lf "$output" + node ../scripts/normalize-lf.js "$output" fi done From 8d7fe95e97a7f0c18521874dc79b55cbc0bd3f11 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sat, 8 Aug 2026 19:01:14 -0300 Subject: [PATCH 5/6] fix tools tests --- tools/tests/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/tests/test.sh b/tools/tests/test.sh index 4a002d8f1..6227da143 100755 --- a/tools/tests/test.sh +++ b/tools/tests/test.sh @@ -3,7 +3,7 @@ for file in src/*.{res,resi}; do dune exec --no-print-directory -- rescript-tools doc $file > $output # # CI. We use LF, and the CI OCaml fork prints CRLF. Convert. if [ "$RUNNER_OS" == "Windows" ]; then - perl -pi -e 's/\r\n/\n/g' -- $output + node ../../../scripts/normalize-lf.js "$output" fi done From a833d5ae48bbe57fd0b6c42efcb9a8c80adc9eeb Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sat, 8 Aug 2026 19:11:57 -0300 Subject: [PATCH 6/6] fix script path --- tools/tests/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/tests/test.sh b/tools/tests/test.sh index 6227da143..fc40d2c04 100755 --- a/tools/tests/test.sh +++ b/tools/tests/test.sh @@ -3,7 +3,7 @@ for file in src/*.{res,resi}; do dune exec --no-print-directory -- rescript-tools doc $file > $output # # CI. We use LF, and the CI OCaml fork prints CRLF. Convert. if [ "$RUNNER_OS" == "Windows" ]; then - node ../../../scripts/normalize-lf.js "$output" + node ../../analysis/scripts/normalize-lf.js "$output" fi done