Skip to content

gh-109817: Add --single-process-per-case option to libregrtest - #151689

Open
Aniketsy wants to merge 4 commits into
python:mainfrom
Aniketsy:fix-109817
Open

gh-109817: Add --single-process-per-case option to libregrtest#151689
Aniketsy wants to merge 4 commits into
python:mainfrom
Aniketsy:fix-109817

Conversation

@Aniketsy

@Aniketsy Aniketsy commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

fixes #109817

  • still working on this , so converting into draft @serhiy-storchaka please let me know if this looks in right direction or any pointers you want to share. Thanks!

@Aniketsy

Aniketsy commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

i'll fix these mypy and add tests , in the meantime removing from draft, to get some review and suggestions.

@Aniketsy
Aniketsy marked this pull request as ready for review July 1, 2026 07:04
@serhiy-storchaka
serhiy-storchaka self-requested a review July 1, 2026 07:21
@serhiy-storchaka

Copy link
Copy Markdown
Member

I'm a little busy now, but I'll review it after finishing with other unittest/regrtest tasks. Thank you for your efforts.

@Aniketsy

Copy link
Copy Markdown
Contributor Author

I'm a little busy now, but I'll review it after finishing with other unittest/regrtest tasks.

no hurry, i'm improving this till then, so hopefully it creates less pain for you to review 😊 .

I've added tests, with some improvement (locally everything works fine for me) . i'll once again go through this and check for improvement areas before you come here .

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this.

It looks like the code does what the issue asked. But I suspect it can be simplified.

Comment thread Lib/test/libregrtest/findtests.py Outdated
@@ -94,19 +94,47 @@ def list_cases(tests: TestTuple, *,
test_dir: StrPath | None = None) -> None:
support.verbose = False
set_match_tests(match_tests)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set_match_tests() is called both in list_cases() and in collect_cases().

Comment thread Lib/test/libregrtest/run_workers.py Outdated
with self.lock:
self.tests_iter = None

class GroupedMultiprocessIterator:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot MultiprocessIterator be used instead? These classes look very similar.

Comment thread Lib/test/libregrtest/run_workers.py Outdated
finally:
self.test_name = _NOT_RUNNING

mp_result = dataclasses.replace(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mp_result.result is mutable, it can be mutated in-place (see _run_flat()).

Comment thread Lib/test/libregrtest/run_workers.py Outdated
finally:
self.output.put(WorkerThreadExited())

def _run_grouped(self) -> None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_run_grouped() looks very similar to _run_flat() (especially if unify iterators). Could not the share the parametrized body?

@Aniketsy

Aniketsy commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for working on this.

It looks like the code does what the issue asked. But I suspect it can be simplified.

thanks for the review , i'll update shortly with the improvement points you shared .

@Aniketsy

Copy link
Copy Markdown
Contributor Author

@serhiy-storchaka gentle ping, i've updated with changes, please have a look in this when you get chance and let me know if this needs any further improvement. Thankyou :)

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this is much simpler now.

collect_cases() skips unittest.loader._FailedTest. This was harmless while it only fed --list-cases, but it now decides what actually runs: a module which fails to import produces no cases and silently disappears. Where a normal run reports FAILURE and returns 2, --single-process-per-case reports SUCCESS and returns 0. _FailedTest should be reported rather than skipped.

The skipped list returned by collect_cases() is discarded in _run_tests(), so modules which raise SkipTest on import are not reported as skipped.

Please add a NEWS entry in Misc/NEWS.d/next/Tests/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants