Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test helper: runCommand #613

Open
TWiStErRob opened this issue Oct 18, 2023 · 0 comments
Open

Fix test helper: runCommand #613

TWiStErRob opened this issue Oct 18, 2023 · 0 comments
Labels
a:bug something isn't working as expected in:test test module and project tests is:good-first-issue
Milestone

Comments

@TWiStErRob
Copy link
Owner

TWiStErRob commented Oct 18, 2023

.apply { waitFor(timeout, MILLISECONDS) }
.also { process ->
if (verifyError && process.exitValue() != 0) {
val out = process.inputStream.bufferedReader().readText()
val err = process.errorStream.bufferedReader().readText()
assertEquals(
0, process.exitValue(),
@Suppress("StringShouldBeRawString") // It would be more complex that way.
"Non-zero exit value:\nstdout:\n${out}\nstderr:\n${err}"
)
}
}
.run { inputStream.bufferedReader().readText() }

val out = StringWriter(); thread { process.inputStream.reader().copyTo(out) }

See https://stackoverflow.com/a/3285479/253468 and TWiStErRob/net.twisterrob.inventory#359

also assert waitFor return value.

@TWiStErRob TWiStErRob added a:bug something isn't working as expected in:test test module and project tests is:good-first-issue labels Oct 18, 2023
@TWiStErRob TWiStErRob added this to the 0.17 milestone Oct 18, 2023
@TWiStErRob TWiStErRob modified the milestones: 0.17, 0.18 May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug something isn't working as expected in:test test module and project tests is:good-first-issue
Projects
None yet
Development

No branches or pull requests

1 participant