|
| 1 | +with GNATCOLL.Projects; use GNATCOLL.Projects; |
| 2 | +with GNATCOLL.VFS; use GNATCOLL.VFS; |
| 3 | +with Test_Assert; use Test_Assert; |
| 4 | +with Ada.Directories; |
| 5 | +with Ada.Direct_IO; |
| 6 | +with Ada.Strings.Fixed; use Ada.Strings.Fixed; |
| 7 | + |
| 8 | +function Test return Integer is |
| 9 | + Tree : Project_Tree; |
| 10 | + Proj_File : constant String := "p.gpr"; |
| 11 | + Proj : Project_Type; |
| 12 | + Dummy : Boolean; |
| 13 | + |
| 14 | + function Read_File (File_Name : String) return String; |
| 15 | + -- Read a file and return its content as a String |
| 16 | + |
| 17 | + function Read_File (File_Name : String) return String |
| 18 | + is |
| 19 | + File_Size : constant Natural := |
| 20 | + Natural (Ada.Directories.Size (File_Name)); |
| 21 | + |
| 22 | + subtype File_String is String (1 .. File_Size); |
| 23 | + package File_String_IO is new Ada.Direct_IO (File_String); |
| 24 | + |
| 25 | + File : File_String_IO.File_Type; |
| 26 | + Contents : File_String; |
| 27 | + |
| 28 | + begin |
| 29 | + File_String_IO.Open (File, Mode => File_String_IO.In_File, |
| 30 | + Name => File_Name); |
| 31 | + File_String_IO.Read (File, Item => Contents); |
| 32 | + File_String_IO.Close (File); |
| 33 | + |
| 34 | + return String (Contents); |
| 35 | + end Read_File; |
| 36 | + |
| 37 | +begin |
| 38 | + Tree.Load (Create (Filesystem_String (Proj_File))); |
| 39 | + |
| 40 | + Proj := Tree.Root_Project; |
| 41 | + Proj.Rename_And_Move |
| 42 | + ("foobar_" & Proj.Name, Create |
| 43 | + (Filesystem_String |
| 44 | + (Ada.Directories.Containing_Directory |
| 45 | + (+Proj.Project_Path.Full_Name)))); |
| 46 | + |
| 47 | + Tree.Recompute_View; |
| 48 | + Dummy := Proj.Save; |
| 49 | + |
| 50 | + declare |
| 51 | + Content : constant String := Read_File ("foobar_" & Proj_File); |
| 52 | + begin |
| 53 | + -- Check that the separator are not removed |
| 54 | + |
| 55 | + Assert (Index (Content, """src/"" & ""subsrc/""") > 0); |
| 56 | + |
| 57 | + -- Check that the project name has been updated |
| 58 | + |
| 59 | + Assert (Index (Content, "Foobar_P") > 0); |
| 60 | + end; |
| 61 | + |
| 62 | + return Report; |
| 63 | +end Test; |
0 commit comments