File: aunit-run.adb

package info (click to toggle)
libaunit 18-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,100 kB
  • sloc: ada: 5,325; makefile: 152; sh: 94; xml: 13
file content (123 lines) | stat: -rw-r--r-- 4,957 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
------------------------------------------------------------------------------
--                                                                          --
--                         GNAT COMPILER COMPONENTS                         --
--                                                                          --
--                             A U N I T . R U N                            --
--                                                                          --
--                                 B o d y                                  --
--                                                                          --
--                                                                          --
--                       Copyright (C) 2006-2013, AdaCore                   --
--                                                                          --
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
--                                                                          --
-- You should have received a copy of the GNU General Public License and    --
-- a copy of the GCC Runtime Library Exception along with this program;     --
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
-- <http://www.gnu.org/licenses/>.                                          --
--                                                                          --
-- GNAT is maintained by AdaCore (http://www.adacore.com)                   --
--                                                                          --
------------------------------------------------------------------------------

with AUnit.Time_Measure;
with AUnit.Test_Suites; use AUnit.Test_Suites;

package body AUnit.Run is

   procedure Run
     (Suite    : Access_Test_Suite;
      Results  : in out Test_Results.Result'Class;
      Options  : AUnit.Options.AUnit_Options;
      Reporter : AUnit.Reporter.Reporter'Class;
      Outcome  : out Status);
   --  Run a specific testsuite and return its status

   ---------
   -- Run --
   ---------

   procedure Run
     (Suite    : Access_Test_Suite;
      Results  : in out Test_Results.Result'Class;
      Options  : AUnit.Options.AUnit_Options;
      Reporter : AUnit.Reporter.Reporter'Class;
      Outcome  : out Status)
   is
      Time    : Time_Measure.Time;

   begin
      if Options.Global_Timer then
         Time_Measure.Start_Measure (Time);
      end if;

      pragma Warnings (Off);
      AUnit.Test_Suites.Run (Suite, Options, Results, Outcome);
      pragma Warnings (On);

      if Options.Global_Timer then
         Time_Measure.Stop_Measure (Time);
         Test_Results.Set_Elapsed (Results, Time);
      end if;

      AUnit.Reporter.Report (Reporter, Results, Options);
   end Run;

   -----------------
   -- Test_Runner --
   -----------------

   procedure Test_Runner
     (Reporter : AUnit.Reporter.Reporter'Class;
      Options  : AUnit.Options.AUnit_Options := AUnit.Options.Default_Options)
   is
      Results : Test_Results.Result;
      Outcome : Status;
      pragma Unreferenced (Outcome);
   begin
      Test_Results.Clear (Results);
      Run (Suite, Results, Options, Reporter, Outcome);
   end Test_Runner;

   -----------------------------
   -- Test_Runner_With_Status --
   -----------------------------

   function Test_Runner_With_Status
     (Reporter : AUnit.Reporter.Reporter'Class;
      Options  : AUnit.Options.AUnit_Options := AUnit.Options.Default_Options)
      return Status
   is
      Results : Test_Results.Result;
      Outcome : Status;
   begin
      Test_Results.Clear (Results);
      Run (Suite, Results, Options, Reporter, Outcome);
      return Outcome;
   end Test_Runner_With_Status;

   ------------------------------
   -- Test_Runner_With_Results --
   ------------------------------

   procedure Test_Runner_With_Results
     (Reporter : AUnit.Reporter.Reporter'Class;
      Results  : in out AUnit.Test_Results.Result'Class;
      Options  : AUnit.Options.AUnit_Options := AUnit.Options.Default_Options)
   is
      Outcome : Status;
      pragma Unreferenced (Outcome);
   begin
      Run (Suite, Results, Options, Reporter, Outcome);
   end Test_Runner_With_Results;

end AUnit.Run;