Skip to content

Commit

Permalink
Merge branch 'mr/backport/release-25.1-issue-eng/ide/libadalang-tools…
Browse files Browse the repository at this point in the history
…_36' into '25.1'

[25.1] Backport of eng/ide/libadalang-tools#36

See merge request eng/ide/libadalang-tools!279
  • Loading branch information
leocreuse committed Dec 16, 2024
2 parents 8ea35b3 + 93822d4 commit f001c31
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/test-stub.adb
Original file line number Diff line number Diff line change
Expand Up @@ -3666,7 +3666,7 @@ package body Test.Stub is
S_Put (0, GT_Marker_End);
New_Line_Count;

Put_Lines (MD, Comment_Out => False);
Put_Lines (MD, Comment_Out => True);

S_Put (0, GT_Marker_Begin);
New_Line_Count;
Expand Down Expand Up @@ -3796,7 +3796,7 @@ package body Test.Stub is
S_Put (0, GT_Marker_End);
New_Line_Count;

Put_Lines (MD, Comment_Out => False);
Put_Lines (MD, Comment_Out => True);

S_Put (0, GT_Marker_Begin);
New_Line_Count;
Expand Down
8 changes: 8 additions & 0 deletions testsuite/tests/test/36-stub_dangling_setters/new/dep.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package body Dep is

function Baz (X : Integer) return Integer is
begin
return X;
end Baz;

end Dep;
5 changes: 5 additions & 0 deletions testsuite/tests/test/36-stub_dangling_setters/new/dep.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package Dep is

function Baz (X : Integer) return Integer;

end Dep;
10 changes: 10 additions & 0 deletions testsuite/tests/test/36-stub_dangling_setters/new/root.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
with Dep;

package body Root is

function Foo (X : Integer) return Integer is
begin
return Dep.Baz (X);
end Foo;

end Root;
5 changes: 5 additions & 0 deletions testsuite/tests/test/36-stub_dangling_setters/new/root.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package Root is

function Foo (X : Integer) return Integer;

end Root;
8 changes: 8 additions & 0 deletions testsuite/tests/test/36-stub_dangling_setters/old/dep.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package body Dep is

function Bar (X : My_Int) return My_Int is
begin
return X;
end Bar;

end Dep;
7 changes: 7 additions & 0 deletions testsuite/tests/test/36-stub_dangling_setters/old/dep.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package Dep is

subtype My_Int is Integer;

function Bar (X : My_Int) return My_Int;

end Dep;
10 changes: 10 additions & 0 deletions testsuite/tests/test/36-stub_dangling_setters/old/root.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
with Dep;

package body Root is

function Foo (X : Integer) return Integer is
begin
return Dep.Bar (X);
end Foo;

end Root;
5 changes: 5 additions & 0 deletions testsuite/tests/test/36-stub_dangling_setters/old/root.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package Root is

function Foo (X : Integer) return Integer;

end Root;
8 changes: 8 additions & 0 deletions testsuite/tests/test/36-stub_dangling_setters/prj.gpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
project Prj is

type Source is ("old", "new");
for Source_Dirs use (external ("SRC_DIR", "old"));
for Object_Dir use "obj";

end Prj;

5 changes: 5 additions & 0 deletions testsuite/tests/test/36-stub_dangling_setters/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Units remaining: 4 Units remaining: 3 warning: (gnattest) Dep.Test_Data.Tests has dangling test(s)
Units remaining: 2 Units remaining: 1 warning: (gnattest) Dep has dangling element(s)
warning: (gnattest) Dep.Stub_Data has dangling setter spec(s)
warning: (gnattest) Dep.Stub_Data has dangling setter body(ies)

Expand Down
12 changes: 12 additions & 0 deletions testsuite/tests/test/36-stub_dangling_setters/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /bin/bash

# Generate a stubbing harness with the old sources, containing a custom type
gnattest -P prj.gpr -q -XSRC_DIR=old --stub

# Re-generate the harness but with the custom type dissapearing. Any remaining
# references to it will cause a compilation failure
gnattest -P prj.gpr -XSRC_DIR=new --stub

# Build the harness to check that the unused setters are not causing any
# problems.
gprbuild -P obj/gnattest_stub/harness/test_drivers.gpr -q -XSRC_DIR=new
6 changes: 6 additions & 0 deletions testsuite/tests/test/36-stub_dangling_setters/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
description:
Check that dangling setters in a stubbing harness do not cause any compilation
issues. They used to not be commented out, which could result in lingering
references to types or objects no longer present in the codebase.

driver: shell_script

0 comments on commit f001c31

Please sign in to comment.