swift-testing icon indicating copy to clipboard operation
swift-testing copied to clipboard

Add a built-in trait for creating a temporary directory scoped to a test

Open stmontgomery opened this issue 10 months ago • 2 comments

Description

The testing library should include a built-in trait which automatically creates a temporary directory (or just one file, as a variation of this) scoped to a test. The trait could clean up the file after the test finishes (as a configurable option, probably enabled by default), and perhaps even attach the temporary directory if the test failed for easier troubleshooting.

This could now be implemented using ST-0007: Test Scoping Traits. I think most of the remaining work would be deciding various other aspects of how it would behave, such as different options (if any) for specifying the temp dir's attributes, whether to dispose of it afterward, etc.

Additional information

No response

stmontgomery avatar May 12 '25 17:05 stmontgomery

Might make sense to do this in the Foundation CIO so we can expose it as a URL.

grynspan avatar May 13 '25 16:05 grynspan

Tracked by rdar://151991045

stmontgomery avatar Jul 01 '25 21:07 stmontgomery