trendy_test_0.0.3_a0e14736/src/trendy_test-reports.adb

 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
with Ada.Calendar;
with Ada.Strings.Unbounded;
with Ada.Strings.Unbounded.Text_IO;
with Ada.Text_IO;
with Ada.Command_Line;

package body Trendy_Test.Reports is

    procedure Print_Basic_Report (Results : Test_Report_Vectors.Vector) is
        use Ada.Text_IO;
        use Ada.Strings.Unbounded.Text_IO;
        use type Ada.Strings.Unbounded.Unbounded_String;
        use all type Ada.Calendar.Time;

        Passes        : Natural                    := 0;
        Fails         : Natural                    := 0;
        Total         : Natural                    := 0;
        Final_Results : Test_Report_Vectors.Vector := Results;
    begin
        Trendy_Test.Test_Report_Vectors_Sort.Sort (Final_Results);
        for R of Final_Results loop
            case R.Status is
                when Passed =>
                    Passes := Passes + 1;
                    Put ("[ PASS ] " & R.Name);
                when Failed =>
                    Fails := Fails + 1;
                    Put ("[ FAIL ] " & R.Name);
                when Skipped =>
                    null;
                    Put ("[ SKIP ] " & R.Name);
            end case;
            Set_Col (80);

            declare
                DT : constant Duration := R.End_Time - R.Start_Time;
            begin
                Put_Line (DT'Image);
            end;

            if R.Status = Failed then
                Put_Line ("         " & R.Failure);
            end if;
        end loop;

        Total := Fails + Passes;
        Put_Line ("Results: Passed: " & Passes'Image & " / " & Total'Image);
        New_Line;

        if Fails > 0 then
            Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
        end if;
    end Print_Basic_Report;
end Trendy_Test.Reports;