Skip to content

Commit

Permalink
test: add a repro case for #6607
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne Millon <me@emillon.org>
  • Loading branch information
emillon committed Dec 2, 2022
1 parent 3b58cf7 commit c170506
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/blackbox-tests/test-cases/dune
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,9 @@
(applies_to patch-back-source-tree)
(enabled_if
(<> %{system} macosx)))

(cram
(applies_to github6607)
(deps
(package stdune)
(package ppx_expect)))
58 changes: 58 additions & 0 deletions test/blackbox-tests/test-cases/github6607.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
This shows that the test suite is impacted by CLICOLOR_FORCE=1 (#6607).
This environment variable should only impact the output of dune, not behavior
visible from within the test suite.

$ cat > dune-project << EOF
> (lang dune 1.0)
> EOF

$ cat > dune << EOF
> (library
> (name l)
> (libraries stdune)
> (preprocess (pps ppx_expect))
> (inline_tests))
> EOF

$ cat > l.ml << EOF
> open[@ocaml.alert "-unstable"] Stdune
>
> let%expect_test _ =
> User_message.print (User_error.make []);
> [%expect]
> EOF

When running with `CLICOLOR_FORCE=0`, no escape codes are present in the output
string. But when it is set to `1`, escape codes are present.
Remarks:
- it is necessary to pipe into `tr` to see the difference because otherwise these
escape codes are stripped by cram, and it is necessary
- it is necessary to call `dune clean` because `dune` does not know that the
runtest depends on `CLICOLOR_FORCE`.

The expected outcome would be that both of these runs output the same corrected
file.

$ CLICOLOR_FORCE=0 dune runtest --auto-promote
File "l.ml", line 1, characters 0-0:
Error: Files _build/default/l.ml and _build/default/l.ml.corrected differ.
Promoting _build/default/l.ml.corrected to l.ml.
[1]
$ < l.ml tr '\033' '?'
open[@ocaml.alert "-unstable"] Stdune

let%expect_test _ =
User_message.print (User_error.make []);
[%expect{| Error: |}]
$ dune clean
$ CLICOLOR_FORCE=1 dune runtest --auto-promote
File "l.ml", line 1, characters 0-0:
Error: Files _build/default/l.ml and _build/default/l.ml.corrected differ.
Promoting _build/default/l.ml.corrected to l.ml.
[1]
$ < l.ml tr '\033' '?'
open[@ocaml.alert "-unstable"] Stdune

let%expect_test _ =
User_message.print (User_error.make []);
[%expect{| ?[1;31mError?[0m: |}]

0 comments on commit c170506

Please sign in to comment.