Skip to content

Commit

Permalink
Merge branch 'leo_cr/183-generics_gen' into 'master'
Browse files Browse the repository at this point in the history
Test: do not generate tests for non-instanciated generic subps

Closes #183

See merge request eng/ide/libadalang-tools!234
  • Loading branch information
leocreuse committed Sep 19, 2024
2 parents afab009 + de22d22 commit 580c530
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/test-generation.adb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ package body Test.Generation is
return Over;
end if;

-- Skip any non-instantiated generic decl, they will be processed as
-- part of a generic instantiation, if any.

if Node.Kind in Ada_Generic_Decl
and then Node.P_Generic_Instantiations'Length = 0
then
return Over;
end if;

-- Collect all types used as parameters in subprogram declarations.
-- Skip generic subprogram declarations as we only care about the
-- instantiations. Also skip subprograms with zero parameters if there
Expand All @@ -86,14 +95,6 @@ package body Test.Generation is
| Ada_Subp_Renaming_Decl
then

-- Skip generic subp decls (these will be processed if they are
-- instantiated).

if Node.As_Basic_Decl.P_Canonical_Part.Kind in Ada_Generic_Decl
then
return Over;
end if;

-- Check, if the subprogram has zero parameters. If so, only add it
-- to the generation context if it has a global annotation.

Expand Down
10 changes: 10 additions & 0 deletions testsuite/tests/test/183-formal_params/gen.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package body Gen is

procedure Params (X : T) is
begin
null;
end Params;

function Ret return T is (Val);

end Gen;
7 changes: 7 additions & 0 deletions testsuite/tests/test/183-formal_params/gen.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
generic
type T is range <>;
Val : T;
package Gen is
procedure Params (X : T);
function Ret return T;
end Gen;
5 changes: 5 additions & 0 deletions testsuite/tests/test/183-formal_params/importing.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
with Gen;

package Importing is

end Importing;
5 changes: 5 additions & 0 deletions testsuite/tests/test/183-formal_params/prj.gpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project Prj is

for Object_Dir use "obj";

end Prj;
7 changes: 7 additions & 0 deletions testsuite/tests/test/183-formal_params/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
No subprogram supported for test case generation.
Units remaining: 3 Units remaining: 2 Units remaining: 1 warning: (gnattest) gen.ads:1:1: no instance of Gen
corresponding tests are not included into harness
gnattest: no test skeletons generated because no subprogram to test
found in project /prj.gpr
gnattest: cannot create main suite and test runner
>>>program returned status code 1
Expand Down
5 changes: 5 additions & 0 deletions testsuite/tests/test/183-formal_params/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /bin/bash

# We expect only diagnostics stating that there are no
# subprograms to test, not that some type is unsupported.
gnattest -P prj.gpr --gen-test-vectors
7 changes: 7 additions & 0 deletions testsuite/tests/test/183-formal_params/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
description: Test that gnattest does not attempt to generate test inputs for
subprograms with generic formal parameters or return types.

driver: shell_script

control:
- [XFAIL, 'x86', 'Marshalling not working for 32bits (UB03-008)']
3 changes: 3 additions & 0 deletions testsuite/tests/test/tc_json_dump_with_gen/test.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
gnattest: Error while processing <ExprFunction ["Ident"] my_file.ads:78:4-78:43>:
my_file.ident.X: my_file.ident.t is not supported (Generic formal types are unsupported)

Units remaining: 2 Units remaining: 1
my_file.ads:14:4: info: corresponding test PASSED
my_file.ads:14:4: info: corresponding test PASSED
Expand Down

0 comments on commit 580c530

Please sign in to comment.