[boost] [test] Problem with BOOST_TEST_MESSAGE

329 views
Skip to first unread message

Edward Diener

unread,
May 12, 2015, 6:01:32 PM5/12/15
to bo...@lists.boost.org
In testing out a library with Boost.Test I want to inject informational
messages that will appear in the output of the test results. When I use
BOOST_TEST_MESSAGE with the correct logging level my message appears in
the output if there is some sort of Boost.Test error during my tests.
However if my unit test does not have a Boost.Test error my
BOOST_TEST_MESSAGE does not appear. Needless to say I always want my
BOOST_TEST_MESSAGE messages to always appear in the output. Is there a
solution to this ?


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Bjorn Reese

unread,
May 12, 2015, 6:42:58 PM5/12/15
to bo...@lists.boost.org
On 05/13/2015 12:00 AM, Edward Diener wrote:

> BOOST_TEST_MESSAGE does not appear. Needless to say I always want my
> BOOST_TEST_MESSAGE messages to always appear in the output. Is there a
> solution to this ?

Add --log_level=message when you run the test.

Edward Diener

unread,
May 12, 2015, 7:33:56 PM5/12/15
to bo...@lists.boost.org
On 5/12/2015 6:42 PM, Bjorn Reese wrote:
> On 05/13/2015 12:00 AM, Edward Diener wrote:
>
>> BOOST_TEST_MESSAGE does not appear. Needless to say I always want my
>> BOOST_TEST_MESSAGE messages to always appear in the output. Is there a
>> solution to this ?
>
> Add --log_level=message when you run the test.

You mean that if I add '--log_level=message' when the test is run my
BOOST_TEST_MESSAGE message will always appear in the output, but if I
set the environment variable:

BOOST_TEST_LOG_LEVEL=message

before running the test that my BOOST_TEST_MESSAGE message will only
appear if there is an error in the unit test ?

I thought the two ways are equivalent.

Edward Diener

unread,
May 12, 2015, 8:40:37 PM5/12/15
to bo...@lists.boost.org
On 5/12/2015 6:42 PM, Bjorn Reese wrote:
> On 05/13/2015 12:00 AM, Edward Diener wrote:
>
>> BOOST_TEST_MESSAGE does not appear. Needless to say I always want my
>> BOOST_TEST_MESSAGE messages to always appear in the output. Is there a
>> solution to this ?
>
> Add --log_level=message when you run the test.

I tried that with the same result.

Bjorn Reese

unread,
May 13, 2015, 4:51:48 AM5/13/15
to bo...@lists.boost.org
On 05/13/2015 02:39 AM, Edward Diener wrote:
> On 5/12/2015 6:42 PM, Bjorn Reese wrote:
>> On 05/13/2015 12:00 AM, Edward Diener wrote:
>>
>>> BOOST_TEST_MESSAGE does not appear. Needless to say I always want my
>>> BOOST_TEST_MESSAGE messages to always appear in the output. Is there a
>>> solution to this ?
>>
>> Add --log_level=message when you run the test.
>
> I tried that with the same result.

Both this and the BOOST_TEST_LOG_LEVEL environment variable work fine
here. I have attached a small test program; hopefully that will help
you narrow down the problem.

Btw, you can also set the log level at compile time:

http://www.boost.org/libs/test/doc/html/utf/user-guide/test-output/log-ct-config.html

test_message.cpp

Edward Diener

unread,
May 13, 2015, 8:31:50 PM5/13/15
to bo...@lists.boost.org
On 5/13/2015 4:51 AM, Bjorn Reese wrote:
> On 05/13/2015 02:39 AM, Edward Diener wrote:
>> On 5/12/2015 6:42 PM, Bjorn Reese wrote:
>>> On 05/13/2015 12:00 AM, Edward Diener wrote:
>>>
>>>> BOOST_TEST_MESSAGE does not appear. Needless to say I always want my
>>>> BOOST_TEST_MESSAGE messages to always appear in the output. Is there a
>>>> solution to this ?
>>>
>>> Add --log_level=message when you run the test.
>>
>> I tried that with the same result.
>
> Both this and the BOOST_TEST_LOG_LEVEL environment variable work fine
> here. I have attached a small test program; hopefully that will help
> you narrow down the problem.

I tried your program using the latest Boost.Test on the 'master' branch,
and the result is the same for me. Perhaps this works for you with some
previous release or perhaps this works for you with the 'develop' branch
of Boost.Test.

>
> Btw, you can also set the log level at compile time:
>
> http://www.boost.org/libs/test/doc/html/utf/user-guide/test-output/log-ct-config.html

Thanks, that helps.

Edward Diener

unread,
May 13, 2015, 9:41:39 PM5/13/15
to bo...@lists.boost.org
On 5/13/2015 8:31 PM, Edward Diener wrote:
> On 5/13/2015 4:51 AM, Bjorn Reese wrote:
>> On 05/13/2015 02:39 AM, Edward Diener wrote:
>>> On 5/12/2015 6:42 PM, Bjorn Reese wrote:
>>>> On 05/13/2015 12:00 AM, Edward Diener wrote:
>>>>
>>>>> BOOST_TEST_MESSAGE does not appear. Needless to say I always want my
>>>>> BOOST_TEST_MESSAGE messages to always appear in the output. Is there a
>>>>> solution to this ?
>>>>
>>>> Add --log_level=message when you run the test.
>>>
>>> I tried that with the same result.
>>
>> Both this and the BOOST_TEST_LOG_LEVEL environment variable work fine
>> here. I have attached a small test program; hopefully that will help
>> you narrow down the problem.
>
> I tried your program using the latest Boost.Test on the 'master' branch,
> and the result is the same for me.

