wuzixiao / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Unable to determine if a test should run before calling RUN_ALL_TESTS #478

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hey fox!

I'm trying to determine if a test should be executed using 
::testing::TestInfo->should_run() before calling RUN_ALL_TESTS()
but it always returns false.

After RUN_ALL_TESTS() all works fine.

I don't know if this is considered a bug, or the info about the tests are 
loaded using a "lazy behaviour".

Is there any way to walk around it?

Thanks!

Original issue reported on code.google.com by genesisl...@gmail.com on 13 Oct 2014 at 9:52

Attachments:

GoogleCodeExporter commented 9 years ago
RUN_ALL_TESTS() calls RunAllTests() calls FilterTests() which sets the 
should_run_ field.

There's what looks like a deliberate wndow of opportunity for main() authors to 
manipulate the filters between GoogleTestInit() time and RUN_ALL_TESTS() time, 
so it may not be possible to set should_run_ earlier.

Original comment by billydon...@google.com on 14 Oct 2014 at 4:47

GoogleCodeExporter commented 9 years ago
With your suggestion I've found out a way to walkaround it by simply running 
the test with GTEST_FLAG(list_tests) set to true, before checking the stuffs I 
need.

Thank you for the support ;)

Original comment by genesisl...@gmail.com on 14 Oct 2014 at 6:03