From 46eccab762993606a4c4ab496dd1a62d6681f01f Mon Sep 17 00:00:00 2001 From: Alfred Fuller Date: Wed, 21 Jun 2023 12:38:10 -0700 Subject: [PATCH 1/3] Add test protos to dev.cel.expr.conformance --- proto/dev/cel/expr/conformance/BUILD.bazel | 92 ++++++++++++++- .../conformance/conformance_service.proto | 2 +- proto/dev/cel/expr/conformance/envcheck.proto | 23 ++++ proto/dev/cel/expr/conformance/simple.proto | 110 ++++++++++++++++++ 4 files changed, 223 insertions(+), 4 deletions(-) create mode 100644 proto/dev/cel/expr/conformance/envcheck.proto create mode 100644 proto/dev/cel/expr/conformance/simple.proto diff --git a/proto/dev/cel/expr/conformance/BUILD.bazel b/proto/dev/cel/expr/conformance/BUILD.bazel index d54b709b..0587971f 100644 --- a/proto/dev/cel/expr/conformance/BUILD.bazel +++ b/proto/dev/cel/expr/conformance/BUILD.bazel @@ -8,15 +8,48 @@ proto_library( name = "conformance_proto", srcs = [ "conformance_service.proto", + "envcheck.proto", + "simple.proto", ], strip_import_prefix = "/proto", deps = [ "//proto/dev/cel/expr:expr_proto", - "@com_google_googleapis//google/api:client_proto", "@com_google_googleapis//google/rpc:status_proto", ], ) +proto_library( + name = "conformance_service_proto", + srcs = ["conformance_service.proto"], + strip_import_prefix = "/proto", + deps = [ + "//proto/dev/cel/expr:checked_proto", + "//proto/dev/cel/expr:eval_proto", + "//proto/dev/cel/expr:syntax_proto", + "@com_google_googleapis//google/rpc:status_proto", + ], +) + +proto_library( + name = "envcheck_proto", + srcs = ["envcheck.proto"], + strip_import_prefix = "/proto", + deps = [ + "//proto/dev/cel/expr:checked_proto", + ], +) + +proto_library( + name = "simple_proto", + srcs = ["simple.proto"], + strip_import_prefix = "/proto", + deps = [ + "//proto/dev/cel/expr:checked_proto", + "//proto/dev/cel/expr:eval_proto", + "//proto/dev/cel/expr:value_proto", + ], +) + ############################################################################## # Java ############################################################################## @@ -25,6 +58,21 @@ java_proto_library( deps = [":conformance_proto"], ) +java_proto_library( + name = "conformance_service_java_proto", + deps = [":conformance_service_proto"], +) + +java_proto_library( + name = "envcheck_java_proto", + deps = [":envcheck_proto"], +) + +java_proto_library( + name = "simple_java_proto", + deps = [":simple_proto"], +) + ############################################################################### ## Go ############################################################################### @@ -41,11 +89,49 @@ go_proto_library( ], ) +go_proto_library( + name = "conformance_service_go_proto", + importpath = "dev.cel/expr/conformance", + protos = [":conformance_service_proto"], + deps = [ + "//proto/dev/cel/expr:expr_go_proto", + "//proto/dev/cel/expr:google_rpc_status_go_proto", + ], +) + +go_proto_library( + name = "envcheck_go_proto", + importpath = "dev.cel/expr/conformance", + protos = [":envcheck_proto"], + deps = [ + "//proto/dev/cel/expr:expr_go_proto", + ], +) + +go_proto_library( + name = "simple_go_proto", + importpath = "dev.cel/expr/conformance", + protos = [":simple_proto"], + deps = [ + "//proto/dev/cel/expr:expr_go_proto", + ], +) + ############################################################################### ## C++ ############################################################################### cc_proto_library( - name = "conformance_cc_proto", - deps = [":conformance_proto"], + name = "conformance_service_cc_proto", + deps = [":conformance_service_proto"], +) + +cc_proto_library( + name = "envcheck_cc_proto", + deps = [":envcheck_proto"], +) + +cc_proto_library( + name = "simple_cc_proto", + deps = [":simple_proto"], ) diff --git a/proto/dev/cel/expr/conformance/conformance_service.proto b/proto/dev/cel/expr/conformance/conformance_service.proto index 149e0674..05e3af56 100644 --- a/proto/dev/cel/expr/conformance/conformance_service.proto +++ b/proto/dev/cel/expr/conformance/conformance_service.proto @@ -25,7 +25,7 @@ option cc_enable_arenas = true; option go_package = "dev.cel/expr/conformance"; option java_multiple_files = true; option java_outer_classname = "ConformanceServiceProto"; -option java_package = "dev.cel.expr"; +option java_package = "dev.cel.expr.conformance"; // Access a CEL implementation from another process or machine. // A CEL implementation is decomposed as a parser, a static checker, diff --git a/proto/dev/cel/expr/conformance/envcheck.proto b/proto/dev/cel/expr/conformance/envcheck.proto new file mode 100644 index 00000000..b916b7c2 --- /dev/null +++ b/proto/dev/cel/expr/conformance/envcheck.proto @@ -0,0 +1,23 @@ +// Tests for runtime support of standard functions. + +syntax = "proto3"; + +package dev.cel.expr.conformance; + +import "dev/cel/expr/checked.proto"; + +option cc_enable_arenas = true; +option go_package = "dev.cel/expr/conformance"; +option java_multiple_files = true; +option java_outer_classname = "EnvcheckProto"; +option java_package = "dev.cel.expr.conformance"; + +// The format of a standard environment, i.e. a collection of declarations +// for the checker. +message Env { + // Required. The name of the environment. + string name = 1; + + // The declarations in this environment. + repeated dev.cel.expr.Decl decl = 2; +} diff --git a/proto/dev/cel/expr/conformance/simple.proto b/proto/dev/cel/expr/conformance/simple.proto new file mode 100644 index 00000000..45178a47 --- /dev/null +++ b/proto/dev/cel/expr/conformance/simple.proto @@ -0,0 +1,110 @@ +// Simple end-to-end conformance tests. + +syntax = "proto3"; + +package dev.cel.expr.conformance; + +import "dev/cel/expr/checked.proto"; +import "dev/cel/expr/eval.proto"; +import "dev/cel/expr/value.proto"; + +option cc_enable_arenas = true; +option go_package = "dev.cel/expr/conformance"; +option java_multiple_files = true; +option java_outer_classname = "SimpleProto"; +option java_package = "dev.cel.expr.conformance"; + +// The format of a simple test file, expected to be stored in text format. +// A file is the unit of granularity for selecting conformance tests, +// so tests of optional features should be segregated into separate files. +message SimpleTestFile { + // Required. The name of the file. Should match the filename. + string name = 1; + + // A description of the file. + string description = 2; + + // The contained sections. + repeated SimpleTestSection section = 3; +} + +// A collection of related SimpleTests. +// +// The section is the unit of organization within a test file, and should +// guide where new tests are added. +message SimpleTestSection { + // Required. The name of the section. + string name = 1; + + // A description of the section. + string description = 2; + + // The contained tests. + repeated SimpleTest test = 3; +} + +// A test which should run the given CEL program through parsing, +// optionally through checking, then evaluation, with the results +// of the pipeline validated by the given result matcher. +message SimpleTest { + // Required. The name of the test, which should be unique in the test file. + string name = 1; + + // A description of the test. + string description = 2; + + // Required. The text of the CEL expression. + string expr = 3; + + // Disables all macro expansion in parsing. + bool disable_macros = 4; + + // Disables the check phase. + bool disable_check = 5; + + // The type environment to use for the check phase. + repeated dev.cel.expr.Decl type_env = 6; + + // The container for name resolution. + string container = 13; + + // Variable bindings to use for the eval phase. + map bindings = 7; + + // An unspecified result defaults to a matcher for the true boolean value. + oneof result_matcher { + // A normal value, which must match the evaluation result exactly + // via value equality semantics. This coincides with proto equality, + // except for: + // * maps are order-agnostic. + // * a floating point NaN should match any NaN. + dev.cel.expr.Value value = 8; + + // Matches error evaluation results. + dev.cel.expr.ErrorSet eval_error = 9; + + // Matches one of several error results. + // (Using explicit message since oneof can't handle repeated.) + ErrorSetMatcher any_eval_errors = 10; + + // Matches unknown evaluation results. + dev.cel.expr.UnknownSet unknown = 11; + + // Matches one of several unknown results. + // (Using explicit message since oneof can't handle repeated.) + UnknownSetMatcher any_unknowns = 12; + } + // Next is 14. +} + +// Matches error results from Eval. +message ErrorSetMatcher { + // Success if we match any of these sets. + repeated dev.cel.expr.ErrorSet errors = 1; +} + +// Matches unknown results from Eval. +message UnknownSetMatcher { + // Success if we match any of these sets. + repeated dev.cel.expr.UnknownSet unknowns = 1; +} From e043735c5d18ea3de41f69824660acaf2f69801c Mon Sep 17 00:00:00 2001 From: Alfred Fuller Date: Wed, 21 Jun 2023 12:49:30 -0700 Subject: [PATCH 2/3] add header --- proto/dev/cel/expr/conformance/envcheck.proto | 14 ++++++++++++++ proto/dev/cel/expr/conformance/simple.proto | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/proto/dev/cel/expr/conformance/envcheck.proto b/proto/dev/cel/expr/conformance/envcheck.proto index b916b7c2..1caa5ea0 100644 --- a/proto/dev/cel/expr/conformance/envcheck.proto +++ b/proto/dev/cel/expr/conformance/envcheck.proto @@ -1,3 +1,17 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Tests for runtime support of standard functions. syntax = "proto3"; diff --git a/proto/dev/cel/expr/conformance/simple.proto b/proto/dev/cel/expr/conformance/simple.proto index 45178a47..1c42759e 100644 --- a/proto/dev/cel/expr/conformance/simple.proto +++ b/proto/dev/cel/expr/conformance/simple.proto @@ -1,3 +1,17 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Simple end-to-end conformance tests. syntax = "proto3"; From f92c1627cb01137093d3c54023b08ab113448ed5 Mon Sep 17 00:00:00 2001 From: Alfred Fuller Date: Mon, 26 Jun 2023 12:33:54 -0700 Subject: [PATCH 3/3] fix merge --- proto/dev/cel/expr/conformance/BUILD.bazel | 39 ++++++++++------------ 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/proto/dev/cel/expr/conformance/BUILD.bazel b/proto/dev/cel/expr/conformance/BUILD.bazel index 987096ad..0587971f 100644 --- a/proto/dev/cel/expr/conformance/BUILD.bazel +++ b/proto/dev/cel/expr/conformance/BUILD.bazel @@ -5,7 +5,7 @@ package(default_visibility = ["//visibility:public"]) ############################################################################## proto_library( - name = "conformance_service_proto", + name = "conformance_proto", srcs = [ "conformance_service.proto", "envcheck.proto", @@ -54,23 +54,8 @@ proto_library( # Java ############################################################################## java_proto_library( - name = "conformance_service_java_proto", - deps = [":conformance_service_proto"], -) - -java_proto_library( - name = "conformance_service_java_proto", - deps = [":conformance_service_proto"], -) - -java_proto_library( - name = "envcheck_java_proto", - deps = [":envcheck_proto"], -) - -java_proto_library( - name = "simple_java_proto", - deps = [":simple_proto"], + name = "conformance_java_proto", + deps = [":conformance_proto"], ) java_proto_library( @@ -95,9 +80,9 @@ java_proto_library( load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") go_proto_library( - name = "conformance_service_go_proto", + name = "conformance_go_proto", importpath = "dev.cel/expr/conformance", - protos = [":conformance_service_proto"], + protos = [":conformance_proto"], deps = [ "//proto/dev/cel/expr:expr_go_proto", "//proto/dev/cel/expr:google_rpc_status_go_proto", @@ -137,6 +122,16 @@ go_proto_library( ############################################################################### cc_proto_library( - name = "conformance_cc_proto", - deps = [":conformance_proto"], + name = "conformance_service_cc_proto", + deps = [":conformance_service_proto"], +) + +cc_proto_library( + name = "envcheck_cc_proto", + deps = [":envcheck_proto"], +) + +cc_proto_library( + name = "simple_cc_proto", + deps = [":simple_proto"], )