| // Protocol Buffers - Google's data interchange format |
| // Copyright 2026 Google LLC. All rights reserved. |
| // |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file or at |
| // https://developers.google.com/open-source/licenses/bsd |
| |
| // Defines the global --testee_binary, --testee_args, --failure_list, |
| // --enforcement_level, --maximum_edition, --performance, --fix and |
| // --fix_output_file flags. Being process-global ABSL_FLAGs with short, generic |
| // names, they must only be linked into binaries with a test_environment_main- |
| // style main (see test_environment_flags.h), never into |
| // conformance_test_runner, whose legacy command line parses flags of the same |
| // names itself. |
| |
| #include "conformance/test_environment_flags.h" |
| |
| #include <string> |
| #include <vector> |
| |
| #include "google/protobuf/descriptor.pb.h" |
| #include "absl/flags/flag.h" |
| #include "absl/types/span.h" |
| #include "conformance/test_environment.h" |
| #include "conformance/testee.h" |
| |
| ABSL_FLAG(std::string, testee_binary, "", |
| "The testee program to run conformance tests against."); |
| ABSL_FLAG(std::vector<std::string>, testee_args, {}, |
| "Comma-separated arguments to pass to --testee_binary. Positional " |
| "arguments are appended to these."); |
| ABSL_FLAG(std::vector<std::string>, failure_list, {}, |
| "Comma-separated list of files containing the tests that are " |
| "expected to fail, one test name per line. Use '#' for comments."); |
| ABSL_FLAG(google::protobuf::conformance::TestPriority, enforcement_level, |
| google::protobuf::conformance::kLowestPriority, |
| "The lowest priority whose failures fail the run, as its number: 0 " |
| "enforces only P0, 1 enforces P0 and P1. The default enforces every " |
| "priority. Failures of tests of a lower priority are tolerated " |
| "(counted, not failed) unless the test is in the failure list, which " |
| "is checked whatever the level."); |
| ABSL_FLAG(google::protobuf::Edition, maximum_edition, google::protobuf::EDITION_PROTO3, |
| "Only run conformance tests up to and including this edition, e.g. " |
| "EDITION_2023. Defaults to proto2 and proto3 only."); |
| // TODO: Transitional. Goes away with the in-binary |
| // performance mode, see ConformanceEnvironmentOptions::performance. |
| ABSL_FLAG(bool, performance, false, |
| "Run only the performance tests instead of the regular tests. A " |
| "performance run needs its own failure list."); |
| ABSL_FLAG(bool, fix, false, |
| "Rewrite the failure list at the end of the run to match the " |
| "observed results. See --fix_output_file. Refused when only some " |
| "of the tests run (--gtest_filter, sharding)."); |
| ABSL_FLAG(std::string, fix_output_file, "", |
| "Where --fix writes the updated failure list. Required when more " |
| "than one --failure_list is given; otherwise defaults to the " |
| "failure list itself under $BUILD_WORKSPACE_DIRECTORY, so that " |
| "`bazel run ... -- --fix` updates the file in your workspace."); |
| |
| namespace google { |
| namespace protobuf { |
| namespace conformance { |
| namespace internal { |
| |
| ConformanceEnvironmentOptions OptionsFromFlags( |
| absl::Span<char* const> positional_args) { |
| ConformanceEnvironmentOptions options; |
| options.testee_binary = absl::GetFlag(FLAGS_testee_binary); |
| options.testee_args = absl::GetFlag(FLAGS_testee_args); |
| for (const char* positional_arg : positional_args) { |
| options.testee_args.push_back(positional_arg); |
| } |
| options.failure_list_files = absl::GetFlag(FLAGS_failure_list); |
| options.enforcement_level = absl::GetFlag(FLAGS_enforcement_level); |
| options.maximum_edition = absl::GetFlag(FLAGS_maximum_edition); |
| options.performance = absl::GetFlag(FLAGS_performance); |
| options.fix = absl::GetFlag(FLAGS_fix); |
| options.fix_output_file = absl::GetFlag(FLAGS_fix_output_file); |
| return options; |
| } |
| |
| } // namespace internal |
| } // namespace conformance |
| } // namespace protobuf |
| } // namespace google |