Skip to content

Commit f17ad10

Browse files
author
David Ungar
committed
Fix fingerprint formation for unit driver tests
1 parent c9e12d3 commit f17ad10

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

unittests/Driver/FineGrainedDependencyGraphTests.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,19 @@ static bool contains(const Range &range, const T &value) {
5757
std::end(range);
5858
}
5959

60+
/// Ensure that 0 and 10 get distinct fingerprints
61+
TEST(ModuleDepGraph, FingerprintFormation) {
62+
ModuleDepGraph graph;
63+
64+
simulateLoad(graph, &job0, {{NodeKind::topLevel, {"a"}}});
65+
simulateLoad(graph, &job1, {{NodeKind::topLevel, {"a->", "z"}}});
66+
simulateLoad(graph, &job10, {{NodeKind::topLevel, {"z"}}});
67+
{
68+
auto jobs = graph.findJobsToRecompileWhenWholeJobChanges(&job0);
69+
EXPECT_FALSE(contains(jobs, &job10));
70+
}
71+
}
72+
6073
TEST(ModuleDepGraph, BasicLoad) {
6174
ModuleDepGraph graph;
6275

unittests/Driver/MockingFineGrainedDependencyGraphs.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ mocking_fine_grained_dependency_graphs::getChangesForSimulatedLoad(
4343
auto swiftDeps =
4444
cmd->getOutput().getAdditionalOutputForType(file_types::TY_SwiftDeps).str();
4545
assert(!swiftDeps.empty());
46-
swiftDeps.resize(Fingerprint::DIGEST_LENGTH, 'X');
46+
// Insert at start so that "1" and "10" are distinct
47+
swiftDeps.insert(0, Fingerprint::DIGEST_LENGTH - swiftDeps.size(), '0');
4748
auto swiftDepsFingerprint = Fingerprint::fromString(swiftDeps);
4849
if (!swiftDepsFingerprint) {
4950
llvm::errs() << "unconvertable fingerprint from switdeps ':"

0 commit comments

Comments
 (0)