Simplify/sharpen some assertions about analyzed configured targets in AnalysisCachingTest.
I came across this while trying to modify unit tests for unknown commit. I managed to avoid modifying the tests in the end, but this seemed like a worthwhile change regardless.
@@ -393,7 +393,8 @@ public class AnalysisCachingTest extends AnalysisCachingTestBase {
assertThat(countObjectsPartiallyMatchingRegex(oldAnalyzedTargets, "//java/a:y")).isEqualTo(1);
update("//java/a:x");
Set<?> newAnalyzedTargets = getSkyframeEvaluatedTargetKeys();
- assertThat(newAnalyzedTargets).isNotEmpty(); // could be greater due to implicit deps
+ // Source target and rule target.
+ assertThat(newAnalyzedTargets).hasSize(2);
assertThat(countObjectsPartiallyMatchingRegex(newAnalyzedTargets, "//java/a:x")).isEqualTo(1);
assertThat(countObjectsPartiallyMatchingRegex(newAnalyzedTargets, "//java/a:y")).isEqualTo(0);
}
@@ -669,12 +670,7 @@ public class AnalysisCachingTest extends AnalysisCachingTestBase {
useConfiguration("--definitely_relevant=Testing");
update("//test:top");
update("//test:top");
- // these targets were cached and did not need to be reanalyzed
- assertNumberOfAnalyzedConfigurationsOfTargets(
- ImmutableMap.<String, Integer>builder()
- .put("//test:top", 0)
- .put("//test:shared", 0)
- .build());
+ assertNoTargetsVisited();
}
@Test
@@ -689,11 +685,7 @@ public class AnalysisCachingTest extends AnalysisCachingTestBase {
update("//test:top");
update("//test:top");
// these targets were cached and did not need to be reanalyzed
- assertNumberOfAnalyzedConfigurationsOfTargets(
- ImmutableMap.<String, Integer>builder()
- .put("//test:top", 0)
- .put("//test:shared", 0)
- .build());
+ assertNoTargetsVisited();
}
@Test
