AllLinesParser: Enable draining of stdout (#8670)

This commit is contained in:
Rene Peinthor 2024-04-02 11:50:11 +02:00 committed by GitHub
parent 6c6023b790
commit f7603dcbcc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View File

@ -137,6 +137,11 @@ public abstract class OutputInterpreter {
public String getLines() {
return allLines;
}
@Override
public boolean drain() {
return true;
}
}
public static class LineByLineOutputLogger extends OutputInterpreter {

View File

@ -111,6 +111,20 @@ public class ScriptTest {
Assert.assertNotNull(value);
}
@Test
public void executeWithOutputInterpreterAllLinesParserLargeOutput() {
Assume.assumeTrue(SystemUtils.IS_OS_LINUX);
OutputInterpreter.AllLinesParser parser = new OutputInterpreter.AllLinesParser();
Script script = new Script("seq");
script.add("-f");
script.add("my text to test cloudstack %g");
script.add("4096"); // AllLinesParser doesn't work with that amount of data
String value = script.execute(parser);
// it is a stack trace in this case as string
Assert.assertNull(value);
Assert.assertEquals(129965, parser.getLines().length());
}
@Test
public void runSimpleBashScriptNotExisting() {
Assume.assumeTrue(SystemUtils.IS_OS_LINUX);