Unverified Commit 92bdf944 authored by Russell Cohen's avatar Russell Cohen Committed by GitHub
Browse files

Add default for the Smithy test workspace (#1981)

* Add default for the Smithy test workspace

* CR feedback
parent 84ed110f
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import software.amazon.smithy.rust.codegen.core.util.runCommand
import java.io.File
import java.nio.file.Files.createTempDirectory
import java.nio.file.Path
import kotlin.io.path.absolutePathString

/**
 * Waiting for Kotlin to stabilize their temp directory functionality
@@ -55,8 +56,18 @@ private fun tempDir(directory: File? = null): File {
 * This workspace significantly improves test performance by sharing dependencies between different tests.
 */
object TestWorkspace {
    private val baseDir =
    private val baseDir by lazy {
        val homeDir = System.getProperty("APPDATA")
            ?: System.getenv("XDG_DATA_HOME")
            ?: System.getProperty("user.home")
                ?.let { Path.of(it, "Library/Application Support").absolutePathString() }
                ?.takeIf { File(it).exists() }
        if (homeDir != null) {
            File(Path.of(homeDir, "smithy-test-workspace").absolutePathString())
        } else {
            System.getenv("SMITHY_TEST_WORKSPACE")?.let { File(it) } ?: tempDir()
        }
    }
    private val subprojects = mutableListOf<String>()

    init {