Skip to content

Commit 0259a9f

Browse files
zeitlingertrask
andauthored
add dev mode where warnings don't fail the test (#11273)
Co-authored-by: Trask Stalnaker <[email protected]>
1 parent c8bea45 commit 0259a9f

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

conventions/src/main/kotlin/otel.java-conventions.gradle.kts

+5-4
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,13 @@ tasks.withType<JavaCompile>().configureEach {
7272
// We suppress the "options" warning because it prevents compilation on modern JDKs
7373
"-Xlint:-options",
7474
// jdk21 generates more serial warnings than previous versions
75-
"-Xlint:-serial",
76-
77-
// Fail build on any warning
78-
"-Werror"
75+
"-Xlint:-serial"
7976
)
8077
)
78+
if (System.getProperty("dev") != "true") {
79+
// Fail build on any warning
80+
compilerArgs.add("-Werror")
81+
}
8182
}
8283

8384
encoding = "UTF-8"

docs/contributing/running-tests.md

+12
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ To run these tests locally, add `-PtestLatestDeps=true` to your existing `gradle
3838

3939
Executing `./gradlew :instrumentation:<INSTRUMENTATION_NAME>:test --tests <GROOVY TEST FILE NAME>` will run only the selected test.
4040

41+
### How to prevent linting and formatting warnings from failing tests
42+
43+
During local development, you may want to ignore lint warnings when running tests.
44+
45+
To ignore warnings, formatting issues, or other non-fatal issues in tests, use
46+
47+
```
48+
./gradlew test -Ddev=true -x spotlessCheck -x checkstyleMain
49+
```
50+
51+
The `dev` flag will ignore warnings in tests.
52+
4153
## Smoke tests
4254

4355
The smoke tests are not run as part of a global `test` task run since they take a long time and are

0 commit comments

Comments
 (0)