Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.o
*.ali
lib/aunit*
alire
16 changes: 16 additions & 0 deletions alire.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
description = "Ada unit test framework"
name = "aunit"
version = "25.0.0-dev"
authors = ["AdaCore"]
licenses = "GPL-3.0-or-later WITH GCC-exception-3.1"
maintainers = ["chouteau@adacore.com"]
maintainers-logins = ["Fabien-Chouteau"]
project-files = ["lib/gnat/aunit.gpr"]
tags=["unit", "test", "unit-test"]

[configuration]
disabled = true

[gpr-externals]
AUNIT_BUILD_MODE = ["Devel", "Install"]
AUNIT_RUNTIME = ["full", "zfp", "zfp-cross", "ravenscar", "ravenscar-cert", "cert"]
3 changes: 3 additions & 0 deletions include/aunit/framework/aunit-test_cases.adb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ package body AUnit.Test_Cases is
-- Call_Set_Up_Case --
----------------------

function Call_Set_Up_Case
(Test : in out Test_Case'Class) return Test_Error_Access;

function Call_Set_Up_Case
(Test : in out Test_Case'Class) return Test_Error_Access is separate;

Expand Down
4 changes: 2 additions & 2 deletions include/aunit/framework/staticmemory/aunit-memory.adb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
-- Dummy implementation.

with System.Storage_Elements;
with Unchecked_Conversion;
with Ada.Unchecked_Conversion;

package body AUnit.Memory is

Expand All @@ -49,7 +49,7 @@ package body AUnit.Memory is

Top : Mark_Id := Mem'First;

function To_Mark_Id is new Unchecked_Conversion
function To_Mark_Id is new Ada.Unchecked_Conversion
(size_t, Mark_Id);

-----------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ function Call_Set_Up_Case
(Test : in out Test_Case'Class) return Test_Error_Access is
function Alloc_Error is new Gen_Alloc (Test_Error, Test_Error_Access);

procedure Internal_Set_Up_Case;

procedure Internal_Set_Up_Case is
begin
Set_Up_Case (Test);
Expand Down
32 changes: 19 additions & 13 deletions include/aunit/reporters/aunit-reporter-junit.adb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ with AUnit.IO; use AUnit.IO;
with AUnit.Time_Measure; use AUnit.Time_Measure;

package body AUnit.Reporter.JUnit is


procedure Put_Special_Chars (File : File_Type; S : String);
procedure Report_Test (File : File_Type; Test : Test_Result);
procedure Dump_Result_List (File : File_Type; L : Result_Lists.List);

procedure Put_Special_Chars (File : File_Type; S : String) is
begin
for C of S loop
Expand All @@ -46,10 +50,10 @@ package body AUnit.Reporter.JUnit is
end case;
end loop;
end Put_Special_Chars;

procedure Put_Measure is
new Gen_Put_Measure_In_Seconds;

procedure Report_Test (File : File_Type; Test : Test_Result) is
begin
Put (File, "<testcase name=""");
Expand All @@ -59,7 +63,7 @@ package body AUnit.Reporter.JUnit is
Put (File, """ time=""");
Put_Measure (File, Get_Measure (Test.Elapsed));
if Test.Failure /= null then
Put_Line (File, """>");
Put_Line (File, """>");
Put_Line (File, "<failure>");
Put_Line (File, "<![CDATA[");
Put (File, " Assertion: ");
Expand All @@ -73,7 +77,7 @@ package body AUnit.Reporter.JUnit is
Put_Line (File, "</failure>");
Put_Line (File, "</testcase>");
elsif Test.Error /= null then
Put_Line (File, """>");
Put_Line (File, """>");
Put_Line (File, "<error>");
Put_Line (File, "<![CDATA[");
Put (File, " Exception: ");
Expand All @@ -90,9 +94,9 @@ package body AUnit.Reporter.JUnit is
Put_Line (File, "</testcase>");
else
Put_Line (File, """ />");
end if;
end if;
end Report_Test;

procedure Dump_Result_List (File : File_Type; L : Result_Lists.List) is
use Result_Lists;
C : Cursor := First (L);
Expand All @@ -102,17 +106,19 @@ package body AUnit.Reporter.JUnit is
Next (C);
end loop;
end Dump_Result_List;

procedure Report (Engine : JUnit_Reporter;
R : in out Result'Class;
Options : AUnit_Options := Default_Options)
is
is
File : File_Type renames Engine.File.all;
T : constant Time := Elapsed (R);
begin
Put_Line (File, "<?xml version=""1.0"" encoding=""utf-8""?>");
Put_Line (File, "<testsuites>");
Put (File, "<testsuite name=""" & "aunit_testsuite" & """ skipped=""0"" tests=""");
Put (File, "<testsuite name=""" &
"aunit_testsuite" &
""" skipped=""0"" tests=""");
Put (File, Integer (Test_Count (R)), 0);
Put (File, """ failures=""");
Put (File, Integer (Failure_Count (R)), 0);
Expand All @@ -122,15 +128,15 @@ package body AUnit.Reporter.JUnit is
Put (File, """ time=""");
Put_Measure (File, Get_Measure (T));
end if;
Put_Line (File, """>");
Put_Line (File, """>");
if Options.Report_Successes then
declare
S : Result_Lists.List;
begin
Successes (R, S);
Dump_Result_List (File, S);
end;
end if;
end if;
declare
F : Result_Lists.List;
begin
Expand All @@ -142,7 +148,7 @@ package body AUnit.Reporter.JUnit is
begin
Errors (R, E);
Dump_Result_List (File, E);
end;
end;
Put_Line (File, "</testsuite>");
Put_Line (File, "</testsuites>");
end Report;
Expand Down
4 changes: 2 additions & 2 deletions include/aunit/reporters/aunit-reporter-junit.ads
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@

-- jenkins-junit.xsd compatible reporter to file.
package AUnit.Reporter.JUnit is

type JUnit_Reporter is new Reporter with null record;

procedure Report (Engine : JUnit_Reporter;
R : in out Result'Class;
Options : AUnit_Options := Default_Options);
Expand Down
23 changes: 18 additions & 5 deletions include/aunit/reporters/aunit-reporter-text.adb
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ package body AUnit.Reporter.Text is
procedure Indent (File : File_Type; N : Natural);
-- Print N indentations to output

procedure Dump_Result_List (File : File_Type; L : Result_Lists.List; Prefix : String);
procedure Dump_Result_List
(File : File_Type;
L : Result_Lists.List;
Prefix : String);
-- Dump a result list

procedure Put_Measure is new Gen_Put_Measure;
-- Output elapsed time

procedure Report_Test (File : File_Type; Test : Test_Result; Prefix : String);
procedure Report_Test
(File : File_Type;
Test : Test_Result;
Prefix : String);
-- Report a single assertion failure or unexpected exception

generic
Expand Down Expand Up @@ -88,8 +94,11 @@ package body AUnit.Reporter.Text is
-- Dump_Result_List --
----------------------

procedure Dump_Result_List (File : File_Type; L : Result_Lists.List; Prefix : String) is

procedure Dump_Result_List
(File : File_Type;
L : Result_Lists.List;
Prefix : String)
is
use Result_Lists;

C : Cursor := First (L);
Expand Down Expand Up @@ -211,7 +220,11 @@ package body AUnit.Reporter.Text is
-- Report_Test --
-----------------

procedure Report_Test (File : File_Type; Test : Test_Result; Prefix : String) is
procedure Report_Test
(File : File_Type;
Test : Test_Result;
Prefix : String)
is
T : AUnit_Duration;
begin
Put (File, Prefix);
Expand Down