Making lots of compile FAIL tests
I've started to devise some tests to ensure that things that really should not compile, do in fact compile-fail. So far I've produced a few files with a single statement that should fail inside a int main(){}. But it's looking at though it will get pretty tedious pretty soon :-( (I see for example that Boost.Multiprecision has some 50-ish compile_fail items) Is there some slicker way of doing this? Paul --- Paul A. Bristow Prizet Farmhouse Kendal UK LA8 8AB +44 (0) 1539 561830
On 17.06.2015 16:57, Paul A. Bristow wrote:
I've started to devise some tests to ensure that things that really should not compile, do in fact compile-fail.
So far I've produced a few files with a single statement that should fail inside a int main(){}.
But it's looking at though it will get pretty tedious pretty soon :-(
(I see for example that Boost.Multiprecision has some 50-ish compile_fail items)
Is there some slicker way of doing this?
Not in Boost right now. There are tools that match output of tools against expectations set in a file (gcc has one in their test suite, and clang has -verify) that are used to test compiler errors in test suites. It would be cool if Boost provided access to such a tool for its own tests. Sebastian
On Wed, Jun 17, 2015 at 5:57 PM, Paul A. Bristow
I've started to devise some tests to ensure that things that really should not compile, do in fact compile-fail.
So far I've produced a few files with a single statement that should fail inside a int main(){}.
But it's looking at though it will get pretty tedious pretty soon :-(
(I see for example that Boost.Multiprecision has some 50-ish compile_fail items)
Is there some slicker way of doing this?
Depending on complexity of the checks you perform, you could try to auto-generate those tests from bjam. For example, in Boost.Log I'm generating compile tests for every public header (so that there are no missing includes, syntax errors, etc.) using a single .cpp with a macro that expands to the tested header name. See libs/log/test/Jamfile.v2, rule test_all and libs/log/test/compile/self_contained_header.cpp.
-----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Andrey Semashev Sent: 18 June 2015 10:22 To: boost@lists.boost.org Subject: Re: [boost] Making lots of compile FAIL tests
On Wed, Jun 17, 2015 at 5:57 PM, Paul A. Bristow
wrote: I've started to devise some tests to ensure that things that really should not compile, do in fact compile-fail.
So far I've produced a few files with a single statement that should fail inside a int main(){}.
But it's looking at though it will get pretty tedious pretty soon :-(
(I see for example that Boost.Multiprecision has some 50-ish compile_fail items)
Is there some slicker way of doing this?
Depending on complexity of the checks you perform, you could try to auto-generate those tests from bjam. For example, in Boost.Log I'm generating compile tests for every public header (so that
missing includes, syntax errors, etc.) using a single .cpp with a macro that expands to the tested
name. See libs/log/test/Jamfile.v2, rule test_all and
there are no header libs/log/test/compile/self_contained_header.cpp. That's rather neat, but I'm not sure that my tests are quite tedious enough to resort to such serious grappling with bjam ;-) Thanks Paul
participants (3)
-
Andrey Semashev
-
Paul A. Bristow
-
Sebastian Redl