]> gcc.gnu.org Git - gcc.git/commit
testsuite: always use UTF-8 in scan-sarif-file[-not] [PR105959]
authorDavid Malcolm <dmalcolm@redhat.com>
Wed, 22 Mar 2023 20:48:27 +0000 (16:48 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Wed, 22 Mar 2023 20:48:40 +0000 (16:48 -0400)
commit6b2740946d26ffde7e1318f24bae00443ece387d
tree43375f753ef75417a89df2d0b924049e2f220dbc
parente3af2b64ab9e3d16b3b8d30b9e2e4b9755b807f9
testsuite: always use UTF-8 in scan-sarif-file[-not] [PR105959]

c-c++-common/diagnostic-format-sarif-file-4.c is a test case for
quoting non-ASCII source code in a SARIF diagnostic log.

The SARIF standard mandates that .sarif files are UTF-8 encoded.

PR testsuite/105959 notes that the test case fails when the system
encoding is not UTF-8, such as when the "make" invocation is prefixed
with LC_ALL=C, whereas it works with in a UTF-8-locale.

The root cause is that dg-scan opens the file for reading using the
"system" encoding; I believe it is falling back to treating all files as
effectively ISO 8859-1 in a non-UTF-8 locale.

This patch fixes things by adding a mechanism to dg-scan to allow
callers to (optionally) specify an encoding to use when reading the
file, and updating scan-sarif-file (and the -not variant) to always
use UTF-8 when calling dg-scan, fixing the test case with LC_ALL=C.

gcc/testsuite/ChangeLog:
PR testsuite/105959
* gcc.dg-selftests/dg-final.exp
(dg_final_directive_check_num_args): Update expected maximum
number of args for the various directives using dg-scan.
* lib/scanasm.exp (append_encoding_arg): New procedure.
(dg-scan): Add optional 3rd argument: the encoding to use when
reading from the file.
* lib/scansarif.exp (scan-sarif-file): Treat the file as UTF-8
encoded when reading it.
(scan-sarif-file-not): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/testsuite/gcc.dg-selftests/dg-final.exp
gcc/testsuite/lib/scanasm.exp
gcc/testsuite/lib/scansarif.exp
This page took 0.054553 seconds and 5 git commands to generate.