Easier to access exitValue (java -> kotlin accessor)

master
Robinson 2021-08-29 10:22:08 -06:00
parent 8e376ae273
commit c38c84aaed
8 changed files with 18 additions and 22 deletions

View File

@ -94,7 +94,7 @@ class DeferredProcessResult internal constructor(private val process: Process,
*/
internal fun checkExit(attributes: ProcessAttributes, result: ProcessResult) {
val allowedExitValues = attributes.allowedExitValues
val exitValue = result.getExitValue()
val exitValue = result.exitValue
if (allowedExitValues.isNotEmpty() && !allowedExitValues.contains(exitValue)) {
val sb = StringBuilder()

View File

@ -34,5 +34,5 @@ open class InvalidResultException(message: String, val result: ProcessResult) :
* @return the exit value of the finished process.
*/
val exitValue: Int
get() = result.getExitValue()
get() = result.exitValue
}

View File

@ -26,7 +26,7 @@ interface ProcessResult {
/**
* @return the exit value of the finished process.
*/
fun getExitValue(): Int
val exitValue: Int
/**
* @return true if this result has output

View File

@ -27,18 +27,16 @@ package dorkbox.executor.processResults
*/
open class SyncProcessResult(
/**
* Gets the PID for the currently running process. This doesn't make sense for remotely executed processes (which return 0)
* @return the PID for the currently running process. This doesn't make sense for remotely executed processes (which return 0)
*/
val pid: Long,
private val exitValue: Int,
/**
* @return the exit value of the finished process.
*/
override val exitValue: Int,
private val out: ByteArray) : ProcessResult {
/**
* @return the exit value of the finished process.
*/
override fun getExitValue(): Int {
return exitValue
}
/**
* @return true if this result has output

View File

@ -58,7 +58,7 @@ internal class ReadmeExamples {
Executor()
.command("java", "-version")
.start()
.getExitValue()
.exitValue
}
}

View File

@ -63,7 +63,7 @@ class InputRedirectTest {
exec.redirectInput(bais)
.enableRead()
.start()
.getExitValue()
.exitValue
}
log.debug("Exit: {}", exit)

View File

@ -77,7 +77,7 @@ class ProcessExecutorMainTest {
Executor()
.command("java", "-version")
.startAsShell()
.getExitValue()
.exitValue
}
Assert.assertEquals(0, exit.toLong())
@ -89,7 +89,7 @@ class ProcessExecutorMainTest {
Executor()
.command("java", "-version")
.start()
.getExitValue()
.exitValue
}
Assert.assertEquals(0, exit.toLong())
@ -101,7 +101,7 @@ class ProcessExecutorMainTest {
Executor()
.commandSplit("java -version")
.start()
.getExitValue()
.exitValue
}
Assert.assertEquals(0, exit.toLong())
@ -114,7 +114,7 @@ class ProcessExecutorMainTest {
Executor()
.command(iterable)
.start()
.getExitValue()
.exitValue
}
Assert.assertEquals(0, exit.toLong())
@ -126,7 +126,7 @@ class ProcessExecutorMainTest {
.command("java", "-version")
.startAsync()
.awaitBlocking()
.getExitValue()
.exitValue
Assert.assertEquals(0, exit.toLong())
}
@ -136,7 +136,7 @@ class ProcessExecutorMainTest {
.command("java", "-version")
.startAsync()
.awaitBlocking(1000)
.getExitValue()
.exitValue
Assert.assertEquals(0, exit.toLong())
}

View File

@ -34,9 +34,7 @@ class SuccessTest {
.start()
}
val exit: Int = result.getExitValue()
Assert.assertEquals(0, exit.toLong())
Assert.assertEquals(0, result.exitValue)
Assert.assertNotNull(listener.executor)
Assert.assertNotNull(listener.process)
Assert.assertNotNull(listener.result)