-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'mr/jicquel/#89.aggregate-library-projects-iterator' int…
…o 'master' Iterate over aggregated library projects See merge request eng/toolchain/gnatcoll-core!151
- Loading branch information
Showing
8 changed files
with
142 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
testsuite/tests/projects/aggregated_libraries/project_iterator/test.adb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
------------------------------------------------------------------------------ | ||
-- G N A T C O L L -- | ||
-- -- | ||
-- Copyright (C) 2024, AdaCore -- | ||
-- -- | ||
-- This library is free software; you can redistribute it and/or modify it -- | ||
-- under terms of the GNU General Public License as published by the Free -- | ||
-- Software Foundation; either version 3, or (at your option) any later -- | ||
-- version. This library is distributed in the hope that it will be useful, -- | ||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- | ||
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- | ||
-- -- | ||
-- As a special exception under Section 7 of GPL version 3, you are granted -- | ||
-- additional permissions described in the GCC Runtime Library Exception, -- | ||
-- version 3.1, as published by the Free Software Foundation. -- | ||
-- -- | ||
-- You should have received a copy of the GNU General Public License and -- | ||
-- a copy of the GCC Runtime Library Exception along with this program; -- | ||
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- | ||
-- <http://www.gnu.org/licenses/>. -- | ||
-- -- | ||
-- Test the aggregated libraries project iteration | ||
|
||
with GNATCOLL.Projects; use GNATCOLL.Projects; | ||
with GNATCOLL.VFS; use GNATCOLL.VFS; | ||
with Test_Assert; use Test_Assert; | ||
|
||
function Test return Integer is | ||
PT : Project_Tree; | ||
procedure Silent_Report (S : String) is null; | ||
|
||
procedure Internal (Include_Aggregate_Libraries : Boolean); | ||
|
||
procedure Internal (Include_Aggregate_Libraries : Boolean) is | ||
|
||
Files : File_Array (1 .. 4); | ||
File_Index : Integer := 1; | ||
It : Project_Iterator := | ||
Start | ||
(PT.Root_Project, | ||
Include_Aggregate_Libraries => Include_Aggregate_Libraries); | ||
|
||
begin | ||
while Current (It) /= No_Project loop | ||
Files (File_Index) := Current (It).Project_Path; | ||
Next (It); | ||
File_Index := File_Index + 1; | ||
end loop; | ||
|
||
if Include_Aggregate_Libraries then | ||
Assert (File_Index = 5, "Check that we iterate over 4 projects"); | ||
Sort (Files); | ||
|
||
Assert (Files (1).Display_Base_Name, "agg.gpr", "check 1st project"); | ||
Assert (Files (2).Display_Base_Name, "lib1.gpr", "check 2nd project"); | ||
Assert (Files (3).Display_Base_Name, "lib2.gpr", "check 3rd project"); | ||
Assert (Files (4).Display_Base_Name, "root.gpr", "check 4th project"); | ||
else | ||
Assert (File_Index = 4, "Check that we iterate over 3 projects"); | ||
Sort (Files (1 .. 3)); | ||
|
||
Assert (Files (1).Display_Base_Name, "lib1.gpr", "check 1st project"); | ||
Assert (Files (2).Display_Base_Name, "lib2.gpr", "check 2rd project"); | ||
Assert (Files (3).Display_Base_Name, "root.gpr", "check 3rd project"); | ||
end if; | ||
end Internal; | ||
|
||
begin | ||
PT.Load | ||
(Create ("tree/root.gpr"), Errors => Silent_Report'Unrestricted_Access); | ||
|
||
Internal (True); | ||
Internal (False); | ||
|
||
PT.Unload; | ||
|
||
return Test_Assert.Report; | ||
|
||
end Test; |
4 changes: 4 additions & 0 deletions
4
testsuite/tests/projects/aggregated_libraries/project_iterator/test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
description: Check aggregated libraries project iteration. | ||
data: | ||
- "tree" | ||
- "test.adb" |
11 changes: 11 additions & 0 deletions
11
testsuite/tests/projects/aggregated_libraries/project_iterator/tree/agg.gpr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
aggregate library project Agg is | ||
|
||
for Project_Files use ( | ||
"./lib1.gpr", | ||
"./lib2.gpr" | ||
); | ||
|
||
for Library_Dir use "lib_agg"; | ||
for Library_Name use "agg"; | ||
|
||
end Agg; |
7 changes: 7 additions & 0 deletions
7
testsuite/tests/projects/aggregated_libraries/project_iterator/tree/lib1.gpr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
library project Lib1 is | ||
|
||
for Object_Dir use "obj_lib1"; | ||
for Library_Dir use "lib1"; | ||
for Library_Name use "lib1"; | ||
|
||
end Lib1; |
7 changes: 7 additions & 0 deletions
7
testsuite/tests/projects/aggregated_libraries/project_iterator/tree/lib2.gpr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
library project Lib2 is | ||
|
||
for Object_Dir use "obj_lib2"; | ||
for Library_Dir use "lib2"; | ||
for Library_Name use "lib2"; | ||
|
||
end Lib2; |
5 changes: 5 additions & 0 deletions
5
testsuite/tests/projects/aggregated_libraries/project_iterator/tree/root.gpr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
with "./agg.gpr"; | ||
|
||
project Root is | ||
|
||
end Root; |