Skip to content

Commit e08a87f

Browse files
committed
More logging to try to diagnose SIGSEGV issues
1 parent d38ea2d commit e08a87f

6 files changed

Lines changed: 80 additions & 49 deletions

File tree

buildSrc/src/main/groovy/java-common-conventions.gradle

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
2+
import org.gradle.api.tasks.testing.logging.TestLogEvent
3+
14
plugins {
25
// Apply the java-library plugin for API and implementation separation.
36
id 'java-library'
@@ -9,11 +12,85 @@ java {
912
targetCompatibility = JavaVersion.VERSION_17
1013
}
1114

12-
tasks.withType(JavaCompile) {
15+
tasks.withType(JavaCompile).configureEach {
1316
// Configure string concat to always inline compile
1417
options.compilerArgs.add '-XDstringConcat=inline'
1518
}
1619

20+
project.ext {
21+
runningTestDescriptions = [] as Set
22+
}
23+
24+
tasks.withType(Test).configureEach {
25+
26+
testLogging {
27+
// set options for log level LIFECYCLE
28+
events TestLogEvent.FAILED,
29+
TestLogEvent.PASSED,
30+
TestLogEvent.SKIPPED,
31+
TestLogEvent.STANDARD_OUT
32+
exceptionFormat TestExceptionFormat.FULL
33+
showExceptions true
34+
showCauses true
35+
showStackTraces true
36+
37+
// set options for log level DEBUG and INFO
38+
debug {
39+
events TestLogEvent.STARTED,
40+
TestLogEvent.FAILED,
41+
TestLogEvent.PASSED,
42+
TestLogEvent.SKIPPED,
43+
TestLogEvent.STANDARD_ERROR,
44+
TestLogEvent.STANDARD_OUT
45+
exceptionFormat TestExceptionFormat.FULL
46+
}
47+
info.events = debug.events
48+
info.exceptionFormat = debug.exceptionFormat
49+
50+
beforeTest { desc ->
51+
project.ext.runningTestDescriptions.add(desc.displayName)
52+
}
53+
54+
afterTest { desc, result ->
55+
project.ext.runningTestDescriptions.remove(desc.displayName )
56+
}
57+
58+
afterSuite { desc, result ->
59+
if (!desc.parent) { // will match the outermost suite
60+
def name = desc.name
61+
def idx = name.indexOf(":")
62+
if (idx >= 0) {
63+
name = name.substring(idx)
64+
}
65+
66+
def rows = [
67+
"Results for ${name} - ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)"
68+
]
69+
def running = project.ext.runningTestDescriptions
70+
if (!running.isEmpty()) {
71+
rows.add("Interrupted tests: ${running}")
72+
}
73+
def maxContentLen = rows.stream()
74+
.map { it.length() }
75+
.max(Comparator.naturalOrder())
76+
.orElse(0)
77+
def startItem = '', endItem = ''
78+
def repeatLength = startItem.length() + maxContentLen + endItem.length() - 2
79+
80+
def printRow = { String row ->
81+
println(startItem + row + (' ' * (maxContentLen - row.length())) + endItem)
82+
}
83+
84+
println('\n' + ('' * repeatLength) + '')
85+
for (row in rows) {
86+
printRow row
87+
}
88+
println('' + ('' * repeatLength) + '\n')
89+
}
90+
}
91+
}
92+
}
93+
1794
tasks.named('jar') {
1895
manifest {
1996
attributes(

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
org.gradle.logging.level=debug
1+
org.gradle.logging.level=info

lib/build.gradle

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,6 @@ tasks.named('test') {
5151
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
5252
}
5353

54-
test {
55-
testLogging {
56-
debug {
57-
showStandardStreams = true
58-
exceptionFormat = "full"
59-
displayGranularity = -1
60-
}
61-
}
62-
}
63-
6454
javadoc {
6555
options.tags = [
6656
// Converts `@apiNote` paragraph to "Note: " section in the generated javadoc

lib/src/test/java/com/team2813/lib2813/preferences/PersistedConfigurationTest.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import static java.util.stream.Collectors.toMap;
66
import static org.junit.Assert.assertThrows;
77

8-
import com.team2813.lib2813.util.PrintingWatcher;
98
import edu.wpi.first.networktables.NetworkTable;
109
import edu.wpi.first.networktables.NetworkTableEntry;
1110
import edu.wpi.first.networktables.NetworkTableInstance;
@@ -19,12 +18,10 @@
1918
import java.util.function.*;
2019
import org.junit.After;
2120
import org.junit.Before;
22-
import org.junit.ClassRule;
2321
import org.junit.Rule;
2422
import org.junit.Test;
2523
import org.junit.experimental.runners.Enclosed;
2624
import org.junit.rules.ErrorCollector;
27-
import org.junit.rules.TestWatcher;
2825
import org.junit.runner.RunWith;
2926
import org.junit.runners.Parameterized;
3027
import org.junit.runners.Parameterized.Parameters;
@@ -35,13 +32,12 @@ public final class PersistedConfigurationTest {
3532
private static final double EPSILON = 0.001;
3633

3734
/** Base class for all nested classes of {@link PersistedConfigurationTest}. */
38-
public abstract static class PreferencesRegistryTestCase<T extends Record> {
35+
abstract static class PreferencesRegistryTestCase<T extends Record> {
3936
private final String preferenceName;
4037
private final Class<T> recordClass;
4138

4239
@Rule public final IsolatedPreferences isolatedPreferences = new IsolatedPreferences();
4340
@Rule public final ErrorCollector errorCollector = new ErrorCollector();
44-
@ClassRule @Rule public static final TestWatcher printingWatcher = new PrintingWatcher();
4541

4642
protected PreferencesRegistryTestCase(String preferenceName, Class<T> recordClass) {
4743
this.preferenceName = preferenceName;

lib/src/test/java/com/team2813/lib2813/util/InputValidationTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@
44
import static com.google.common.truth.Truth.assertWithMessage;
55
import static org.junit.Assert.assertThrows;
66

7-
import org.junit.ClassRule;
8-
import org.junit.Rule;
97
import org.junit.Test;
10-
import org.junit.rules.TestWatcher;
118

129
public class InputValidationTest {
1310
// Tests for the `InputValidation.checkCanId(...)` method.
1411
public static class CheckCanIdTest {
15-
@ClassRule @Rule public static final TestWatcher printingWatcher = new PrintingWatcher();
16-
1712
@Test
1813
public void invalidCanId() {
1914
// Can IDs can only valid in the range [0, 62].

lib/src/test/java/com/team2813/lib2813/util/PrintingWatcher.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)