Add helper to create temp directory.

This directory will be cleaned up on successful test, but will be left
on test error.

^KT-45745 In Progress
This commit is contained in:
Yahor Berdnikau
2021-10-08 19:40:09 +02:00
committed by TeamCityServer
parent 6c747d33f7
commit 38849b7be4
@@ -18,3 +18,12 @@ internal fun Path.findInPath(name: String): Path? = Files
.walk(this)
.asSequence()
.find { it.fileName.toString() == name }
/**
* Create a temporary directory that will be cleaned up on normal JVM termination, but will be left on non-zero exit status.
*
* Prefer using JUnit5 `@TempDir` over this method when possible.
*/
internal fun createTempDir(prefix: String): Path = Files
.createTempDirectory(prefix)
.apply { toFile().deleteOnExit() }