mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
BTA
This commit is contained in:
1 parent
2d4ede41dd
commit
8734c38361
2 files changed
+36
-8
No files matched your search
@@ -49,19 +49,24 @@ public abstract class IrisModdedBuildAction implements WorkAction<IrisModdedBuil
|
||||
LOGGER.lifecycle("{} succeeded in {} ms", label,
|
||||
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - started));
|
||||
} catch (Exception failure) {
|
||||
appendFailure(log, failure);
|
||||
String details;
|
||||
try {
|
||||
details = logTail(log);
|
||||
} catch (IOException unreadable) {
|
||||
failure.addSuppressed(unreadable);
|
||||
details = "Log could not be read.";
|
||||
}
|
||||
String details = failureSummary(log, failure);
|
||||
LOGGER.error(label + " failed; log: " + log + System.lineSeparator() + details, failure);
|
||||
throw new GradleException(label + " failed; log: " + log, failure);
|
||||
}
|
||||
}
|
||||
|
||||
static String failureSummary(Path log, Exception failure) {
|
||||
String details;
|
||||
try {
|
||||
details = logTail(log);
|
||||
} catch (IOException unreadable) {
|
||||
failure.addSuppressed(unreadable);
|
||||
details = "Log could not be read.";
|
||||
}
|
||||
appendFailure(log, failure);
|
||||
return details;
|
||||
}
|
||||
|
||||
static String logTail(Path log) throws IOException {
|
||||
try (RandomAccessFile input = new RandomAccessFile(log.toFile(), "r")) {
|
||||
long offset = Math.max(0L, input.length() - LOG_TAIL_BYTES);
|
||||
|
||||
@@ -66,6 +66,29 @@ public class IrisModdedBuildTest {
|
||||
assertEquals("first" + System.lineSeparator() + "last", IrisModdedBuildAction.logTail(log));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void failureSummaryReportsTheNestedBuildOutputBeforeTheRecordedStackTrace() throws Exception {
|
||||
Path log = temporary.newFile().toPath();
|
||||
Files.writeString(log, "> Task :compileJava FAILED\n\n* What went wrong:\nExecution failed for task ':compileJava'.\n\nBUILD FAILED in 20s\n");
|
||||
Exception failure = new IllegalStateException("nested build exited 1");
|
||||
|
||||
String summary = IrisModdedBuildAction.failureSummary(log, failure);
|
||||
|
||||
assertTrue(summary.contains("* What went wrong:"));
|
||||
assertTrue(summary.endsWith("BUILD FAILED in 20s"));
|
||||
assertFalse(summary.contains("nested build exited 1"));
|
||||
assertTrue(Files.readString(log).contains("java.lang.IllegalStateException: nested build exited 1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void failureSummaryReportsAnUnreadableLog() throws Exception {
|
||||
Path log = temporary.getRoot().toPath().resolve("missing/forge.log");
|
||||
Exception failure = new IllegalStateException("log directory could not be created");
|
||||
|
||||
assertEquals("Log could not be read.", IrisModdedBuildAction.failureSummary(log, failure));
|
||||
assertEquals(2, failure.getSuppressed().length);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void failureSummaryBoundsAnUnbrokenFailureLine() throws Exception {
|
||||
Path log = temporary.newFile().toPath();
|
||||
|
||||
Reference in new issue
Block a user