Skip to content

Commit 29e1029

Browse files
authored
Fix Windows CI line ending normalization in analysis tests (#1189)
1 parent 2bc69d2 commit 29e1029

11 files changed

Lines changed: 19 additions & 284 deletions

File tree

‎.gitattributes‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
* text=auto
2+
*.snap text eol=lf
3+
analysis/tests*/**/expected/*.res.txt text eol=lf
4+
analysis/tests*/**/expected/*.resi.txt text eol=lf
5+
analysis/reanalyze/examples/**/expected/*.txt text eol=lf

‎analysis/reanalyze/examples/deadcode/test.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fi
99
dune exec rescript-editor-analysis -- reanalyze -config -debug -ci -exclude-paths $exclude_dirs -live-names globallyLive1 -live-names globallyLive2,globallyLive3 -suppress $suppress > $output
1010
# CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
1111
if [ "$RUNNER_OS" == "Windows" ]; then
12-
perl -pi -e 's/\r\n/\n/g' -- $output
12+
node ../../../scripts/normalize-lf.js "$output"
1313
fi
1414

1515
output="expected/exception.txt"
@@ -21,7 +21,7 @@ fi
2121
dune exec rescript-editor-analysis -- reanalyze -exception -ci -suppress src -unsuppress $unsuppress_dirs > $output
2222
# CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
2323
if [ "$RUNNER_OS" == "Windows" ]; then
24-
perl -pi -e 's/\r\n/\n/g' -- $output
24+
node ../../../scripts/normalize-lf.js "$output"
2525
fi
2626

2727

‎analysis/reanalyze/examples/termination/test.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ output="expected/termination.txt"
22
dune exec rescript-editor-analysis -- reanalyze -config -ci -debug > $output
33
# CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
44
if [ "$RUNNER_OS" == "Windows" ]; then
5-
perl -pi -e 's/\r\n/\n/g' -- $output
5+
node ../../../scripts/normalize-lf.js "$output"
66
fi
77

88
warningYellow='\033[0;33m'

‎analysis/scripts/normalize-lf.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const fs = require("fs");
2+
3+
for (const file of process.argv.slice(2)) {
4+
const text = fs.readFileSync(file, "utf8");
5+
fs.writeFileSync(file, text.replace(/\r\n/g, "\n").replace(/\r/g, "\n"));
6+
}

‎analysis/tests-generic-jsx-transform/test.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ for file in src/*.res; do
33
../../rescript-editor-analysis.exe test $file &> $output
44
# CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
55
if [ "$RUNNER_OS" == "Windows" ]; then
6-
perl -pi -e 's/\r\n/\n/g' -- $output
6+
node ../scripts/normalize-lf.js "$output"
77
fi
88
done
99

‎analysis/tests-incremental-typechecking/test.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ for file in src/*.res; do
33
../../rescript-editor-analysis.exe test $file &> $output
44
# CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
55
if [ "$RUNNER_OS" == "Windows" ]; then
6-
perl -pi -e 's/\r\n/\n/g' -- $output
6+
node ../scripts/normalize-lf.js "$output"
77
fi
88
done
99

‎analysis/tests/src/expected/DocExtraction2.res.txt‎

Lines changed: 0 additions & 45 deletions
This file was deleted.

‎analysis/tests/src/expected/DocExtraction2.resi.txt‎

Lines changed: 0 additions & 44 deletions
This file was deleted.

‎analysis/tests/src/expected/DocExtractionRes.res.txt‎

Lines changed: 0 additions & 187 deletions
This file was deleted.

‎analysis/tests/test.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ for file in src/*.{res,resi}; do
33
../../rescript-editor-analysis.exe test $file &> $output
44
# CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
55
if [ "$RUNNER_OS" == "Windows" ]; then
6-
perl -pi -e 's/\r\n/\n/g' -- $output
6+
node ../scripts/normalize-lf.js "$output"
77
fi
88
done
99

@@ -12,7 +12,7 @@ for file in not_compiled/*.{res,resi}; do
1212
../../rescript-editor-analysis.exe test $file &> $output
1313
# CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
1414
if [ "$RUNNER_OS" == "Windows" ]; then
15-
perl -pi -e 's/\r\n/\n/g' -- $output
15+
node ../scripts/normalize-lf.js "$output"
1616
fi
1717
done
1818

0 commit comments

Comments
 (0)