By this I meant that if their are no errors the BOOST_TEST_MESSAGE
message never appears. By the "same for me" I meant that nothing has
changed with your test from my original problem.

Bjorn Reese

unread,
May 14, 2015, 2:35:55 AM5/14/15
to bo...@lists.boost.org
On 05/14/2015 02:31 AM, Edward Diener wrote:

> I tried your program using the latest Boost.Test on the 'master' branch,
> and the result is the same for me. Perhaps this works for you with some
> previous release or perhaps this works for you with the 'develop' branch
> of Boost.Test.

Yes, I tested it with the develop branch and the 1.55 release. I have
not tried the master branch (or the 1.58 release.)

Edward Diener

unread,
May 14, 2015, 9:40:11 PM5/14/15
to bo...@lists.boost.org
On 5/14/2015 2:35 AM, Bjorn Reese wrote:
> On 05/14/2015 02:31 AM, Edward Diener wrote:
>
>> I tried your program using the latest Boost.Test on the 'master' branch,
>> and the result is the same for me. Perhaps this works for you with some
>> previous release or perhaps this works for you with the 'develop' branch
>> of Boost.Test.
>
> Yes, I tested it with the develop branch and the 1.55 release. I have
> not tried the master branch (or the 1.58 release.)

I tried the current 'develop' branch of Boost.Test and still got the
result reported in my OP. I can live with it, since the vast majority of
the times I only need to see the BOOST_TEST_MESSAGE output when a test
fails. But there is clearly something different in our environments when
your result is different than mine. I wish I knew what it was, but it is
not so important that I cannnot use BOOST_TEST_MESSAGE to trace through
my code when something is wrong.

Gennadiy Rozental

unread,
May 14, 2015, 10:21:19 PM5/14/15
to bo...@lists.boost.org
Edward Diener <eldiener <at> tropicsoft.com> writes:

> I tried the current 'develop' branch of Boost.Test and still got the
> result reported in my OP. I can live with it, since the vast majority of
> the times I only need to see the BOOST_TEST_MESSAGE output when a test
> fails

BOOST_TEST_MESSAGE has nothing to do whatsoever with assertions (failing
or not). This is a feature of the log subsystem.

Do you observe this with bjam? If yes, than this is expected.

Gennadiy

Edward Diener

unread,
May 14, 2015, 11:25:10 PM5/14/15
to bo...@lists.boost.org
On 5/14/2015 10:20 PM, Gennadiy Rozental wrote:
> Edward Diener <eldiener <at> tropicsoft.com> writes:
>
>> I tried the current 'develop' branch of Boost.Test and still got the
>> result reported in my OP. I can live with it, since the vast majority of
>> the times I only need to see the BOOST_TEST_MESSAGE output when a test
>> fails
>
> BOOST_TEST_MESSAGE has nothing to do whatsoever with assertions (failing
> or not). This is a feature of the log subsystem.

When did I say it has anything to do with assertions ?

>
> Do you observe this with bjam?

Yes.

> If yes, than this is expected.

Do you mean that if I use BOOST_TEST_MESSAGE in a test and there are no
failures the BOOST_TEST_MESSAGE not appearing as bjam output, while if
there is a test failure the BOOST_TEST_MESSAGE appearing as bjam output,
is expected ? Why is that ?

Steven Watanabe

unread,
May 15, 2015, 12:45:54 AM5/15/15
to bo...@lists.boost.org
AMDG

On 05/14/2015 09:24 PM, Edward Diener wrote:
>
> Do you mean that if I use BOOST_TEST_MESSAGE in a test and there are no
> failures the BOOST_TEST_MESSAGE not appearing as bjam output, while if
> there is a test failure the BOOST_TEST_MESSAGE appearing as bjam output,
> is expected ? Why is that ?
>

Boost.Build doesn't print the test output
unless it fails or you pass --verbose-test.
You'll find it in the file xxx.output.

In Christ,
Steven Watanabe

Edward Diener

unread,
May 15, 2015, 7:29:47 AM5/15/15
to bo...@lists.boost.org
On 5/15/2015 12:45 AM, Steven Watanabe wrote:
> AMDG
>
> On 05/14/2015 09:24 PM, Edward Diener wrote:
>>
>> Do you mean that if I use BOOST_TEST_MESSAGE in a test and there are no
>> failures the BOOST_TEST_MESSAGE not appearing as bjam output, while if
>> there is a test failure the BOOST_TEST_MESSAGE appearing as bjam output,
>> is expected ? Why is that ?
>>
>
> Boost.Build doesn't print the test output
> unless it fails or you pass --verbose-test.
> You'll find it in the file xxx.output.+

Thanks for the explanation. I naively thought that all standard output
showed up in the Boost Build results.
Reply all
Reply to author
Forward
0 new messages