-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use colored output with GCC and Clang
The flag -fdiagnostics-color=always is added to the :standard set of flags for C stubs, which can be easily removed by the user if needed. Signed-off-by: Antonin Décimo <antonin@tarides.com>
- Loading branch information
Showing
7 changed files
with
82 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
test/blackbox-tests/test-cases/c-flags-diagnostics-color.t/dune-project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(lang dune 3.5) |
53 changes: 53 additions & 0 deletions
53
test/blackbox-tests/test-cases/c-flags-diagnostics-color.t/run.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
This test won't work with MSVC as it's using GCC and clang CLI | ||
parameters. | ||
|
||
We have to force Dune outputting colors, for that we use | ||
`CLICOLOR_FORCE=1`. | ||
|
||
The flag should be present in the command, as we want it in the | ||
:standard set. | ||
|
||
We don't actually test that the compiler outputs colors, just that | ||
Dune correctly passes the flag when required, and doesn't when it's | ||
not. | ||
|
||
test, color enabled, color flag default (enabled) | ||
================================================= | ||
|
||
$ cat >dune <<EOF | ||
> (library | ||
> (name test) | ||
> (foreign_stubs (language c) (names stub))) | ||
> EOF | ||
|
||
$ CLICOLOR_FORCE=1 dune rules -m stub.o | grep -ce "-fdiagnostics-color=always" | ||
1 | ||
|
||
test, color enabled, color flag disabled | ||
======================================== | ||
|
||
$ cat >dune <<EOF | ||
> (library | ||
> (name test) | ||
> (foreign_stubs | ||
> (flags :standard \ -fdiagnostics-color=always) | ||
> (language c) (names stub))) | ||
> EOF | ||
|
||
$ CLICOLOR_FORCE=1 dune rules -m stub.o | grep -ce "-fdiagnostics-color=always" | ||
0 | ||
[1] | ||
|
||
test, color disabled, color flag default (enabled) | ||
================================================== | ||
|
||
$ cat >dune <<EOF | ||
> (library | ||
> (name test) | ||
> (foreign_stubs | ||
> (language c) (names stub))) | ||
> EOF | ||
|
||
$ CLICOLOR=0 dune rules -m stub.o | grep -ce "-fdiagnostics-color=always" | ||
0 | ||
[1] |
1 change: 1 addition & 0 deletions
1
test/blackbox-tests/test-cases/c-flags-diagnostics-color.t/stub.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#error "error message" |