Skip to content

Commit

Permalink
feat(tooling): mark conflicting /kythe/code facts as ok with ignore f…
Browse files Browse the repository at this point in the history
…lag and add tests (#5410)
  • Loading branch information
BrianWieder committed Oct 26, 2022
1 parent e99afd2 commit 73dab3e
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kythe/cxx/verifier/verifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1293,15 +1293,16 @@ bool Verifier::PrepareDatabase() {
print_decoded(ta->element(4));
printer.Print("\n ----------------- versus ----------------- \n\n");
print_decoded(tb->element(4));
is_ok = false;
}
} else {
printer.Print("Two facts about a node differed in value:\n ");
fa->Dump(symbol_table_, &printer);
printer.Print("\n ");
fb->Dump(symbol_table_, &printer);
printer.Print("\n");
is_ok = false;
}
is_ok = false;
}
}
if (is_ok) {
Expand Down
63 changes: 63 additions & 0 deletions kythe/cxx/verifier/verifier_unit_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2934,6 +2934,69 @@ TEST(VerifierUnitTest, ConvertMarkedSourceDuplicateFactsWellFormed) {
ASSERT_TRUE(v.VerifyAllGoals());
}

TEST(VerifierUnitTest, ConflictingCodeFactsNotWellFormed) {
Verifier v;
MarkedSource source;
google::protobuf::string source_string;
ASSERT_TRUE(source.SerializeToString(&source_string));
google::protobuf::TextFormat::FieldValuePrinter printer;
google::protobuf::string enc_source = printer.PrintBytes(source_string);

MarkedSource source_conflict;
source_conflict.set_pre_text("pre_text");
google::protobuf::string source_conflict_string;
ASSERT_TRUE(source_conflict.SerializeToString(&source_conflict_string));
google::protobuf::string enc_source_conflict =
printer.PrintBytes(source_conflict_string);
ASSERT_TRUE(v.LoadInlineProtoFile(R"(
entries {
source { signature:"test" }
fact_name: "/kythe/code"
fact_value: )" + enc_source + R"(
}
entries {
source { signature:"test" }
fact_name: "/kythe/code"
fact_value: )" + enc_source_conflict +
R"(
}
)"));
ASSERT_FALSE(v.PrepareDatabase());
ASSERT_FALSE(v.VerifyAllGoals());
}

TEST(VerifierUnitTest, ConflictingCodeFactsIgnoreWellFormed) {
Verifier v;
v.IgnoreCodeConflicts();
MarkedSource source;
google::protobuf::string source_string;
ASSERT_TRUE(source.SerializeToString(&source_string));
google::protobuf::TextFormat::FieldValuePrinter printer;
google::protobuf::string enc_source = printer.PrintBytes(source_string);

MarkedSource source_conflict;
source_conflict.set_pre_text("pre_text");
google::protobuf::string source_conflict_string;
ASSERT_TRUE(source_conflict.SerializeToString(&source_conflict_string));
google::protobuf::string enc_source_conflict =
printer.PrintBytes(source_conflict_string);
ASSERT_TRUE(v.LoadInlineProtoFile(R"(
entries {
source { signature:"test" }
fact_name: "/kythe/code"
fact_value: )" + enc_source + R"(
}
entries {
source { signature:"test" }
fact_name: "/kythe/code"
fact_value: )" + enc_source_conflict +
R"(
}
)"));
ASSERT_TRUE(v.PrepareDatabase());
ASSERT_TRUE(v.VerifyAllGoals());
}

} // anonymous namespace
} // namespace verifier
} // namespace kythe
Expand Down

0 comments on commit 73dab3e

Please sign in to comment.