From b30b9335ab185837e03527b4bf9c3c40b41db767 Mon Sep 17 00:00:00 2001 From: jmmv Date: Thu, 21 Dec 2017 10:30:44 -0800 Subject: 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 --- .../google/devtools/build/lib/actions/util/ActionsTestUtil.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/test/java/com/google/devtools/build/lib/actions') 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 entry : details.entrySet()) { + total += entry.getValue(); + } + return total; + } } /** -- cgit v1.2.3