Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
23 changes: 23 additions & 0 deletions include/aunit/reporters/aunit-reporter-combine.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

package body AUnit.Reporter.Combine is

procedure Report
(Engine : Combined_Reporter;
R : in out Result'Class;
Comment thread
TamaMcGlinn marked this conversation as resolved.
Options : AUnit_Options := Default_Options) is

procedure Run_Reporter(Position : Reporter_Vecs.Cursor) is
Element : constant Reporter_Access := Reporter_Vecs.Element (Position);
begin
AUnit.Reporter.Report (Element.all, R, Options);
end Run_Reporter;
begin
Reporter_Vecs.Iterate (Engine.Reporters, Run_Reporter'Access);
end Report;

procedure Add_Reporter (C : in out Combined_Reporter; R : access constant Reporter'Class) is
begin
C.Reporters.Append(R);
end Add_Reporter;

end AUnit.Reporter.Combine;
26 changes: 26 additions & 0 deletions include/aunit/reporters/aunit-reporter-combine.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
with Ada.Containers.Vectors;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work for restricted runtimes, Ada.Containers are not present there

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an easy way for me to test that? I tried adding for Runtime ("Ada") use "zfp"; to the project using aunit, but then even AUnit.Time_Measure's usage of Ada.Calendar won't work.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reviewing aunit_shared.gpr it seems clear this currently works fine.

I guess the proper way to do this would be to add another enumeration like the current Except, Calend, Memory and FileIO and then create a consistent interface to the Vectors package with two implementations, "vectors" would pass through to Ada.Containers.Vectors, while "novectors" would have some custom implementation.

Another option would be to use AUnit.Memory directly, or rather, to implement AUnit.Vectors in terms of AUnit.Memory, so that the above enumeration isn't necessay. Thoughts on which is better/simpler?

By the way, I saw that in aunit_shared.gpr around line 52 when "cert" => the value for Calend remains "calendar", which is implicitly saying that Ada.Calendar is certified. It seems better to make that explicit if that is correct. If this were normal Ada code, I would say that these four enumerations are begging to be made into a record type, so that we could make the compiler spot such omissions, but I'm not sure that applies to gpr files.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A third option I think is to move the trx reporter into a separate directory which is only included as a source when the runtime is set to full. This is the only option that doesn't have me unnecessarily supporting runtimes I don't use myself.


package AUnit.Reporter.Combine is

type Combined_Reporter is new Reporter with private;

overriding
procedure Report
(Engine : Combined_Reporter;
R : in out Result'Class;
Options : AUnit_Options := Default_Options);

procedure Add_Reporter (C : in out Combined_Reporter; R : access constant Reporter'Class);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R should be of type Reporter_Access, otherwise there would be a compilation error:

aunit-reporter-combine.adb:20:26: implicit conversion of anonymous access parameter not allowed


private

type Reporter_Access is access constant Reporter'Class;
Comment thread
TamaMcGlinn marked this conversation as resolved.

package Reporter_Vecs is new Ada.Containers.Vectors
(Element_Type => Reporter_Access,
Index_Type => Positive);

type Combined_Reporter is new Reporter with record
Reporters : Reporter_Vecs.Vector;
end record;
end AUnit.Reporter.Combine;