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

[WIP] Add an experimental .serialized(.globally) trait. #913

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Jan 15, 2025

This PR adds a variant of the .serialized that causes annotated tests and suites to run in serial after all other test content has run, in effect allowing them to opt out of parallelization entirely.

This PR introduces a new concept to a runner plan, "stages." The names of stages are arbitrary, but the point is that they run in a fixed order and different work is performed in each stage. Test functions always run in a single stage, while test suites may get smeared across multiple stages. Normal test work is performed in the first stage, with a second stage that runs everything in it serially. Hence, any test that gets put in that second stage runs in a globally serialized order.

"Globally" here does not refer to multi-process parallelization, which is a whole 'nother animal. If we ever add support for that, we'll presumably want tests in this stage to be serialized even between processes.

Stages aren't API or SPI, although we could potentially promote it to either in the future.

Resolves rdar://135288463.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

@grynspan grynspan added enhancement New feature or request concurrency Swift concurrency/sendability issues public-api Affects public API labels Jan 15, 2025
@grynspan grynspan added this to the Swift 6.x milestone Jan 15, 2025
@grynspan grynspan self-assigned this Jan 15, 2025
@spnkr
Copy link

spnkr commented Jan 16, 2025

Yes!! Controlling concurrent/serialized execution of tests in swift testing is not great at the moment. It's my biggest pain point actually.

@grynspan grynspan force-pushed the jgrynspan/global-serialized branch from 2118d86 to d5b624b Compare January 17, 2025 17:49
@grynspan
Copy link
Contributor Author

@spnkr This is just an experimental branch and does not imply we're actually going to make a feature out of it, sorry. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
concurrency Swift concurrency/sendability issues enhancement New feature or request public-api Affects public API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants