Skip to content

Commit 1196719

Browse files
author
Viviane Garese
committed
Merge branch '254-regeneration' into 'master'
Forbid use of Subdirs and source dir path with ** Closes #254 See merge request eng/ide/libadalang-tools!311
2 parents 6a6dda8 + 25eee83 commit 1196719

File tree

9 files changed

+76
-0
lines changed

9 files changed

+76
-0
lines changed

src/test-actions.adb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,31 @@ package body Test.Actions is
514514

515515
end if;
516516

517+
-- Forbid specifying a test subdir along with a source directoy path
518+
-- ending with "**".
519+
-- Upon running gnattest twice in a row, the subdirs created during the
520+
-- first run will be taken as source directories during the second,
521+
-- leading to an error.
522+
523+
if (Root_Prj.Has_Attribute (Subdir_Mode_Att)
524+
or else Arg (Cmd, Subdirs) /= null)
525+
and then Root_Prj.Has_Attribute (Source_Dirs_Attribute)
526+
then
527+
for Src_Dir_Path
528+
of Root_Prj.Attribute_Value (Source_Dirs_Attribute).all
529+
loop
530+
if Src_Dir_Path'Length >= 2
531+
and then Src_Dir_Path
532+
(Src_Dir_Path'Last - 1 .. Src_Dir_Path'Last)
533+
= "**"
534+
then
535+
Cmd_Error_No_Help
536+
("cannot specify test subdir along with a source directory"
537+
& " path ending with ""**""");
538+
end if;
539+
end loop;
540+
end if;
541+
517542
if Arg (Cmd, Stubs_Dir) /= null then
518543

519544
Free (Test.Common.Stub_Dir_Name);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
with Ada.Text_IO; use Ada.Text_IO;
2+
3+
with Pkg;
4+
5+
procedure Main is
6+
begin
7+
Put_Line (Pkg.Foo);
8+
end Main;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package body Pkg is
2+
function Foo return String is
3+
begin
4+
return "Foo";
5+
end Foo;
6+
end Pkg;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package Pkg is
2+
function Foo return String;
3+
end Pkg;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
gnattest: cannot specify test subdir along with a source directory path ending with "**"
2+
gnattest: cannot specify test subdir along with a source directory path ending with "**"
3+
>>>program returned status code 1
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
gnattest -q -P test1.gpr
4+
gnattest -q -P test2.gpr --subdirs="my_tests"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
description:
2+
An error message should be emitted when a test subdir name is specified
3+
(either throught --subdir or the Subdir gnattest project attribute) along
4+
with a source directory path ending in "**" in the project file.
5+
This is to avoid gnattest seeing a previouly generated test subdirectory
6+
as a source directory when ran twice in row.
7+
8+
driver: shell_script
9+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
project Test1 is
2+
3+
for Languages use ("Ada");
4+
for Source_Dirs use ("src" & "/**");
5+
for Object_Dir use "obj";
6+
7+
package GNATtest is
8+
for Subdir use "my_tests";
9+
end GNATtest;
10+
11+
end Test1;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
project Test2 is
2+
3+
for Languages use ("Ada");
4+
for Source_Dirs use ("src" & "/**");
5+
for Object_Dir use "obj";
6+
7+
end Test2;

0 commit comments

Comments
 (0)