gnatcoll_24.0.0_11c512d1/testsuite/tests/projects/type_from_missing_with/test.adb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
with GNATCOLL.Projects; use GNATCOLL.Projects;
with GNATCOLL.VFS;      use GNATCOLL.VFS;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with GNATCOLL.Projects.Aux;
with Ada.Containers.Indefinite_Doubly_Linked_Lists;

with Test_Assert;

function Test return Integer is
   PT              : Project_Tree;
   Env             : Project_Environment_Access;

   package String_Lists is new
     Ada.Containers.Indefinite_Doubly_Linked_Lists (String);
   use String_Lists;

   Lines : String_Lists.List;
   Cur   : String_Lists.Cursor;

   procedure Errors (S : String);
   procedure Errors (S : String) is
   begin
      Lines.Append (S);
   end Errors;

   Load_Failed : Boolean := False;
begin
   Initialize (Env);

   begin
      GNATCOLL.Projects.Load
        (PT,
         Root_Project_Path => Create_From_Base ("p.gpr"),
         Env => Env,
         Recompute_View => False,
         Errors => Errors'Unrestricted_Access);
   exception
      when Invalid_Project =>
         Load_Failed := True;
   end;

   Test_Assert.Assert (Load_Failed, "check that load failed");

   Cur := Lines.First;
   Test_Assert.Assert
     (Index
        (Element (Cur),
         "p.gpr:1:06: imported project file ""Common1.gpr""") /= 0,
      "check first error line");
   Next (Cur);
   Test_Assert.Assert
     (Index
        (Element (Cur),
         "p.gpr:3:10: unknown project ""common""") /= 0,
      "check second error line");
   Lines.Clear;

   GNATCOLL.Projects.Aux.Delete_All_Temp_Files (PT.Root_Project);

   PT.Unload;
   Free (Env);
   return Test_Assert.Report;
end Test;