Guarding ForTesting call behind compile-time-available IS_FOR_TEST
Bug: 1322880 Change-Id: I9ed4e49cf07a886ed20b2539ef790db83b065099 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3774076 Reviewed-by: Mohamed Heikal <mheikal@chromium.org> Commit-Queue: Sam Maier <smaier@chromium.org> Reviewed-by: Yaron Friedman <yfriedman@chromium.org> Reviewed-by: Ted Choc <tedchoc@chromium.org> Cr-Commit-Position: refs/heads/main@{#1026333}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
acfe48638a
commit
7452a0d26d
base/android/java/src/org/chromium/base/metrics
build
styleguide/java
@ -256,6 +256,11 @@ with the testing suffixes supported [PRESUMBIT.py](https://chromium.googlesource
|
||||
`ForTest`, are also accepted. These suffixes are checked at presubmit time
|
||||
to ensure the functions are called only by test files.
|
||||
|
||||
It's generally bad practice to directly call test-only methods from
|
||||
non-test-only code. However, occasionally it has to be done, and if so, you
|
||||
should guard the check with an `if (BuildConfig.IS_FOR_TEST)` so that our Java
|
||||
optimizer can still remove the call in non-test builds.
|
||||
|
||||
## Location
|
||||
"Top level directories" are defined as directories with a GN file, such as
|
||||
[//base](https://chromium.googlesource.com/chromium/src/+/main/base/)
|
||||
|
Reference in New Issue
Block a user