Skip to content

Commit b9bb6d9

Browse files
committed
disable color in docstring format tests since it breaks in different environments in CI
1 parent f32fa15 commit b9bb6d9

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

tests/tools_tests/src/expected/FormatDocstringsTestError.res.expected

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
Syntax error in code block in docstring
33
FormatDocstringsTestError.res:5:10-6:3
44

5-
3 │
6-
4 │
7-
5 │ let name= 
8-
6 │ let x=12
5+
3
6+
4
7+
5 │ let name=
8+
6 │ let x=12
99

1010
This let-binding misses an expression
1111

tests/tools_tests/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ done
1919
# Test format-docstrings command
2020
for file in src/docstrings-format/*.{res,resi}; do
2121
output="src/expected/$(basename $file).expected"
22-
../../_build/install/default/bin/rescript-tools format-docstrings "$file" --stdout > $output
22+
DISABLE_COLOR=true ../../_build/install/default/bin/rescript-tools format-docstrings "$file" --stdout > $output
2323
# # CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
2424
if [ "$RUNNER_OS" == "Windows" ]; then
2525
perl -pi -e 's/\r\n/\n/g' -- $output

tools/bin/main.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ let main () =
5454
logAndExit (Tools.extractDocs ~entryPointFile:path ~debug:false)
5555
| _ -> logAndExit (Error docHelp))
5656
| "format-docstrings" :: rest -> (
57+
(try
58+
match Sys.getenv "DISABLE_COLOR" with
59+
| "true" -> Clflags.color := Some Misc.Color.Never
60+
| _ -> ()
61+
with Not_found -> ());
5762
match rest with
5863
| ["-h"] | ["--help"] -> logAndExit (Ok formatDocstringsHelp)
5964
| [path; "--stdout"] -> (

tools/src/tools.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ module FormatDocstrings = struct
764764
~display_filename:displayFilename ~source:codeWithOffset
765765
in
766766
if invalid then (
767-
let buf = Buffer.create 32 in
767+
let buf = Buffer.create 1000 in
768768
let formatter = Format.formatter_of_buffer buf in
769769
Res_diagnostics.print_report ~formatter
770770
~custom_intro:(Some "Syntax error in code block in docstring")

0 commit comments

Comments
 (0)