Skip to content

Commit d642f32

Browse files
Merge pull request #74 from Tinder/add_test_coverage_stack_overflow
Add test for stack overflow situation
2 parents 4310ea8 + dded975 commit d642f32

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/java/com/bazel_diff/TargetHashingClientImplTests.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,26 @@ public void hashAllBazelTargets_ruleTargets_ruleInputs() throws IOException, NoS
102102
}
103103
}
104104

105+
@Test
106+
public void hashAllBazelTargets_ruleTargets_ruleInputsWithSelfInput() throws IOException, NoSuchAlgorithmException {
107+
List<String> ruleInputs = new ArrayList<>();
108+
ruleInputs.add("rule1");
109+
ruleInputs.add("rule4");
110+
BazelTarget rule3 = createRuleTarget("rule3", ruleInputs, "digest");
111+
defaultTargets.add(rule3);
112+
BazelTarget rule4 = createRuleTarget("rule4", ruleInputs, "digest2");
113+
defaultTargets.add(rule4);
114+
when(bazelClientMock.queryAllTargets()).thenReturn(defaultTargets);
115+
TargetHashingClientImpl client = new TargetHashingClientImpl(bazelClientMock, filesClientMock);
116+
try {
117+
Map<String, String> hash = client.hashAllBazelTargetsAndSourcefiles(new HashSet<>());
118+
assertEquals(4, hash.size());
119+
assertEquals("bf15e616e870aaacb02493ea0b8e90c6c750c266fa26375e22b30b78954ee523", hash.get("rule4"));
120+
} catch (IOException | NoSuchAlgorithmException e) {
121+
fail(e.getMessage());
122+
}
123+
}
124+
105125
private BazelTarget createRuleTarget(String ruleName, List<String> ruleInputs, String ruleDigest) throws NoSuchAlgorithmException {
106126
BazelTarget target = mock(BazelTarget.class);
107127
BazelRule rule = mock(BazelRule.class);

0 commit comments

Comments
 (0)