Skip to content

Commit c2ea810

Browse files
author
Viviane Garese
committed
Merge branch 'garese/215-interfaces' into 'master'
Fix inclusion of tested unit to driver interface See merge request eng/ide/libadalang-tools!329
2 parents 47542a8 + 6f19362 commit c2ea810

File tree

7 files changed

+59
-17
lines changed

7 files changed

+59
-17
lines changed

src/test-harness.adb

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
-- <http://www.gnu.org/licenses/>. --
2222
------------------------------------------------------------------------------
2323

24+
with Ada.Directories;
2425
with GNATCOLL.JSON;
2526
with GNATCOLL.VFS; use GNATCOLL.VFS;
2627
with GNATCOLL.Traces; use GNATCOLL.Traces;
@@ -3149,43 +3150,43 @@ package body Test.Harness is
31493150
GNATCOLL.Projects.Project_From_Name
31503151
(Source_Project_Tree, P.Name_Of_Extended.all);
31513152

3153+
Exposed_List : constant String_List :=
3154+
Project.Attribute_Value (Interfaces_Attribute).all;
3155+
31523156
Driver_Sources_Present : constant Boolean :=
3153-
P.Sources_List.First = List_Of_Strings.No_Element;
3157+
P.Sources_List.First /= List_Of_Strings.No_Element;
31543158
begin
31553159
S_Put (3, "for Interfaces use (");
31563160

31573161
-- Go through all units exposed in the interface and add them
31583162
-- to the driver's interface.
3159-
declare
3160-
Exposed_List : constant String_List :=
3161-
Project.Attribute_Value (Interfaces_Attribute).all;
3162-
begin
3163-
for Source of Exposed_List loop
3164-
S_Put (0, """" & Source.all & """,");
3165-
end loop;
3166-
end;
3163+
3164+
for Source of Exposed_List loop
3165+
S_Put (0, """" & Source.all & """,");
3166+
end loop;
31673167

31683168
-- If there are source for this test driver, add all of them to
31693169
-- the interface. If not, only add the relevant unit.
31703170

31713171
if Driver_Sources_Present then
3172-
S_Put (0, """" & Base_Name (P.UUT_File_Name.all) & """");
3173-
else
31743172
declare
31753173
Cur : String_Set.Cursor := Sources_Names.First;
31763174
begin
31773175
while Cur /= String_Set.No_Element loop
3178-
S_Put (0, """" & String_Set.Element (Cur) & """");
3179-
3176+
S_Put (0, """" & String_Set.Element (Cur) & """,");
31803177
Next (Cur);
3181-
3182-
if Cur /= String_Set.No_Element then
3183-
S_Put (0, ",");
3184-
end if;
31853178
end loop;
31863179
end;
31873180
end if;
31883181

3182+
-- Always add the unit under test to the interface
3183+
3184+
S_Put
3185+
(0,
3186+
""""
3187+
& Ada.Directories.Simple_Name (P.UUT_File_Name.all)
3188+
& """");
3189+
31893190
S_Put (0, ");");
31903191

31913192
-- Reset the sources list to be added to the interface
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
library project Lib4 is
2+
3+
for Library_Name use "lib4";
4+
for Library_Kind use "static";
5+
for Library_Dir use "lib4";
6+
for Library_Interface use ("Pkg");
7+
for Object_Dir use "obj-lib4";
8+
for Source_Dirs use ("src-lib4");
9+
10+
end Lib4;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
with Pkh;
2+
3+
package body Pkg is
4+
5+
function Foo (X : Positive) return Positive is
6+
begin
7+
return Pkh.Bar (X);
8+
end Foo;
9+
10+
end PKg;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package Pkg is
2+
3+
function Foo (X : Positive) return Positive;
4+
5+
end Pkg;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package body Pkh is
2+
3+
function Bar (X : Positive) return Positive is
4+
begin
5+
return X;
6+
end Bar;
7+
8+
end Pkh;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package Pkh is
2+
3+
function Bar (X : Positive) return Positive;
4+
5+
end Pkh;

testsuite/tests/test/215-interface/test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22

33
gnattest -q -dd -Plib1 --stub
44
gprbuild -q -P obj/gnattest_stub/harness/test_drivers.gpr
5+
6+
gnattest -q -dd -Plib4 --stub
7+
gprbuild -q -P obj-lib4/gnattest_stub/harness/test_drivers.gpr

0 commit comments

Comments
 (0)