Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable conformance tests for extensions #930

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ go_repository(
# CEL Spec deps
go_repository(
name = "com_google_cel_spec",
commit = "1bc3fb168317fa77d1227c52d0becbf2d358c023",
commit = "91f3cb1a7590f594a392b607ae9cab5e969b4cf3",
importpath = "github.com/google/cel-spec",
)

Expand Down
3 changes: 3 additions & 0 deletions conformance/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ ALL_TESTS = [
"@com_google_cel_spec//tests/simple:testdata/lists.textproto",
"@com_google_cel_spec//tests/simple:testdata/logic.textproto",
"@com_google_cel_spec//tests/simple:testdata/macros.textproto",
"@com_google_cel_spec//tests/simple:testdata/math_ext.textproto",
"@com_google_cel_spec//tests/simple:testdata/namespace.textproto",
"@com_google_cel_spec//tests/simple:testdata/optionals.textproto",
"@com_google_cel_spec//tests/simple:testdata/parse.textproto",
"@com_google_cel_spec//tests/simple:testdata/plumbing.textproto",
"@com_google_cel_spec//tests/simple:testdata/proto2.textproto",
"@com_google_cel_spec//tests/simple:testdata/proto3.textproto",
"@com_google_cel_spec//tests/simple:testdata/string.textproto",
"@com_google_cel_spec//tests/simple:testdata/string_ext.textproto",
"@com_google_cel_spec//tests/simple:testdata/timestamps.textproto",
"@com_google_cel_spec//tests/simple:testdata/unknowns.textproto",
"@com_google_cel_spec//tests/simple:testdata/wrappers.textproto",
Expand All @@ -37,6 +39,7 @@ sh_test(
# Failing conformance tests.
"--skip_test=fields/qualified_identifier_resolution/map_key_float,map_key_null,map_value_repeat_key",
"--skip_test=fields/qualified_identifier_resolution/map_value_repeat_key_heterogeneous",
"--skip_test=macros/map/map_extract_keys",
"--skip_test=timestamps/duration_converters/get_milliseconds",

# Future enhancments.
Expand Down
1 change: 1 addition & 0 deletions server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ go_library(
"//cel:go_default_library",
"//common/types:go_default_library",
"//common/types/ref:go_default_library",
"//ext:go_default_library",
"@com_google_cel_spec//proto/test/v1/proto2:test_all_types_go_proto",
"@com_google_cel_spec//proto/test/v1/proto3:test_all_types_go_proto",
"@org_golang_google_genproto_googleapis_api//expr/conformance/v1alpha1:go_default_library",
Expand Down
17 changes: 15 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/google/cel-go/cel"
"github.com/google/cel-go/common/types"
"github.com/google/cel-go/common/types/ref"
"github.com/google/cel-go/ext"

test2pb "github.com/google/cel-spec/proto/test/v1/proto2/test_all_types"
test3pb "github.com/google/cel-spec/proto/test/v1/proto3/test_all_types"
Expand All @@ -41,7 +42,11 @@ func (s *ConformanceServer) Parse(ctx context.Context, in *confpb.ParseRequest)
return nil, invalidArgument("No source code.")
}
// NOTE: syntax_version isn't currently used
var parseOptions []cel.EnvOption
parseOptions := []cel.EnvOption{
ext.Math(),
ext.Protos(),
ext.Bindings(),
}
if in.DisableMacros {
parseOptions = append(parseOptions, cel.ClearMacros())
}
Expand All @@ -68,7 +73,12 @@ func (s *ConformanceServer) Check(ctx context.Context, in *confpb.CheckRequest)
return nil, invalidArgument("No source info.")
}
// Build the environment.
var checkOptions []cel.EnvOption = []cel.EnvOption{cel.StdLib()}
checkOptions := []cel.EnvOption{
cel.StdLib(),
ext.Strings(),
ext.Math(),
ext.Encoders(),
}
if in.NoStdEnv {
checkOptions = []cel.EnvOption{}
}
Expand Down Expand Up @@ -255,6 +265,9 @@ var evalEnv *cel.Env

func init() {
evalEnv, _ = cel.NewEnv(
ext.Strings(),
ext.Math(),
ext.Encoders(),
cel.Types(&test2pb.TestAllTypes{}, &test3pb.TestAllTypes{}),
cel.EagerlyValidateDeclarations(true),
cel.OptionalTypes())
Expand Down