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

Parallel test runner is not actually parallel #641

Open
cschreib opened this issue Oct 19, 2024 · 0 comments
Open

Parallel test runner is not actually parallel #641

cschreib opened this issue Oct 19, 2024 · 0 comments

Comments

@cschreib
Copy link

Expected Behavior

The example for the parallel test runner uses std::for_each(std::execution::par, ...) to demonstrate running several test suites in parallel. I expect the tests to actually run in separate threads.

Actual Behavior

In practice on my machine, this isn't actually executed in parallel. As proof: GDB shows no thread being created, and std::this_thread::get_id() is the same in both suites.

If I force the suites to run in separate threads with

    std::thread t1([&]() { suites_[0](); });
    std::thread t2([&]() { suites_[1](); });
    t1.join();
    t2.join();

the console output is interleaving results from both threads. To make this more obvious, I have edited some of assertions to fail in each suite. As you can see, the output is not readable:

test.1.1
test.2.1
test.2.2
test.1.2
test.2.3
test.1.3
Running "test.1
 "test.2.1"...1
  parallel_runner.cpp:64:FAILED [
 "test.1.2"...2 == 1]parallel_runner.cpp:55:FAILED [2 == 1]
FAILED
Running "test.2.3"...PASSED
Running "test.1.3"...PASSED

===============================================================================
tests:   3 | 1 failed
asserts: 6 | 4 passed | 2 failed
.

Steps to Reproduce the Problem

  1. Edit the parallel_runner.cpp example to insert std::cout << "thread ID: " << std::this_thread::get_id() << std::endl; in each test suite.
  2. Compile and run.
  3. Thread IDs are the same.

Specifications

  • Version: 1.1.9
  • Platform: Linux x64 (Ubuntu 22.04)
  • Subsystem: g++ 11.4
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

1 participant