diff options
author | Tom Tromey <tom@tromey.com> | 2023-09-15 17:24:26 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-09-29 10:55:43 -0600 |
commit | 4ebfd53de03599b73838ee339e47652ac26c37c0 (patch) | |
tree | 5990de5f860d32aa252dfb7564fbbb56179f737c /gdb/testsuite/gdb.python | |
parent | 2677a57064afd32076b85295bdc11de6e75e7e36 (diff) | |
download | binutils-4ebfd53de03599b73838ee339e47652ac26c37c0.zip binutils-4ebfd53de03599b73838ee339e47652ac26c37c0.tar.gz binutils-4ebfd53de03599b73838ee339e47652ac26c37c0.tar.bz2 |
Support the NO_COLOR environment variable
I ran across this site:
https://no-color.org/
... which lobbies for tools to recognize the NO_COLOR environment
variable and disable any terminal styling when it is seen.
This patch implements this for gdb.
Regression tested on x86-64 Fedora 38.
Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Reviewed-by: Kevin Buettner <kevinb@redhat.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Andrew Burgess <aburgess@redhat.com>
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r-- | gdb/testsuite/gdb.python/py-format-string.exp | 3 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-source-styling.exp | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-startup-opt.exp | 5 |
3 files changed, 3 insertions, 9 deletions
diff --git a/gdb/testsuite/gdb.python/py-format-string.exp b/gdb/testsuite/gdb.python/py-format-string.exp index 55a3776..04d19e4 100644 --- a/gdb/testsuite/gdb.python/py-format-string.exp +++ b/gdb/testsuite/gdb.python/py-format-string.exp @@ -1184,11 +1184,10 @@ with_test_prefix "format_string" { # Perform C Tests. if { [build_inferior "${binfile}" "c"] == 0 } { with_test_prefix "lang_c" { - save_vars { env(TERM) } { + with_ansi_styling_terminal { # We run all of these tests in an environment where styling # could work, but we only expect the final call to # test_styling to actually produce any styled output. - setenv TERM ansi set current_lang "c" prepare_gdb "${binfile}" test_all_common diff --git a/gdb/testsuite/gdb.python/py-source-styling.exp b/gdb/testsuite/gdb.python/py-source-styling.exp index f92d6f7..d3ae339 100644 --- a/gdb/testsuite/gdb.python/py-source-styling.exp +++ b/gdb/testsuite/gdb.python/py-source-styling.exp @@ -20,13 +20,11 @@ load_lib gdb-python.exp standard_testfile -save_vars { env(TERM) } { +with_ansi_styling_terminal { # We need an ANSI-capable terminal to get the output, additionally # we need to set LC_ALL so GDB knows the terminal is UTF-8 # capable, otherwise we'll get a UnicodeEncodeError trying to # encode the output. - setenv TERM ansi - if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { return -1 } diff --git a/gdb/testsuite/gdb.python/py-startup-opt.exp b/gdb/testsuite/gdb.python/py-startup-opt.exp index 08d1c79..729b1c1 100644 --- a/gdb/testsuite/gdb.python/py-startup-opt.exp +++ b/gdb/testsuite/gdb.python/py-startup-opt.exp @@ -97,10 +97,7 @@ proc test_python_settings { exp_state } { gdb_exit } -save_vars { env(TERM) } { - # We need an ANSI-capable terminal to get the output. - setenv TERM ansi - +with_ansi_styling_terminal { # Check the features are off by default. test_python_settings "off" |