Skip to content

Commit

Permalink
prep/errors: fix absolute paths handling issues on Windows
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pmderodat committed Nov 8, 2023
1 parent 7a847f2 commit cb00208
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
6 changes: 0 additions & 6 deletions testsuite/drivers/base_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 18 additions & 1 deletion testsuite/tests/prep/errors/main.adb
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/prep/errors/test.out
Original file line number Diff line number Diff line change
Expand Up @@ -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]: <empty list>

Expand Down
1 change: 0 additions & 1 deletion testsuite/tests/prep/errors/test.yaml
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit cb00208

Please sign in to comment.