Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiller committed Jan 31, 2025
1 parent 2bbcec0 commit fa8b4af
Showing 1 changed file with 106 additions and 0 deletions.
106 changes: 106 additions & 0 deletions tools/artifact_gen/artifact_gen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,108 @@ class ArtifactGen {
}
}

void PatchGrpcProtoLibraryRules() {
for (auto& [name, bazel_rule] : rules_) {
if (absl::StartsWith(name, "//") &&
(bazel_rule.generator_function == "grpc_proto_library" ||
bazel_rule.clazz == "cc_proto_library")) {
bazel_rule.deps.push_back("//third_party:protobuf");
}
}
}

void PatchDescriptorUpbProtoLibrary() {
auto it = rules_.find("@com_google_protobuf//upb:descriptor_upb_proto");
if (it == rules_.end()) return;
auto& bazel_rule = it->second;
bazel_rule.srcs.push_back(
":src/core/ext/upb-gen/google/protobuf/descriptor.upb_minitable.c");
bazel_rule.hdrs.push_back(
":src/core/ext/upb-gen/google/protobuf/descriptor.upb.h");
}

void PopulateCcTests() {
for (const auto& [_, bazel_rule] : rules_) {
if (bazel_rule.clazz != "cc_test") continue;
std::string test_name = bazel_rule.name;
if (!absl::StartsWith(test_name, "//")) continue;
test_name = test_name.substr(2);
if (!WantCcTest(test_name)) continue;
tests_.push_back(test_name);
}
}

void GenerateExtraMetadataForTests() {
for (const auto& test : tests_) {
LOG(FATAL) << "unimplemented";
}
}

private:
bool WantCcTest(absl::string_view test) {
// most qps tests are autogenerated, we are fine without them
if (absl::StartsWith(test, "test/cpp/qps:")) return false;
// microbenchmarks aren't needed for checking correctness
if (absl::StartsWith(test, "test/cpp/microbenchmarks:")) return false;
if (absl::StartsWith(test, "test/core/promise/benchmark:")) return false;
// we have trouble with census dependency outside of bazel
if (absl::StartsWith(test, "test/cpp/ext/filters/census:")) return false;
if (absl::StartsWith(test,
"test/core/server:xds_channel_stack_modifier_test")) {
return false;
}
if (absl::StartsWith(test, "test/cpp/ext/gcp:")) return false;
if (absl::StartsWith(test, "test/cpp/ext/filters/logging:")) return false;
if (absl::StartsWith(test, "test/cpp/interop:observability_interop")) {
return false;
}
// we have not added otel dependency outside of bazel
if (absl::StartsWith(test, "test/cpp/ext/csm:")) return false;
if (absl::StartsWith(test, "test/cpp/interop:xds_interop")) return false;
// missing opencensus/stats/stats.h
if (absl::StartsWith(
test, "test/cpp/end2end:server_load_reporting_end2end_test")) {
return false;
}
if (absl::StartsWith(
test, "test/cpp/server/load_reporter:lb_load_reporter_test")) {
return false;
}
// The test uses --running_under_bazel cmdline argument
// To avoid the trouble needing to adjust it, we just skip the test
if (absl::StartsWith(
test, "test/cpp/naming:resolver_component_tests_runner_invoker")) {
return false;
}
// the test requires 'client_crash_test_server' to be built
if (absl::StartsWith(test, "test/cpp/end2end:time_change_test")) {
return false;
}
if (absl::StartsWith(test, "test/cpp/end2end:client_crash_test")) {
return false;
}
// the test requires 'server_crash_test_client' to be built
if (absl::StartsWith(test, "test/cpp/end2end:server_crash_test")) {
return false;
}
// test never existed under build.yaml and it fails -> skip it
if (absl::StartsWith(test, "test/core/tsi:ssl_session_cache_test")) {
return false;
}
// the binary of this test does not get built with cmake
if (absl::StartsWith(test, "test/cpp/util:channelz_sampler_test")) {
return false;
}
// chaotic good not supported outside bazel
if (absl::StartsWith(test, "test/core/transport/chaotic_good")) {
return false;
}
// we don't need to generate fuzzers outside of bazel
if (absl::EndsWith(test, "_fuzzer")) return false;
if (absl::StrContains(test, "_fuzzer_")) return false;
return true;
}

std::set<std::string> GetTransitiveProtos(std::string root) {
std::queue<std::string> todo;
std::set<std::string> visited;
Expand Down Expand Up @@ -262,6 +363,7 @@ class ArtifactGen {
}

std::map<std::string, BazelRule> rules_;
std::vector<std::string> tests_;
const std::map<std::string, std::string> external_source_prefixes_ = {
// TODO(veblush) : Remove @utf8_range// item once protobuf is upgraded
// to 26.x
Expand Down Expand Up @@ -308,5 +410,9 @@ int main(int argc, char** argv) {
generator.LoadRulesXml(argv[i]);
}
generator.ExpandUpbProtoLibraryRules();
generator.PatchGrpcProtoLibraryRules();
generator.PatchDescriptorUpbProtoLibrary();
generator.PopulateCcTests();
generator.GenerateExtraMetadataForTests();
return 0;
}

0 comments on commit fa8b4af

Please sign in to comment.