diff --git a/src/org/ice1000/julia/lang/action/julia-pkg-actions.kt b/src/org/ice1000/julia/lang/action/julia-pkg-actions.kt index c1f24a1d..24f5b956 100644 --- a/src/org/ice1000/julia/lang/action/julia-pkg-actions.kt +++ b/src/org/ice1000/julia/lang/action/julia-pkg-actions.kt @@ -37,10 +37,10 @@ class JuliaRemovePkgAction( if (beforeVersion07) printJulia(box.comboBox.selectedItem.toString(), 30_000L, """Pkg.rm("$removePackageName")""") else - executeCommand(box.comboBox.selectedItem.toString(), """ + executeCommand(box.comboBox.selectedItem.toString(), input = """ using Pkg Pkg.rm("$removePackageName") -""", 30_000L) +""", timeLimit = 30_000L) ApplicationManager.getApplication().invokeLater { Messages.showDialog( project, @@ -84,11 +84,11 @@ class JuliaAddPkgAction( if (beforeVersion07) printJulia(box.comboBox.selectedItem.toString(), 50_000L, """Pkg.add("$it")""") else - executeCommand(box.comboBox.selectedItem.toString(), """ + executeCommand(box.comboBox.selectedItem.toString(), input = """ using Pkg Pkg.add("$it") exit() -""", 50_000L) +""", timeLimit = 50_000L) } override fun onSuccess() = ApplicationManager.getApplication().invokeLater { diff --git a/src/org/ice1000/julia/lang/module/julia-package-manager.kt b/src/org/ice1000/julia/lang/module/julia-package-manager.kt index 1c68e0d0..3cb35dcf 100644 --- a/src/org/ice1000/julia/lang/module/julia-package-manager.kt +++ b/src/org/ice1000/julia/lang/module/julia-package-manager.kt @@ -47,7 +47,7 @@ private val packagePredicate = Predicate { dir: Path -> */ @Language("Julia") fun versionsList(settings: JuliaSettings) = - executeCommand(settings.exePath, "Pkg.installed()", 20_000L) + executeCommand(settings.exePath, input = "Pkg.installed()", timeLimit = 20_000L) .first .filter { "=>" in it } .sorted() @@ -66,7 +66,11 @@ fun loadNamesListByEnvFile(settings: JuliaSettings, envdir: String): List, List> { + vararg command: String, + input: String? = null, + timeLimit: Long = 1200L +): Pair, List> { + var processRef: Process? = null var output: List = emptyList() var outputErr: List = emptyList() diff --git a/test/org/ice1000/julia/lang/module/julia-sdk-type-test.kt b/test/org/ice1000/julia/lang/module/julia-sdk-type-test.kt index 61a01bde..16eed07f 100644 --- a/test/org/ice1000/julia/lang/module/julia-sdk-type-test.kt +++ b/test/org/ice1000/julia/lang/module/julia-sdk-type-test.kt @@ -4,8 +4,8 @@ import org.ice1000.julia.lang.executeCommand fun main(args: Array) { if (!System.getenv("CI").isNullOrBlank()) return - println(executeCommand("ls", null, 100L).first) - println(executeCommand("whereis julia", null, 500L).first) + println(executeCommand("ls", input = null, timeLimit = 100L).first) + println(executeCommand("whereis julia", input = null, timeLimit = 500L).first) println(juliaPath) println("" in arrayOf("")) } \ No newline at end of file diff --git a/test/org/ice1000/julia/lang/utils-test.kt b/test/org/ice1000/julia/lang/utils-test.kt index 9206cf09..62b52965 100644 --- a/test/org/ice1000/julia/lang/utils-test.kt +++ b/test/org/ice1000/julia/lang/utils-test.kt @@ -40,7 +40,7 @@ class UtilsKtTest { } @Test - fun whereIsJulia() = executeCommand("whereis julia", null, 1000) + fun whereIsJulia() = executeCommand("whereis julia", input = null, timeLimit = 1000) .first .forEach(::println)