mirror of https://github.com/briot/gnatbdd
Check whether skipped tests are actually defined
This commit is contained in:
parent
2d45334844
commit
162bfb4237
|
@ -147,36 +147,38 @@ package body BDD.Runner is
|
||||||
|
|
||||||
procedure Run_Step
|
procedure Run_Step
|
||||||
(Scenario : BDD.Features.Scenario;
|
(Scenario : BDD.Features.Scenario;
|
||||||
Step : not null access Step_Record'Class) is
|
Step : not null access Step_Record'Class)
|
||||||
|
is
|
||||||
|
Execute : constant Boolean := Scenario.Status = Status_Passed;
|
||||||
begin
|
begin
|
||||||
case Scenario.Status is
|
-- Run the step, or at least check whether it is defined.
|
||||||
when Status_Passed =>
|
if Execute then
|
||||||
Step.Set_Status (Status_Passed);
|
Step.Set_Status (Status_Passed);
|
||||||
|
else
|
||||||
|
Step.Set_Status (Status_Skipped);
|
||||||
|
end if;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
BDD.Steps.Run_Step (Step);
|
-- Will set status to undefined if necessary
|
||||||
|
BDD.Steps.Run_Step (Step, Execute => Execute);
|
||||||
|
-- if Step.Status = Status_Undefined then
|
||||||
|
-- -- ??? Could run some predefined steps here
|
||||||
|
-- null;
|
||||||
|
-- end if;
|
||||||
|
|
||||||
-- if Step.Status = Status_Undefined then
|
exception
|
||||||
-- -- ??? Could run some predefined steps here
|
when E : others =>
|
||||||
-- null;
|
Step.Set_Status (Status_Failed, Exception_Information (E));
|
||||||
-- end if;
|
end;
|
||||||
|
|
||||||
exception
|
if Execute then
|
||||||
when E : others =>
|
if Show_Steps then
|
||||||
Step.Set_Status
|
Self.Steps_Stats (Step.Status) :=
|
||||||
(Status_Failed, Exception_Information (E));
|
Self.Steps_Stats (Step.Status) + 1;
|
||||||
end;
|
end if;
|
||||||
|
|
||||||
if Show_Steps then
|
Scenario.Set_Status (Step.Status);
|
||||||
Self.Steps_Stats (Step.Status) :=
|
end if;
|
||||||
Self.Steps_Stats (Step.Status) + 1;
|
|
||||||
end if;
|
|
||||||
|
|
||||||
Scenario.Set_Status (Step.Status);
|
|
||||||
|
|
||||||
when Status_Failed | Status_Skipped | Status_Undefined =>
|
|
||||||
Step.Set_Status (Status_Skipped);
|
|
||||||
end case;
|
|
||||||
|
|
||||||
if Show_Steps then
|
if Show_Steps then
|
||||||
Self.Format.Step_Completed (Scenario, Step);
|
Self.Format.Step_Completed (Scenario, Step);
|
||||||
|
|
|
@ -29,9 +29,12 @@ package body BDD.Steps is
|
||||||
("^Given a user named '(.*)'$");
|
("^Given a user named '(.*)'$");
|
||||||
Re_2 : constant Pattern_Matcher := Compile
|
Re_2 : constant Pattern_Matcher := Compile
|
||||||
("^Given I am sitting at my desk$");
|
("^Given I am sitting at my desk$");
|
||||||
|
Re_3 : constant Pattern_Matcher := Compile
|
||||||
|
("^Then I should create great software$");
|
||||||
|
|
||||||
procedure Do_Step_1 (Name : String);
|
procedure Do_Step_1 (Name : String);
|
||||||
procedure Do_Step_2;
|
procedure Do_Step_2;
|
||||||
|
procedure Do_Step_3;
|
||||||
|
|
||||||
---------------
|
---------------
|
||||||
-- Do_Step_1 --
|
-- Do_Step_1 --
|
||||||
|
@ -52,12 +55,22 @@ package body BDD.Steps is
|
||||||
raise Constraint_Error;
|
raise Constraint_Error;
|
||||||
end Do_Step_2;
|
end Do_Step_2;
|
||||||
|
|
||||||
|
---------------
|
||||||
|
-- Do_Step_3 --
|
||||||
|
---------------
|
||||||
|
|
||||||
|
procedure Do_Step_3 is
|
||||||
|
begin
|
||||||
|
raise Constraint_Error;
|
||||||
|
end Do_Step_3;
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
-- Run_Step --
|
-- Run_Step --
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
procedure Run_Step
|
procedure Run_Step
|
||||||
(Step : not null access BDD.Features.Step_Record'Class)
|
(Step : not null access BDD.Features.Step_Record'Class;
|
||||||
|
Execute : Boolean)
|
||||||
is
|
is
|
||||||
Text : constant String := Step.Text;
|
Text : constant String := Step.Text;
|
||||||
Matches : Match_Array (0 .. 10);
|
Matches : Match_Array (0 .. 10);
|
||||||
|
@ -65,14 +78,27 @@ package body BDD.Steps is
|
||||||
Match (Re_1, Text, Matches);
|
Match (Re_1, Text, Matches);
|
||||||
if Matches (0) /= No_Match then
|
if Matches (0) /= No_Match then
|
||||||
Step.Set_Match_Info (Matches);
|
Step.Set_Match_Info (Matches);
|
||||||
Do_Step_1 (Name => Text (Matches (1).First .. Matches (1).Last));
|
if Execute then
|
||||||
|
Do_Step_1 (Name => Text (Matches (1).First .. Matches (1).Last));
|
||||||
|
end if;
|
||||||
return;
|
return;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
Match (Re_2, Text, Matches);
|
Match (Re_2, Text, Matches);
|
||||||
if Matches (0) /= No_Match then
|
if Matches (0) /= No_Match then
|
||||||
Step.Set_Match_Info (Matches);
|
Step.Set_Match_Info (Matches);
|
||||||
Do_Step_2;
|
if Execute then
|
||||||
|
Do_Step_2;
|
||||||
|
end if;
|
||||||
|
return;
|
||||||
|
end if;
|
||||||
|
|
||||||
|
Match (Re_3, Text, Matches);
|
||||||
|
if Matches (0) /= No_Match then
|
||||||
|
Step.Set_Match_Info (Matches);
|
||||||
|
if Execute then
|
||||||
|
Do_Step_3;
|
||||||
|
end if;
|
||||||
return;
|
return;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,12 @@ with BDD.Features; use BDD.Features;
|
||||||
|
|
||||||
package BDD.Steps is
|
package BDD.Steps is
|
||||||
|
|
||||||
procedure Run_Step (Step : not null access BDD.Features.Step_Record'Class);
|
procedure Run_Step
|
||||||
-- Run a step, and sets its status
|
(Step : not null access BDD.Features.Step_Record'Class;
|
||||||
|
Execute : Boolean);
|
||||||
|
-- Run a step, and sets its status.
|
||||||
|
-- If Execute is False, then we only check whether the step is known, but
|
||||||
|
-- it is not run. No exception is raised in this mode.
|
||||||
-- This procedure is expected to raise exceptions when a test fails.
|
-- This procedure is expected to raise exceptions when a test fails.
|
||||||
|
|
||||||
end BDD.Steps;
|
end BDD.Steps;
|
||||||
|
|
Loading…
Reference in New Issue