From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.150.18 with SMTP id y18mr1924044iod.107.1522533028093; Sat, 31 Mar 2018 14:50:28 -0700 (PDT) X-Received: by 2002:a9d:16c3:: with SMTP id s3-v6mr209637ots.13.1522533027853; Sat, 31 Mar 2018 14:50:27 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!weretis.net!feeder4.news.weretis.net!news.roellig-ltd.de!open-news-network.org!peer02.am4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!k65-v6no620105ita.0!news-out.google.com!u64-v6ni3158itb.0!nntp.google.com!u184-v6no2402208ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 31 Mar 2018 14:50:27 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=76.218.37.33; posting-account=W2gdXQoAAADxIuhBWhPFjUps3wUp4RhQ NNTP-Posting-Host: 76.218.37.33 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <6b4d7928-4aad-4023-b402-3f3418869d5f@googlegroups.com> Subject: useful AUnit filter From: Stephen Leake Injection-Date: Sat, 31 Mar 2018 21:50:28 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Bytes: 5006 X-Received-Body-CRC: 1612347225 Xref: reader02.eternal-september.org comp.lang.ada:51262 Date: 2018-03-31T14:50:27-07:00 List-Id: I put together the AUnit filter below; it outputs each test name before the test is run. Useful when one test hangs, or outputs somewhat unhelpful error messages. I thought some others might find it useful. -- aunit-test_filters-verbose.ads -- Abstract : -- -- Add to Name_Filter a verbose option; output to Standard_Error each -- test name before it is run, to help find which is hanging, or -- otherwise crashing without helpful output. -- -- Copyright (C) 2018 Stephen Leake All Rights Reserved. -- -- This program is free software; you can redistribute it and/or -- modify it under terms of the GNU General Public License as -- published by the Free Software Foundation; either version 3, or (at -- your option) any later version. This program is distributed in the -- hope that it will be useful, but WITHOUT ANY WARRANTY; without even -- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -- PURPOSE. See the GNU General Public License for more details. You -- should have received a copy of the GNU General Public License -- distributed with this program; see file COPYING. If not, write to -- the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, -- MA 02110-1335, USA. pragma License (GPL); with AUnit.Tests; package AUnit.Test_Filters.Verbose is type Filter is new Name_Filter with record Verbose : Boolean := False; end record; -- Same filter as parent, and if Verbose, outputs to -- Text_IO.Standard_Error the name of each test before it is run. overriding function Is_Active (Filter : Verbose.Filter; T : AUnit.Tests.Test'Class) return Boolean; end AUnit.Test_Filters.Verbose; ---- -- aunit-test_filters-verbose.adb -- Abstract : -- -- See spec. -- -- Copyright (C) 2018 Stephen Leake All Rights Reserved. -- -- This program is free software; you can redistribute it and/or -- modify it under terms of the GNU General Public License as -- published by the Free Software Foundation; either version 3, or (at -- your option) any later version. This program is distributed in the -- hope that it will be useful, but WITHOUT ANY WARRANTY; without even -- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -- PURPOSE. See the GNU General Public License for more details. You -- should have received a copy of the GNU General Public License -- distributed with this program; see file COPYING. If not, write to -- the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, -- MA 02110-1335, USA. pragma License (GPL); with AUnit.Simple_Test_Cases; with Ada.Tags; with Ada.Text_IO; package body AUnit.Test_Filters.Verbose is overriding function Is_Active (Filter : Verbose.Filter; T : AUnit.Tests.Test'Class) return Boolean is use Ada.Text_IO; Result : constant Boolean := Name_Filter (Filter).Is_Active (T); begin if Filter.Verbose and Result then if T in AUnit.Simple_Test_Cases.Test_Case'Class then declare Name : constant Message_String := AUnit.Simple_Test_Cases.Test_Case'Class (T).Name; Routine_Name : constant Message_String := AUnit.Simple_Test_Cases.Test_Case'Class (T).Routine_Name; begin if Name = null then Put_Line (Standard_Error, "unnamed test, type: " & Ada.Tags.Expanded_Name (T'Tag)); else Put_Line (Standard_Error, Name.all & (if Routine_Name = null then "" else " " & Routine_Name.all)); end if; end; else -- We don't know how to get a name. Put_Line (Standard_Error, "unnamed test, type: " & Ada.Tags.Expanded_Name (T'Tag)); end if; end if; return Result; end Is_Active; end AUnit.Test_Filters.Verbose; -----