Skip to content

Commit 7233d2b

Browse files
committed
Log the CLI process output when sample project generation test times out
1 parent 9721321 commit 7233d2b

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

integration-tests/sample-app/src/test/java/io/quarkus/platform/test/SampleProjectGenerationIT.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,11 @@ private static void buildApp(Path projectDir) throws IOException {
156156
} catch (Exception e) {
157157
log.error("Failed to destroy the process", e);
158158
}
159-
fail("The process has exceeded the time out limit of " + getBuildAppTimeout() + " seconds");
159+
final String timeoutMessage = "The process has exceeded the timeout limit of " + getBuildAppTimeout()
160+
+ " seconds";
161+
log.error(timeoutMessage);
162+
logCliProcessOutput(cliLog, cliErrors);
163+
fail(timeoutMessage);
160164
}
161165
} catch (InterruptedException e) {
162166
log.error("Interrupted waiting for the process to complete", e);
@@ -173,6 +177,25 @@ private static void buildApp(Path projectDir) throws IOException {
173177
}
174178
}
175179

180+
private static void logCliProcessOutput(Path cliLog, Path cliErrors) throws IOException {
181+
if (Files.exists(cliLog)) {
182+
String output = Files.readString(cliLog);
183+
if (!output.isBlank()) {
184+
log.info("BEGIN the CLI process output:");
185+
log.info(output);
186+
log.info("END the CLI process output");
187+
}
188+
}
189+
if (Files.exists(cliLog)) {
190+
String output = Files.readString(cliErrors);
191+
if (!output.isBlank()) {
192+
log.info("BEGIN the CLI process error output:");
193+
log.info(output);
194+
log.info("END the CLI process error output");
195+
}
196+
}
197+
}
198+
176199
private static String getMvnPath() {
177200
var mavenHome = System.getProperty("maven.home");
178201
if (mavenHome == null) {
@@ -213,7 +236,11 @@ private static Path generateSampleAppWithMaven() throws IOException {
213236
} catch (Exception e) {
214237
log.error("Failed to destroy the process", e);
215238
}
216-
fail("The process has exceeded the time out limit of " + getGenerateAppTimeout() + " seconds");
239+
final String timeoutMessage = "The process has exceeded the time out limit of " + getGenerateAppTimeout()
240+
+ " seconds";
241+
log.error(timeoutMessage);
242+
logCliProcessOutput(cliLog, cliErrors);
243+
fail(timeoutMessage);
217244
}
218245
} catch (InterruptedException e) {
219246
log.error("Interrupted waiting for the process to complete", e);

0 commit comments

Comments
 (0)