diff --git a/proto/dev/cel/expr/conformance/BUILD.bazel b/proto/dev/cel/expr/conformance/BUILD.bazel index c6f88d93..0587971f 100644 --- a/proto/dev/cel/expr/conformance/BUILD.bazel +++ b/proto/dev/cel/expr/conformance/BUILD.bazel @@ -5,9 +5,11 @@ package(default_visibility = ["//visibility:public"]) ############################################################################## proto_library( - name = "conformance_service_proto", + name = "conformance_proto", srcs = [ "conformance_service.proto", + "envcheck.proto", + "simple.proto", ], strip_import_prefix = "/proto", deps = [ @@ -16,20 +18,77 @@ proto_library( ], ) +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 ############################################################################## +java_proto_library( + name = "conformance_java_proto", + 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 ############################################################################### load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") +go_proto_library( + name = "conformance_go_proto", + importpath = "dev.cel/expr/conformance", + protos = [":conformance_proto"], + deps = [ + "//proto/dev/cel/expr:expr_go_proto", + "//proto/dev/cel/expr:google_rpc_status_go_proto", + ], +) + go_proto_library( name = "conformance_service_go_proto", importpath = "dev.cel/expr/conformance", @@ -40,6 +99,24 @@ go_proto_library( ], ) +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++ ############################################################################### @@ -48,3 +125,13 @@ cc_proto_library( 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/envcheck.proto b/proto/dev/cel/expr/conformance/envcheck.proto new file mode 100644 index 00000000..1caa5ea0 --- /dev/null +++ b/proto/dev/cel/expr/conformance/envcheck.proto @@ -0,0 +1,37 @@ +// 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"; + +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..1c42759e --- /dev/null +++ b/proto/dev/cel/expr/conformance/simple.proto @@ -0,0 +1,124 @@ +// 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"; + +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; +}