diff --git a/backend.native/tests/debugger/src/test/kotlin/org/jetbrains/kotlin/native/test/debugger/Driver.kt b/backend.native/tests/debugger/src/test/kotlin/org/jetbrains/kotlin/native/test/debugger/Driver.kt index bf9ebbac5d0..cd557e86b9b 100644 --- a/backend.native/tests/debugger/src/test/kotlin/org/jetbrains/kotlin/native/test/debugger/Driver.kt +++ b/backend.native/tests/debugger/src/test/kotlin/org/jetbrains/kotlin/native/test/debugger/Driver.kt @@ -13,21 +13,12 @@ import org.jetbrains.kotlin.cli.bc.K2Native import java.io.ByteArrayOutputStream import java.io.InputStream import java.io.StringReader -import java.lang.StringBuilder import java.nio.file.Files import java.nio.file.Path -import java.time.temporal.ChronoUnit import java.util.concurrent.TimeUnit -/** - * TODO: This constructor looks weird in conjunction with [DistProperties] - */ class ToolDriver( - private val konancDriver: Path, - private val lldb: Path, - private val dwarfDump: Path, - private val lldbPrettyPrinters: Path, private val useInProcessCompiler: Boolean = false ) { fun compile(source: Path, output: Path, vararg args: String) { @@ -37,7 +28,7 @@ class ToolDriver( if (useInProcessCompiler) { K2Native.main(allArgs) } else { - subprocess(konancDriver, *allArgs).thrownIfFailed() + subprocess(DistProperties.konanc, *allArgs).thrownIfFailed() } check(Files.exists(output)) { "Compiler has not produced an output at $output" @@ -45,15 +36,15 @@ class ToolDriver( } fun runLldb(program: Path, commands: List): String { - val args = listOf("-b", "-o", "command script import \"$lldbPrettyPrinters\"") + + val args = listOf("-b", "-o", "command script import \"${DistProperties.lldbPrettyPrinters}\"") + commands.flatMap { listOf("-o", it) } - return subprocess(lldb, program.toString(), "-b", *args.toTypedArray()) + return subprocess(DistProperties.lldb, program.toString(), "-b", *args.toTypedArray()) .thrownIfFailed() .stdout } fun runDwarfDump(program: Path, processor:List.()->Unit) { - val out = subprocess(dwarfDump, "${program}.dSYM/Contents/Resources/DWARF/${program.fileName}").takeIf { it.process.exitValue() == 0 }?.stdout ?: error("${program}.dSYM/Contents/Resources/DWARF/${program.fileName}") + val out = subprocess(DistProperties.dwarfDump, "${program}.dSYM/Contents/Resources/DWARF/${program.fileName}").takeIf { it.process.exitValue() == 0 }?.stdout ?: error("${program}.dSYM/Contents/Resources/DWARF/${program.fileName}") DwarfUtilParser().parse(StringReader(out)).tags.toList().processor() } } diff --git a/backend.native/tests/debugger/src/test/kotlin/org/jetbrains/kotlin/native/test/debugger/Matchers.kt b/backend.native/tests/debugger/src/test/kotlin/org/jetbrains/kotlin/native/test/debugger/Matchers.kt index d1bf3f88a6f..62dbeed339b 100644 --- a/backend.native/tests/debugger/src/test/kotlin/org/jetbrains/kotlin/native/test/debugger/Matchers.kt +++ b/backend.native/tests/debugger/src/test/kotlin/org/jetbrains/kotlin/native/test/debugger/Matchers.kt @@ -78,7 +78,7 @@ fun lldbTest(@Language("kotlin") programText: String, lldbSession: String) { val source = tmpdir.resolve("main.kt") val output = tmpdir.resolve("program.kexe") - val driver = ToolDriver(DistProperties.konanc, DistProperties.lldb, DistProperties.dwarfDump, DistProperties.lldbPrettyPrinters) + val driver = ToolDriver() Files.write(source, programText.trimIndent().toByteArray()) driver.compile(source, output, "-g") val result = driver.runLldb(output, lldbSessionSpec.commands) @@ -106,11 +106,7 @@ fun dwarfDumpTest(@Language("kotlin") programText: String, flags: List, val source = resolve("main.kt") val output = resolve("program.kexe") - val driver = ToolDriver( - DistProperties.konanc, - DistProperties.lldb, - DistProperties.dwarfDump, - DistProperties.lldbPrettyPrinters) + val driver = ToolDriver() Files.write(source, programText.trimIndent().toByteArray()) driver.compile(source, output, "-g", *flags.toTypedArray()) driver.runDwarfDump(output, test)