]> git.ipfire.org Git - people/ms/gcc.git/commit
diagnostics: Fix up selftests with $COLUMNS < 42 [PR108973]
authorJakub Jelinek <jakub@redhat.com>
Sat, 4 Mar 2023 08:48:17 +0000 (09:48 +0100)
committerJakub Jelinek <jakub@redhat.com>
Sun, 19 Mar 2023 05:28:54 +0000 (06:28 +0100)
commit643985d91512fb8762623034d36d3f48a8b1c282
tree29d32de174cfec6a7080aa13022c431aebb016bf
parentd0e59b5e849258ab00c82ccab37c5e8246a41c6a
diagnostics: Fix up selftests with $COLUMNS < 42 [PR108973]

As mentioned in the PR, GCC's diagnostics self-tests fail if $COLUMNS < 42.
Guarding each self-test with if (get_terminal_width () > 41) or similar
would be a maintainance nightmare (PR has a patch to do so without
reformatting to make it work for $COLUMNS in [30, 41] inclusive, but
I'm afraid going down to $COLUMNS 1 would mean marking everything).
Furthermore, the self-tests don't really emit stuff to the terminal,
but into a buffer, so using get_terminal_width () for it seems
inappropriate.  The following patch makes sure test_diagnostic_context
constructor uses exactly 80 columns wide caret max width, of course
some tests override it already if they want to test for behavior in narrower
cases.

2023-03-04  Jakub Jelinek  <jakub@redhat.com>

PR testsuite/108973
* selftest-diagnostic.cc
(test_diagnostic_context::test_diagnostic_context): Set
caret_max_width to 80.

(cherry picked from commit 739e7ebb3d378ece25d64b39baae47c584253498)
gcc/selftest-diagnostic.cc