From cb0020804364f82957f5ca83f3e2c5a32c5ffff1 Mon Sep 17 00:00:00 2001 From: Pierre-Marie de Rodat Date: Wed, 8 Nov 2023 14:51:31 +0000 Subject: [PATCH] prep/errors: fix absolute paths handling issues on Windows Absolute paths on Windows can be hard to predict (C:\foo, C:/foo, c:\foo, ...) and thus to remove in a robust way. Instead of trying to post-process them, do not include them in baselines in the first place. Also remove the test driver mechanism we introduced just for that case. --- testsuite/drivers/base_driver.py | 6 ------ testsuite/tests/prep/errors/main.adb | 19 ++++++++++++++++++- testsuite/tests/prep/errors/test.out | 2 +- testsuite/tests/prep/errors/test.yaml | 1 - 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/testsuite/drivers/base_driver.py b/testsuite/drivers/base_driver.py index ec70921a9..8d461e9c9 100644 --- a/testsuite/drivers/base_driver.py +++ b/testsuite/drivers/base_driver.py @@ -118,12 +118,6 @@ def output_refiners(self): if self.test_env.get("canonicalize_directory_separators", False): result.append(Substitute("\\", "/")) - # If requested, replace occurences of the working directory - if self.test_env.get("canonicalize_working_dir", False): - result.append( - Substitute(self.working_dir(), "[working-dir]") - ) - return result @property diff --git a/testsuite/tests/prep/errors/main.adb b/testsuite/tests/prep/errors/main.adb index 6884e66a6..327a3e461 100644 --- a/testsuite/tests/prep/errors/main.adb +++ b/testsuite/tests/prep/errors/main.adb @@ -26,7 +26,24 @@ procedure Main is New_Line; if U.Has_Diagnostics then for D of U.Diagnostics loop - Put_Line (U.Format_GNU_Diagnostic (D)); + + -- Remove absolute paths from error messages to have consistent + -- baselines. + + declare + Msg : constant String := U.Format_GNU_Diagnostic (D); + Prefix : constant String := + "no_such_file.adb: Cannot open "; + begin + if Msg'Length > Prefix'Length + and then Msg (Msg'First .. Msg'First + Prefix'Length - 1) + = Prefix + then + Put_Line (Prefix & "[...]"); + else + Put_Line (Msg); + end if; + end; end loop; New_Line; end if; diff --git a/testsuite/tests/prep/errors/test.out b/testsuite/tests/prep/errors/test.out index 7c8dfe3c6..6176734d8 100644 --- a/testsuite/tests/prep/errors/test.out +++ b/testsuite/tests/prep/errors/test.out @@ -13,7 +13,7 @@ PragmaNodeList[1:1-1:19] == no_such_file.adb == -no_such_file.adb: Cannot open [working-dir]/no_such_file.adb +no_such_file.adb: Cannot open [...] CompilationUnitList[1:1-1:1]: diff --git a/testsuite/tests/prep/errors/test.yaml b/testsuite/tests/prep/errors/test.yaml index 81e0c307a..e13858de8 100644 --- a/testsuite/tests/prep/errors/test.yaml +++ b/testsuite/tests/prep/errors/test.yaml @@ -1,5 +1,4 @@ driver: ada-api main: main.adb -canonicalize_working_dir: true control: - [XFAIL, "valgrind", "Pending resolution of eng/gpr/gpr-issues#43"]