* [committed] bootstrap: fix failing diagnostic selftest on Windows [PR98696]
@ 2021-01-15 18:30 David Malcolm
0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2021-01-15 18:30 UTC (permalink / raw)
To: gcc-patches
In one of the selftests in g:f10960558540636800cf5d3d6355969621fbc17e
I didn't consider that paths can contain backslashes, which happens
for the tempfiles on Windows hosts.
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Confirmed by the reporter as fixing the issue on Windows.
Pushed as r11-6730-ga3128bf01289a243a9e0ebb4e34c23bcb04cb938.
gcc/ChangeLog:
PR bootstrap/98696
* diagnostic.c
(selftest::test_print_parseable_fixits_bytes_vs_display_columns):
Escape the tempfile name when constructing the expected output.
---
gcc/diagnostic.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 7d65ac7379f..11ac9064d42 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -2155,7 +2155,12 @@ test_print_parseable_fixits_bytes_vs_display_columns ()
where.m_finish = linemap_position_for_column (line_table, 17);
richloc.add_fixit_replace (where, "color");
- const int buf_len = strlen (fname) + 100;
+ /* Escape fname. */
+ pretty_printer tmp_pp;
+ print_escaped_string (&tmp_pp, fname);
+ char *escaped_fname = xstrdup (pp_formatted_text (&tmp_pp));
+
+ const int buf_len = strlen (escaped_fname) + 100;
char *const expected = XNEWVEC (char, buf_len);
{
@@ -2163,7 +2168,7 @@ test_print_parseable_fixits_bytes_vs_display_columns ()
print_parseable_fixits (&pp, &richloc, DIAGNOSTICS_COLUMN_UNIT_BYTE,
tabstop);
snprintf (expected, buf_len,
- "fix-it:\"%s\":{1:12-1:18}:\"color\"\n", fname);
+ "fix-it:%s:{1:12-1:18}:\"color\"\n", escaped_fname);
ASSERT_STREQ (expected, pp_formatted_text (&pp));
}
{
@@ -2171,11 +2176,12 @@ test_print_parseable_fixits_bytes_vs_display_columns ()
print_parseable_fixits (&pp, &richloc, DIAGNOSTICS_COLUMN_UNIT_DISPLAY,
tabstop);
snprintf (expected, buf_len,
- "fix-it:\"%s\":{1:10-1:16}:\"color\"\n", fname);
+ "fix-it:%s:{1:10-1:16}:\"color\"\n", escaped_fname);
ASSERT_STREQ (expected, pp_formatted_text (&pp));
}
XDELETEVEC (expected);
+ free (escaped_fname);
}
/* Verify that
--
2.26.2
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-01-15 18:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-15 18:30 [committed] bootstrap: fix failing diagnostic selftest on Windows [PR98696] David Malcolm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).