Skip to content

Commit 039d6e2

Browse files
committed
tests/file_paths: canonicalize directory separators
Turn backslashes into forward slashes to remove output discrepancies between Windows and Unix platforms. TN: V117-037 Change-Id: I87fdf9fe82623a31351804fbba13753491d1a323
1 parent bb8580c commit 039d6e2

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

testsuite/tests/file_paths/test.adb

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,30 @@ procedure Test is
3030

3131
function Filename_Image (Filename : String) return String is
3232
F : constant Virtual_File := Create (+Filename);
33+
34+
function Canonicalize (S : String) return String;
35+
-- Canonicalize backslashes to forward slashes
36+
37+
------------------
38+
-- Canonicalize --
39+
------------------
40+
41+
function Canonicalize (S : String) return String is
42+
begin
43+
return R : String := S do
44+
for C of R loop
45+
if C = '\' then
46+
C := '/';
47+
end if;
48+
end loop;
49+
end return;
50+
end Canonicalize;
51+
3352
begin
3453
if F.Is_Absolute_Path then
35-
return "abs(""" & (+F.Relative_Path (CWD)) & """)";
54+
return "abs(""" & Canonicalize (+F.Relative_Path (CWD)) & """)";
3655
else
37-
return """" & Filename & """";
56+
return """" & Canonicalize (Filename) & """";
3857
end if;
3958
end Filename_Image;
4059

@@ -68,7 +87,7 @@ procedure Test is
6887
begin
6988
-- The empty path is equivalent to the current working directory
7089

71-
Check ("", Path_Separator, If_Empty);
90+
Check ("", ':', If_Empty);
7291

7392
-- First items in the path have priority
7493

0 commit comments

Comments
 (0)