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

libregrtest: add option to run every test case in separate process #109817

Open
serhiy-storchaka opened this issue Sep 25, 2023 · 2 comments
Open
Labels
tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Sep 25, 2023

Feature or enhancement

Proposal:

libregrtest can run every test module in a separate process, and can even run several test modules in parallel. It has options to simply output all test modules or all test cases.

I propose to add an option to run every test case in a separate process. Test cases from the same module should still run sequentially, because they can use the same resource (for example create a server at fixed port).

This will slow down the tests several times, but it is not for regular running in the CI, it is for manual running once every months or for manual running selected test module while writing new tests or debugging test flakiness. It can help to solve the following issues:

  1. Order dependency. Some tests are only passed because they run in specific order, and the order of tests in a module is the same, only the order of test modules is randomized. If run the test in a separate process, it is always the first, and cannot depend on others.
  2. Environment changes and leaks. Some tests change the environment (e.g. leak temporary files or do not wait for terminating a thread or a subprocess), and it is not noticed because subsequent tests have cleaned after it. If run the test in a separate process, it is always the last, and nobody cleans after it.

cc @vstinner @gpshead

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

@serhiy-storchaka serhiy-storchaka added type-feature A feature request or enhancement tests Tests in the Lib/test dir labels Sep 25, 2023
@serhiy-storchaka
Copy link
Member Author

For now I can do this by using the following command:

PYTHON=./python; $PYTHON -m test -uall --list-tests 2>/dev/null | while read -r test
do
    $PYTHON -m test -uall --list-cases $test 2>/dev/null | xargs -n1 $PYTHON -m test -vuall $test -m
done

But it is slow (because it does not parallel different test modules), the output is difficult to analyze, and it cannot be run on Windows.

@vstinner
Copy link
Member

See also closed PR gh-99637 by @gpshead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants