質問

I just hit a problem with boost unit running on windows where the output from multiple threads is not atomic, so it corrupts the output XML which confuses the CI system if I put any tests or messages in any threads other than the main thread.

I can't see any boost unit option to control this, so am wondering if this is something that google test can do which would make it worth switching to google test instead (searching the wiki didn't find me anything).

Or is there some other approach I should use (it's useful when running a test from the command line on linux to see this output. but I don't want it to break my windows CI)?

役に立ちましたか?

解決

GTest's output is mutex-protected, so multi-threading doesn't produce garbled output.

The function which generally does this work is AddTestPartResult. At line 3713, you can see the lock being applied:

internal::MutexLock lock(&mutex_);

and then at 3732 the result is printed in this call:

impl_->GetTestPartResultReporterForCurrentThread()->ReportTestPartResult(result);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top