diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..46ccffcf7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +* text=auto +*.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 ec23433ba..0f0d14c81 100755 --- a/analysis/tests-generic-jsx-transform/test.sh +++ b/analysis/tests-generic-jsx-transform/test.sh @@ -3,7 +3,7 @@ for file in src/*.res; 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 + 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 ec23433ba..0f0d14c81 100755 --- a/analysis/tests-incremental-typechecking/test.sh +++ b/analysis/tests-incremental-typechecking/test.sh @@ -3,7 +3,7 @@ for file in src/*.res; 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 + node ../scripts/normalize-lf.js "$output" fi done 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!"] - }] - }] -} - diff --git a/analysis/tests/test.sh b/analysis/tests/test.sh index 71a43c26e..a8e8039a4 100755 --- a/analysis/tests/test.sh +++ b/analysis/tests/test.sh @@ -3,7 +3,7 @@ for file in src/*.{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 + node ../scripts/normalize-lf.js "$output" fi done @@ -12,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 - perl -pi -e 's/\r\n/\n/g' -- $output + node ../scripts/normalize-lf.js "$output" fi done diff --git a/tools/tests/test.sh b/tools/tests/test.sh index 4a002d8f1..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 - perl -pi -e 's/\r\n/\n/g' -- $output + node ../../analysis/scripts/normalize-lf.js "$output" fi done