Skip to content

Commit

Permalink
Fix executable resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
chippmann committed Aug 22, 2024
1 parent 4220633 commit 5b4faf9
Showing 1 changed file with 28 additions and 29 deletions.
57 changes: 28 additions & 29 deletions harness/tests/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import org.jetbrains.kotlin.konan.target.HostManager
import java.io.OutputStream

plugins {
// no need to apply kotlin jvm plugin. Our plugin already applies the correct version for you
Expand Down Expand Up @@ -111,42 +110,42 @@ tasks {

dependsOn(importResources)

val editorExecutable: String = provideEditorExecutable().absolutePath

setupTestExecution(editorExecutable)
setupTestExecution {
provideEditorExecutable().absolutePath
}
}
register<Exec>("runExportedGutTests") {
group = "verification"

dependsOn(importResources, exportRelease)

val testExecutable: String = projectDir
.resolve("export")
.listFiles()
?.filter { it.isFile }
?.also {
println("Test executables: [${it.joinToString()}]")
it.forEach { file -> file.setExecutable(true) }
}
?.firstOrNull { file ->
listOf("exe", "x64_64", "app")
.any { executableExtensions -> file.name.contains(executableExtensions) }
}
?.let { executable ->
if (executable.name.contains("app")) {
executable.resolve("Contents/MacOS").listFiles().firstOrNull()
} else {
executable
setupTestExecution {
projectDir
.resolve("export")
.listFiles()
?.filter { it.isFile }
?.also {
println("Test executables: [${it.joinToString()}]")
it.forEach { file -> file.setExecutable(true) }
}
}
?.absolutePath
?: throw Exception("Could not find test executable")

setupTestExecution(testExecutable)
?.firstOrNull { file ->
listOf("exe", "x64_64", "app")
.any { executableExtensions -> file.name.contains(executableExtensions) }
}
?.let { executable ->
if (executable.name.contains("app")) {
executable.resolve("Contents/MacOS").listFiles().firstOrNull()
} else {
executable
}
}
?.absolutePath
?: throw Exception("Could not find test executable")
}
}
}

fun Exec.setupTestExecution(editorExecutable: String) {
fun Exec.setupTestExecution(executableProvider: () -> String) {
var didAllTestsPass = false
var isJvmClosed = false
val testOutputFile = File("${projectDir}/test_output.txt")
Expand Down Expand Up @@ -186,13 +185,13 @@ fun Exec.setupTestExecution(editorExecutable: String) {
this.commandLine(
"cmd",
"/c",
"$editorExecutable -s --headless --path $projectDir addons/gut/gut_cmdln.gd",
"${executableProvider()} -s --headless --path $projectDir addons/gut/gut_cmdln.gd",
)
} else {
this.commandLine(
"bash",
"-c",
"$editorExecutable -s --headless --path $projectDir addons/gut/gut_cmdln.gd",
"${executableProvider()} -s --headless --path $projectDir addons/gut/gut_cmdln.gd",
)
}
}
Expand Down

0 comments on commit 5b4faf9

Please sign in to comment.