Skip to content

Commit 63d1dbf

Browse files
runningcodeclaude
andcommitted
ci(lint): Lint UI tests, narrow flakyWait, add lostExecutorException
The config ignores sentry-android-integration-tests entirely, so its UI tests never got the tests suite. The tests suite now re-includes the modules' src directories, matches androidTest flavor source sets such as androidTestReplay, and covers the macrobenchmark module, which keeps its tests in src/main. SDK suites still ignore the modules' app code. sentry-samples has no test source sets. flakyWait flagged a Thread.yield() poll bounded by a deadline, though nothing signals that a thread has parked. It now reports only fixed sleeps, unbounded waits, ordering assumptions, and polls where a Future, latch, idling resource, fake clock, or the executor's completion was available. lostExecutorException reports tasks whose exceptions would vanish in a Future nobody reads. unjustifiedBroadCatch now lists the task body as a boundary, so the catch both rules ask for agrees with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 61ab160 commit 63d1dbf

3 files changed

Lines changed: 34 additions & 10 deletions

File tree

‎lint/files.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const MAIN_SOURCES = [...MAIN_JAVA, ...MAIN_KOTLIN];
55
export const TEST_SOURCES = [
66
"**/src/test/**/*.java",
77
"**/src/test/**/*.kt",
8-
"**/src/androidTest/**/*.java",
9-
"**/src/androidTest/**/*.kt",
8+
// Also matches flavor source sets such as `androidTestReplay`.
9+
"**/src/androidTest*/**/*.java",
10+
"**/src/androidTest*/**/*.kt",
1011
];

‎lint/suites/safety.ts‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ export default {
1515
"A new broad catch is missing the `rethrowIfFatal` call, the comment explaining why it is broad, or both.",
1616
"No new broad catch, or every new broad catch rethrows fatal errors and explains why it is broad.",
1717
"Catch the narrowest type the guarded code can throw. A broad catch is only for boundaries such as " +
18-
"public API entry points or calls into another process; it must call " +
19-
"`ExceptionUtils.rethrowIfFatal(t)` first and say in a comment why it is broad and what happens on failure.",
18+
"public API entry points, calls into another process, or the body of a task submitted to an " +
19+
"executor; it must call `ExceptionUtils.rethrowIfFatal(t)` first and say in a comment why it is " +
20+
"broad and what happens on failure.",
2021
),
2122
swallowedException: yesNo(
2223
"Do the new lines add a catch block that neither rethrows, logs through the SDK logger " +
@@ -26,6 +27,17 @@ export default {
2627
"Don't swallow the exception silently. Log it with `options.getLogger().log(...)` so the failure can " +
2728
"be diagnosed, and say what the customer sees when it fires.",
2829
),
30+
lostExecutorException: yesNo(
31+
"Do the new lines submit or schedule a task (`execute`, `submit`, `schedule*`) on an executor where " +
32+
"an exception thrown by the task would be lost, because the task doesn't catch and log it and " +
33+
"nobody reads the returned `Future`?",
34+
"A task's exception would be lost: the task doesn't catch it, and nobody reads the returned `Future`.",
35+
"The new lines submit no task, or the task catches and logs its exceptions, or the `Future` is read.",
36+
"The executor keeps the exception in a `Future` nobody reads, so the failure vanishes and can leave " +
37+
"state broken. Catch inside the task and log through `options.getLogger()`. The task body is a " +
38+
"boundary, so the catch must call `ExceptionUtils.rethrowIfFatal(t)` first and say in a comment why " +
39+
"it is broad.",
40+
),
2941
interruptedException: yesNo(
3042
"Do the new lines handle `InterruptedException` inside a broad catch, or catch it without calling " +
3143
"`Thread.currentThread().interrupt()`?",

‎lint/suites/tests.ts‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ import { TEST_SOURCES } from "../files.ts";
55
import { yesNo } from "../yes-no.ts";
66

77
export default {
8-
files: TEST_SOURCES,
8+
files: [
9+
...TEST_SOURCES,
10+
// A `com.android.test` module keeps its tests in `src/main`.
11+
"sentry-android-integration-tests/sentry-uitest-android-macrobenchmark/src/main/**/*.kt",
12+
],
13+
// The config ignores the UI test modules for the SDK suites; lint their tests again here. Matching
14+
// only `src` keeps their build outputs ignored.
15+
ignores: ["!sentry-android-integration-tests/*/src/**"],
916
rules: {
1017
hollowAssertion: yesNo(
1118
"Does a new or changed test have assertions that would still pass if the behavior its name " +
@@ -22,12 +29,16 @@ export default {
2229
"The new lines start no executor, thread, or timer, or stop each one they start.",
2330
"Shut it down in the test or in teardown, so it does not leak into other tests.",
2431
),
32+
// A bounded poll is the only option for state nothing signals, such as a thread parking.
2533
flakyWait: yesNo(
26-
"Do the new lines wait with `Thread.sleep`, a polling loop, a wall-clock timeout, or an assumption " +
27-
"about thread ordering, instead of a `Future`, latch, or fake clock?",
28-
"The test waits on time or ordering instead of a deterministic signal.",
29-
"The new lines don't wait on time or ordering.",
30-
"Wait on a deterministic signal: a `Future`, a `CountDownLatch`, or a fake clock.",
34+
"Do the new lines wait by sleeping a fixed time and assuming the work is done by then, by looping " +
35+
"with no deadline, or by assuming thread ordering, or poll for a condition that a `Future`, latch, idling resource, fake clock, or the " +
36+
"executor's own completion could signal instead?",
37+
"The test sleeps a fixed time, waits without a bound, or polls where a deterministic signal exists.",
38+
"The new lines wait on a deterministic signal, poll with a deadline for state nothing signals, or " +
39+
"don't wait.",
40+
"Wait on a deterministic signal: a `Future`, a `CountDownLatch`, an idling resource, a fake clock, or " +
41+
"the executor's own completion. Poll only for state nothing signals, and bound the poll with a deadline.",
3142
),
3243
},
3344
} satisfies Suite;

0 commit comments

Comments
 (0)