File tree Expand file tree Collapse file tree 8 files changed +65
-13
lines changed
testsuite/tests/147-slug_collision Expand file tree Collapse file tree 8 files changed +65
-13
lines changed Original file line number Diff line number Diff line change 1+ package body Pkg.Child is
2+
3+ function Foo (X : Integer) return Integer is
4+ begin
5+ return X; -- # stmt
6+ end Foo ;
7+
8+ end Pkg.Child ;
Original file line number Diff line number Diff line change 1+ package Pkg.Child is
2+ function Foo (X : Integer) return Integer;
3+ end Pkg.Child ;
Original file line number Diff line number Diff line change 1+ package Pkg is
2+ end Pkg ;
Original file line number Diff line number Diff line change 1+ package body Pkg_Child is
2+
3+ function Bar (X : Integer) return Integer is
4+ begin
5+ return X; -- # stmt
6+ end Bar ;
7+
8+ end Pkg_Child ;
Original file line number Diff line number Diff line change 1+ package Pkg_Child is
2+ function Bar (X : Integer) return Integer;
3+ end Pkg_Child ;
Original file line number Diff line number Diff line change 1+ with Support ; use Support;
2+
3+ with Pkg.Child ;
4+ with Pkg_Child ;
5+
6+ procedure Test_Collision is
7+ begin
8+ Assert (Pkg.Child.Foo (3 ) = Pkg_Child.Bar (3 ));
9+ end Test_Collision ;
10+
11+ -- # pkg-child.adb pkg_child.adb
12+ --
13+ -- /stmt/ l+ ## 0
Original file line number Diff line number Diff line change 1+ """
2+ Regression test: gnatcov used to generated homonym buffer units for a
3+ "Pkg.Child" unit and a "Pkg_Child" unit, as well as duplicate constant
4+ declarations in some generated units, which prevented the build of the
5+ instrumented sources.
6+ """
7+
8+ from SCOV .tc import TestCase
9+ from SCOV .tctl import CAT
10+ from SUITE .context import thistest
11+
12+
13+ TestCase (category = CAT .stmt ).run ()
14+ thistest .result ()
Original file line number Diff line number Diff line change @@ -154,18 +154,6 @@ package body Instrument is
154154 First : Boolean := True;
155155 Result : Ada_Identifier;
156156 begin
157- if Use_Hash then
158-
159- -- Prefix the hash with "z_" to ensure the unit name slug doesn't
160- -- start with a digit.
161-
162- return
163- " z" & Strip_Zero_Padding
164- (Hex_Image
165- (Unsigned_32
166- (Ada.Strings.Hash (To_Symbol_Name (Name)))));
167- end if ;
168-
169157 -- Create a unique slug from the qualified name: replace occurrences of
170158 -- 'z' with 'zz' and insert '_z_' between identifiers.
171159
@@ -187,7 +175,20 @@ package body Instrument is
187175 end ;
188176 end loop ;
189177 end loop ;
190- return To_String (Result);
178+
179+ if Use_Hash then
180+
181+ -- Prefix the hash with "z" to ensure the unit name slug doesn't
182+ -- start with a digit.
183+
184+ return
185+ " z" & Strip_Zero_Padding
186+ (Hex_Image
187+ (Unsigned_32
188+ (Ada.Strings.Hash (To_String (Result)))));
189+ else
190+ return To_String (Result);
191+ end if ;
191192 end Qualified_Name_Slug ;
192193
193194 -- --------------------------
You can’t perform that action at this time.
0 commit comments