Skip to content

Commit

Permalink
gnattest: create Test.Command_Line
Browse files Browse the repository at this point in the history
Put command-line arguments for gnattest in
Test.Command_Line.

S726-030

Change-Id: I151ea07b2589ef6b7a0d318e7fe7618bd08dd15c
  • Loading branch information
bobduff committed Jul 31, 2019
1 parent 7f21f94 commit 6c9da9f
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 275 deletions.
66 changes: 65 additions & 1 deletion src/test-actions.adb
Expand Up @@ -15,19 +15,80 @@ with Utils.Formatted_Output;

with Utils_Debug; use Utils_Debug;

with Test.Command_Lines; use Test.Command_Lines;

package body Test.Actions is

use Utils.Formatted_Output;

pragma Warnings (Off); -- ????
-- These use clauses will be necessary later.
-- At least some of them.

use Common_Flag_Switches,
Common_Boolean_Switches,
Ada_Version_Switches,
Common_String_Switches,
Common_String_Seq_Switches,
Common_Nat_Switches;

use Test_Boolean_Switches, Test_String_Switches, Test_String_Seq_Switches;
pragma Warnings (On);

----------
-- Init --
----------

procedure Init
(Tool : in out Test_Tool; Cmd : in out Command_Line)
is
pragma Unreferenced (Tool); -- ????
begin
null; -- ????

-- Here's some code to illustrate how to query the args. The parsed
-- comand line (including stuff from project files) is passed as Cmd.
-- Call "Arg (Cmd, <switch_name>)" to get the value specified for the
-- switch.

-- First, a Boolean one: "Arg (Cmd, Strict)" will return True if
-- --strict appears on the command line or in a project file. It
-- defaults to False (see Test.Command_Line).

-- You have to "use" all the "..._Switches" packages. Otherwise, you get
-- incomprehensible error messages about "Arg" not resolving. "Arg" is
-- heavily overloaded. If a "use" is missing, the compiler doesn't
-- say "use Test_Boolean_Switches is missing". It says, "Here's 37
-- different Arg functions with the wrong parameter types."

if Arg (Cmd, Strict) then
Put ("--strict\n");
else
Put ("--no-strict\n");
end if;

-- --harness-dir is a string switch, so Arg returns null or a pointer to
-- the specified string.

if Arg (Cmd, Harness_Dir) = null then
Put ("--harness-dir not specified\n");
else
Put ("--harness-dir = \1\n", Arg (Cmd, Harness_Dir).all);
end if;

-- --additional-tests is a string sequence, so it can be given multiple
-- times on the command line, and Arg returns an array of pointers to
-- strings.

declare
Additional : constant String_Ref_Array := Arg (Cmd, Additional_Tests);
begin
Put ("Additional_Tests:\n");
for X of Additional loop
Put (" \1\n", X.all);
end loop;
Put ("end Additional_Tests\n");
end;
end Init;

-----------
Expand All @@ -51,8 +112,11 @@ package body Test.Actions is
BOM_Seen : Boolean;
Unit : Analysis_Unit)
is
pragma Unreferenced (Tool, Cmd, File_Name, Input, BOM_Seen); -- ????
pragma Unreferenced (Tool, Input, BOM_Seen); -- ????
begin
Put ("gnattest is processing \1.\n", File_Name);
Dump_Cmd (Cmd);

if Debug_Flag_V then
Print (Unit);
Put ("With trivia\n");
Expand Down
5 changes: 3 additions & 2 deletions src/test-actions.ads
Expand Up @@ -2,8 +2,9 @@ with Libadalang.Analysis; use Libadalang.Analysis;
with Utils.Command_Lines; use Utils.Command_Lines;
with Utils.Tools; use Utils.Tools;

private with Test.Command_Lines;
pragma Unreferenced (Test.Command_Lines); -- ????
pragma Warnings (Off); -- ????
private with Test.Command_Lines; -- ????might want this here, or in body
pragma Warnings (On);

package Test.Actions is

Expand Down

0 comments on commit 6c9da9f

Please sign in to comment.