| 63 | ABSL_FLAG(std::vector<std::string>, skip_tests, {}, "Tests to skip"); |
| 64 | ABSL_FLAG(bool, dashboard, false, "Dashboard mode, ignore test failures"); |
| 65 | ABSL_FLAG(bool, skip_check, true, "Skip type checking the expressions"); |
| 66 | ABSL_FLAG(bool, select_optimization, false, "Enable select optimization."); |
| 67 | |
| 68 | namespace { |
| 69 | |
| 70 | using ::testing::IsEmpty; |
| 71 | |
| 72 | using cel::expr::conformance::test::SimpleTest; |
| 73 | using cel::expr::conformance::test::SimpleTestFile; |
| 74 | using google::api::expr::conformance::v1alpha1::CheckRequest; |
| 75 | using google::api::expr::conformance::v1alpha1::CheckResponse; |
| 76 | using google::api::expr::conformance::v1alpha1::EvalRequest; |
| 77 | using google::api::expr::conformance::v1alpha1::EvalResponse; |
| 78 | using google::api::expr::conformance::v1alpha1::ParseRequest; |
| 79 | using google::api::expr::conformance::v1alpha1::ParseResponse; |
| 80 | |
| 81 | google::rpc::Code ToGrpcCode(absl::StatusCode code) { |
| 82 | return static_cast<google::rpc::Code>(code); |
| 83 | } |
| 84 | |
| 85 | bool ShouldSkipTest(absl::Span<const std::string> tests_to_skip, |
| 86 | absl::string_view name) { |
| 87 | for (absl::string_view test_to_skip : tests_to_skip) { |
| 88 | auto consumed_name = name; |
| 89 | if (absl::ConsumePrefix(&consumed_name, test_to_skip) && |
| 90 | (consumed_name.empty() || absl::StartsWith(consumed_name, "/"))) { |
| 91 | return true; |
| 92 | } |
| 93 | } |
| 94 | return false; |
| 95 | } |
| 96 | |
| 97 | SimpleTest DefaultTestMatcherToTrueIfUnset(const SimpleTest& test) { |
| 98 | auto test_copy = test; |
| 99 | if (test_copy.result_matcher_case() == SimpleTest::RESULT_MATCHER_NOT_SET) { |
| 100 | test_copy.mutable_value()->set_bool_value(true); |
| 101 | } |
| 102 | return test_copy; |
| 103 | } |
| 104 | |
| 105 | class ConformanceTest : public testing::Test { |
| 106 | public: |
| 107 | explicit ConformanceTest( |
| 108 | std::shared_ptr<cel_conformance::ConformanceServiceInterface> service, |
| 109 | const SimpleTest& test, bool skip) |
| 110 | : service_(std::move(service)), |
| 111 | test_(DefaultTestMatcherToTrueIfUnset(test)), |
| 112 | skip_(skip) {} |
| 113 | |
| 114 | void TestBody() override { |
| 115 | if (skip_) { |
| 116 | GTEST_SKIP(); |
| 117 | } |
| 118 | ParseRequest parse_request; |
| 119 | parse_request.set_cel_source(test_.expr()); |
| 120 | parse_request.set_source_location(test_.name()); |
| 121 | parse_request.set_disable_macros(test_.disable_macros()); |
| 122 | ParseResponse parse_response; |
no test coverage detected