From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58265 invoked by alias); 19 Nov 2015 20:04:22 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 58248 invoked by uid 89); 19 Nov 2015 20:04:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-lb0-f180.google.com Received: from mail-lb0-f180.google.com (HELO mail-lb0-f180.google.com) (209.85.217.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 19 Nov 2015 20:04:20 +0000 Received: by lbblt2 with SMTP id lt2so50423398lbb.3 for ; Thu, 19 Nov 2015 12:04:16 -0800 (PST) X-Received: by 10.112.199.4 with SMTP id jg4mr3707765lbc.59.1447963456528; Thu, 19 Nov 2015 12:04:16 -0800 (PST) Received: from ?IPv6:2a00:1148:b0ba:629:e23f:49ff:fe10:1e6b? ([2a00:1148:b0ba:629:e23f:49ff:fe10:1e6b]) by smtp.googlemail.com with ESMTPSA id qh2sm1424443lbb.42.2015.11.19.12.04.15 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 19 Nov 2015 12:04:15 -0800 (PST) Message-ID: <564E2B3E.1040903@gmail.com> Date: Thu, 19 Nov 2015 20:04:00 -0000 From: Mikhail Maltsev User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 MIME-Version: 1.0 To: Bernd Schmidt , David Malcolm CC: gcc-patches@gcc.gnu.org, Jeff Law Subject: Re: [PATCH 01/15] Selftest framework (unittests v4) References: <564A1DAB.1030700@redhat.com> <1447952699-40820-1-git-send-email-dmalcolm@redhat.com> <1447952699-40820-2-git-send-email-dmalcolm@redhat.com> <564E084A.20006@redhat.com> <1447956495.19594.140.camel@surprise> <564E1881.3030306@redhat.com> In-Reply-To: <564E1881.3030306@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg02416.txt.bz2 On 11/19/2015 09:44 PM, Bernd Schmidt wrote: > It's one option, but it doesn't seem like the best one either. I was > thinking of something not dissimilar to your approach, but with fewer > bells and whistles. My class registrator would look something like this: > > static list test_callbacks; > > class registrator > { > public: > registrator (void (*)() cb) > { > test_callbacks.push_front (cb); > } > } > > (or use a vec if you can do that at global constructor time) > > and then you just walk the list and run the callbacks when you want to > run tests. The one you have implements both the registration and a > special case linked list, which just doesn't look right to me, and I > think I'd also have avoided the runner class. Google test allows to run tests which match a given regular expression. This is very convenient when you debug a failing test: you just need to run the testsuite under debugger and specify the relevant (failing) test as a filter. I think this feature is worth implementing eventually (maybe regex is an overkill, and matching against a substring will be enough). So, if testcases are implemented as objects, it will easy to add filtering. If testcases are just callbacks, names and possibly some other metainformation need to be stored separately. FWIW, I worked with other unit test frameworks, such as CppUnit (but Google Test is superior, IMHO) and they use the same approach: testcases are objects which store metainformation (such as name) and have methods for running tests. -- Regards, Mikhail Maltsev