Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test runner thread initialization #435

Closed
HrvojeFER opened this issue Nov 19, 2020 · 2 comments
Closed

Test runner thread initialization #435

HrvojeFER opened this issue Nov 19, 2020 · 2 comments

Comments

@HrvojeFER
Copy link

Hello!
I just have a couple of questions about concurrent environments.

I am using a library for which I have to run everything on a separate thread that needs initialization. However, in order to debug and test everything properly, I need to initialize the test runner thread as well.

My questions are:
Are all the test fixtures, test cases, and subcases run on the same thread?
Are they all run on the same thread from which we implement doctest with DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN?
The reason is that I could just run the thread initialization in my main doctest implementation and not worry about it later.

Thank you in advance!

Extra information

  • doctest version: v2.4.1
  • Operating System: Windows
  • Compiler+version: Visual Studio Community 2019
@onqtam
Copy link
Member

onqtam commented Nov 20, 2020

Are all the test fixtures, test cases, and subcases run on the same thread?

Yes, they are all ran from whichever thread doctest::Context::run() is called - sequentially.

Are they all run on the same thread from which we implement doctest with DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN?

DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN just drags the implementation of the test runner into the respective translation unit in order to be compiled - the thread the tests will be running from is the one from which you call doctest::Context::run() on your doctest context and that depends entirely on your preference.

FYI (perhaps unrelated): doctest supports asserts and logging from multiple threads within a single test case.

Let me know if this helps!

@HrvojeFER
Copy link
Author

This is exactly the information I was looking for.
Thank you for the reply and for the wonderful doctest library! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants