Skip to content

AEGIS-10050 add swift-testing capabilities#34

Open
mlink wants to merge 3 commits intomainfrom
AEGIS-10050-add-swift-testing-traits
Open

AEGIS-10050 add swift-testing capabilities#34
mlink wants to merge 3 commits intomainfrom
AEGIS-10050-add-swift-testing-traits

Conversation

@mlink
Copy link
Copy Markdown
Contributor

@mlink mlink commented May 6, 2026

Updates to support swift-testing for parallelized testing. Plan to version 4.0.0 because I can't guarantee the changes to the mocks won't affect someone in an inconvenient way.


This pull request introduces a new SubprocessTesting library for improved subprocess mocking in Swift Testing, makes several enhancements to concurrency and parallel test safety, and updates documentation and package configuration accordingly. The main focus is to enable safe, parallelizable subprocess mocking in tests by leveraging @TaskLocal, and to modernize the codebase for Swift 5.10 and improved Sendable compliance.

Testing and Mocking Improvements:

  • Added the SubprocessTesting library target, providing SubprocessTrait (a Swift Testing TestTrait/SuiteTrait) that scopes subprocess mocking to each test via @TaskLocal, enabling safe parallel test execution. A new SwiftTesting test target demonstrates parallel mock usage. [1] [2] [3] [4] [5]

Concurrency and Sendable Compliance:

  • SubprocessDependencyFactory now conforms to Sendable, and MockSubprocessDependencyBuilder is now public final and Sendable. Its shared instance is now managed by @TaskLocal instead of an unsafe static, removing the need for manual resets between tests. [1] [2]
  • MockProcess.Context, its State, ExpectationError, and MockSubprocessError now conform to Sendable. The runStub closure is now @Sendable, and standard I/O properties in MockProcess.Context are marked nonisolated(unsafe) for Sendable conformance. [1] [2]

API and Testing Usability:

  • MockSubprocessDependencyBuilder.makeProcess, makeInputFileHandle, and makeInputPipe are now public to support the new testing target.
  • All Shell.expect and Subprocess.expect overloads now use #filePath instead of #file for the default file: argument, improving diagnostics. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

Documentation and Package Updates:

  • Updated the README.md with new instructions and examples for using SubprocessTesting, including parallel test examples.
  • Bumped swift-tools-version to 5.10 and updated the changelog for version 4.0.0. [1] [2]

These changes modernize the subprocess mocking infrastructure, making it safer and more ergonomic for concurrent and parallel Swift Testing.

@mlink mlink force-pushed the AEGIS-10050-add-swift-testing-traits branch 2 times, most recently from 4a09d9d to 990146b Compare May 6, 2026 00:38
@mlink mlink force-pushed the AEGIS-10050-add-swift-testing-traits branch from 990146b to e8b34f3 Compare May 6, 2026 14:45
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

Successfully merging this pull request may close these issues.

2 participants