Created
December 30, 2015 20:16
-
-
Save develar/c274d4f5898e8119bb68 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun runAndWait(commandLine: GeneralCommandLine) { | |
val handler = KillableColoredProcessHandler(commandLine, true) | |
var hasErrors = false | |
handler.addProcessListener(object : ProcessAdapter() { | |
override fun onTextAvailable(event: ProcessEvent, outputType: Key<*>) { | |
val text = event.text | |
// https://github.com/maxogden/electron-packager/pull/228 | |
val out = if (outputType == ProcessOutputTypes.STDERR && !text.startsWith("Packaging app for platform ")) { | |
hasErrors = true | |
System.err | |
} | |
else { | |
System.out | |
} | |
out.println(text) | |
} | |
}) | |
handler.startNotify() | |
// "meteor update" take a lot of time on linux | |
if (!handler.waitFor((10 * Time.MINUTE).toLong())) { | |
try { | |
handler.destroyProcess() | |
} | |
finally { | |
throw AssertionError("'${commandLine.commandLineString}' is not completed in 10 minutes, terminated") | |
} | |
} | |
if (hasErrors) { | |
throw AssertionError("'${commandLine.commandLineString}' has error output") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment