Skip to content

Commit 057d4c8

Browse files
Enable conformance tests for extensions (#930)
1 parent 028e53c commit 057d4c8

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ go_repository(
119119
# CEL Spec deps
120120
go_repository(
121121
name = "com_google_cel_spec",
122-
commit = "1bc3fb168317fa77d1227c52d0becbf2d358c023",
122+
commit = "91f3cb1a7590f594a392b607ae9cab5e969b4cf3",
123123
importpath = "github.com/google/cel-spec",
124124
)
125125

conformance/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ ALL_TESTS = [
1010
"@com_google_cel_spec//tests/simple:testdata/lists.textproto",
1111
"@com_google_cel_spec//tests/simple:testdata/logic.textproto",
1212
"@com_google_cel_spec//tests/simple:testdata/macros.textproto",
13+
"@com_google_cel_spec//tests/simple:testdata/math_ext.textproto",
1314
"@com_google_cel_spec//tests/simple:testdata/namespace.textproto",
1415
"@com_google_cel_spec//tests/simple:testdata/optionals.textproto",
1516
"@com_google_cel_spec//tests/simple:testdata/parse.textproto",
1617
"@com_google_cel_spec//tests/simple:testdata/plumbing.textproto",
1718
"@com_google_cel_spec//tests/simple:testdata/proto2.textproto",
1819
"@com_google_cel_spec//tests/simple:testdata/proto3.textproto",
1920
"@com_google_cel_spec//tests/simple:testdata/string.textproto",
21+
"@com_google_cel_spec//tests/simple:testdata/string_ext.textproto",
2022
"@com_google_cel_spec//tests/simple:testdata/timestamps.textproto",
2123
"@com_google_cel_spec//tests/simple:testdata/unknowns.textproto",
2224
"@com_google_cel_spec//tests/simple:testdata/wrappers.textproto",
@@ -37,6 +39,7 @@ sh_test(
3739
# Failing conformance tests.
3840
"--skip_test=fields/qualified_identifier_resolution/map_key_float,map_key_null,map_value_repeat_key",
3941
"--skip_test=fields/qualified_identifier_resolution/map_value_repeat_key_heterogeneous",
42+
"--skip_test=macros/map/map_extract_keys",
4043
"--skip_test=timestamps/duration_converters/get_milliseconds",
4144

4245
# Future enhancments.

server/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ go_library(
1515
"//cel:go_default_library",
1616
"//common/types:go_default_library",
1717
"//common/types/ref:go_default_library",
18+
"//ext:go_default_library",
1819
"@com_google_cel_spec//proto/test/v1/proto2:test_all_types_go_proto",
1920
"@com_google_cel_spec//proto/test/v1/proto3:test_all_types_go_proto",
2021
"@org_golang_google_genproto_googleapis_api//expr/conformance/v1alpha1:go_default_library",

server/server.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/google/cel-go/cel"
2323
"github.com/google/cel-go/common/types"
2424
"github.com/google/cel-go/common/types/ref"
25+
"github.com/google/cel-go/ext"
2526

2627
test2pb "github.com/google/cel-spec/proto/test/v1/proto2/test_all_types"
2728
test3pb "github.com/google/cel-spec/proto/test/v1/proto3/test_all_types"
@@ -41,7 +42,11 @@ func (s *ConformanceServer) Parse(ctx context.Context, in *confpb.ParseRequest)
4142
return nil, invalidArgument("No source code.")
4243
}
4344
// NOTE: syntax_version isn't currently used
44-
var parseOptions []cel.EnvOption
45+
parseOptions := []cel.EnvOption{
46+
ext.Math(),
47+
ext.Protos(),
48+
ext.Bindings(),
49+
}
4550
if in.DisableMacros {
4651
parseOptions = append(parseOptions, cel.ClearMacros())
4752
}
@@ -68,7 +73,12 @@ func (s *ConformanceServer) Check(ctx context.Context, in *confpb.CheckRequest)
6873
return nil, invalidArgument("No source info.")
6974
}
7075
// Build the environment.
71-
var checkOptions []cel.EnvOption = []cel.EnvOption{cel.StdLib()}
76+
checkOptions := []cel.EnvOption{
77+
cel.StdLib(),
78+
ext.Strings(),
79+
ext.Math(),
80+
ext.Encoders(),
81+
}
7282
if in.NoStdEnv {
7383
checkOptions = []cel.EnvOption{}
7484
}
@@ -255,6 +265,9 @@ var evalEnv *cel.Env
255265

256266
func init() {
257267
evalEnv, _ = cel.NewEnv(
268+
ext.Strings(),
269+
ext.Math(),
270+
ext.Encoders(),
258271
cel.Types(&test2pb.TestAllTypes{}, &test3pb.TestAllTypes{}),
259272
cel.EagerlyValidateDeclarations(true),
260273
cel.OptionalTypes())

0 commit comments

Comments
 (0)