Skip to content

Commit

Permalink
Minor cleanup of conformance_test.go (#1015)
Browse files Browse the repository at this point in the history
Also enabled a couple of additional conformance tests.
  • Loading branch information
TristonianJones authored Sep 3, 2024
1 parent fb25c0b commit b359980
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
6 changes: 6 additions & 0 deletions conformance/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ package(

_ALL_TESTS = [
"@com_google_cel_spec//tests/simple:testdata/basic.textproto",
"@com_google_cel_spec//tests/simple:testdata/bindings_ext.textproto",
"@com_google_cel_spec//tests/simple:testdata/comparisons.textproto",
"@com_google_cel_spec//tests/simple:testdata/conversions.textproto",
"@com_google_cel_spec//tests/simple:testdata/dynamic.textproto",
"@com_google_cel_spec//tests/simple:testdata/encoders_ext.textproto",
"@com_google_cel_spec//tests/simple:testdata/enums.textproto",
"@com_google_cel_spec//tests/simple:testdata/fields.textproto",
"@com_google_cel_spec//tests/simple:testdata/fp_math.textproto",
Expand All @@ -23,6 +25,7 @@ _ALL_TESTS = [
"@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/proto2_ext.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",
Expand All @@ -44,6 +47,9 @@ _TESTS_TO_SKIP = [
"macros/map/map_extract_keys",
"timestamps/duration_converters/get_milliseconds",

# Failing conformance test for unknown reasons
"encoders_ext/decode/hello_without_padding",

# Future enhancments.
"enums/strong_proto2",
"enums/strong_proto3",
Expand Down
27 changes: 17 additions & 10 deletions conformance/conformance_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package conformance
package conformance_test

import (
"errors"
Expand All @@ -9,8 +9,6 @@ import (
"strings"
"testing"

"cel.dev/expr/proto/test/v1/testpb"

"github.com/bazelbuild/rules_go/go/runfiles"

"github.com/google/cel-go/cel"
Expand All @@ -25,6 +23,7 @@ import (

test2pb "cel.dev/expr/proto/test/v1/proto2/test_all_types"
test3pb "cel.dev/expr/proto/test/v1/proto3/test_all_types"
testpb "cel.dev/expr/proto/test/v1/testpb"

exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
)
Expand Down Expand Up @@ -79,18 +78,26 @@ func init() {
flag.Var(&tests, "tests", "Paths to run, separate by a comma.")
flag.Var(&skipTests, "skip_tests", "Tests to skip, separate by a comma.")

var err error
envWithMacros, err = cel.NewCustomEnv(cel.StdLib(), cel.OptionalTypes(),
stdOpts := []cel.EnvOption{
cel.StdLib(),
cel.ClearMacros(),
cel.OptionalTypes(),
cel.EagerlyValidateDeclarations(true),
cel.EnableErrorOnBadPresenceTest(true),
cel.Types(&test2pb.TestAllTypes{}, &test3pb.TestAllTypes{}), cel.Macros(cel.StandardMacros...), ext.Bindings(), ext.Encoders(), ext.Math(), ext.Protos(), ext.Strings())
cel.Types(&test2pb.TestAllTypes{}, &test2pb.Proto2ExtensionScopedMessage{}, &test3pb.TestAllTypes{}),
ext.Bindings(),
ext.Encoders(),
ext.Math(),
ext.Protos(),
ext.Strings(),
}

var err error
envNoMacros, err = cel.NewCustomEnv(stdOpts...)
if err != nil {
log.Fatalf("cel.NewCustomEnv() = %v", err)
}
envNoMacros, err = cel.NewCustomEnv(cel.StdLib(), cel.OptionalTypes(),
cel.EagerlyValidateDeclarations(true),
cel.EnableErrorOnBadPresenceTest(true),
cel.Types(&test2pb.TestAllTypes{}, &test3pb.TestAllTypes{}), ext.Bindings(), ext.Encoders(), ext.Math(), ext.Protos(), ext.Strings(), cel.ClearMacros())
envWithMacros, err = envNoMacros.Extend(cel.Macros(cel.StandardMacros...))
if err != nil {
log.Fatalf("cel.NewCustomEnv() = %v", err)
}
Expand Down

0 comments on commit b359980

Please sign in to comment.