aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/actions
diff options
context:
space:
mode:
authorGravatar jmmv <jmmv@google.com>2017-12-21 10:30:44 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2017-12-21 10:34:29 -0800
commitb30b9335ab185837e03527b4bf9c3c40b41db767 (patch)
tree664686c7c66b191dfeec2b87de8679e9cdec775a /src/test/java/com/google/devtools/build/lib/actions
parentda4200141a5fa04a9e83e39fa1f01c444f228dfc (diff)
Improve testing for miss details on action cache stats.
The previous tests (internal-only, sorry) were checking for the total number of misses before testing for the actual breakdown by reason. This was confusing because the total number was quite mysterious and because a test failure would point at the total instead of the breakdown, making the test problems harder to understand. To resolve this: check for the miss reasons first, which will give a better indication of what's wrong with the test, and then check for the total using a number that is derived from the breakdown, which avoids a magical number in the test. RELNOTES: None. PiperOrigin-RevId: 179830122
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/actions')
-rw-r--r--src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
index f344242075..eab667a7ff 100644
--- a/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
+++ b/src/test/java/com/google/devtools/build/lib/actions/util/ActionsTestUtil.java
@@ -652,6 +652,15 @@ public final class ActionsTestUtil {
}
return result;
}
+
+ /** Counts the total number of misses registered so far regardless of their reason. */
+ public int countMisses() {
+ int total = 0;
+ for (Map.Entry<MissReason, Integer> entry : details.entrySet()) {
+ total += entry.getValue();
+ }
+ return total;
+ }
}
/**