| 1 |
# Copyright 2025 Google LLC |
| 2 |
# |
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
# you may not use this file except in compliance with the License. |
| 5 |
# You may obtain a copy of the License at |
| 6 |
# |
| 7 |
# https://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
# |
| 9 |
# Unless required by applicable law or agreed to in writing, software |
| 10 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
# See the License for the specific language governing permissions and |
| 13 |
# limitations under the License. |
| 14 |
|
| 15 |
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") |
| 16 |
load("//test:cel_go_test.bzl", "cel_go_test") |
| 17 |
|
| 18 |
package( |
| 19 |
default_visibility = ["//visibility:public"], |
| 20 |
licenses = ["notice"], |
| 21 |
) |
| 22 |
|
| 23 |
go_library( |
| 24 |
name = "go_default_library", |
| 25 |
srcs = [ |
| 26 |
"test_coverage_reporter.go", |
| 27 |
"test_runner.go", |
| 28 |
], |
| 29 |
importpath = "github.com/google/cel-go/tools/celtest", |
| 30 |
deps = [ |
| 31 |
"//cel:go_default_library", |
| 32 |
"//common/ast:go_default_library", |
| 33 |
"//common/operators:go_default_library", |
| 34 |
"//common/types:go_default_library", |
| 35 |
"//common/types/ref:go_default_library", |
| 36 |
"//interpreter:go_default_library", |
| 37 |
"//parser:go_default_library", |
| 38 |
"//test:go_default_library", |
| 39 |
"//tools/compiler:go_default_library", |
| 40 |
"@com_github_google_go_cmp//cmp:go_default_library", |
| 41 |
"@dev_cel_expr//:expr", |
| 42 |
"@dev_cel_expr//conformance/test:go_default_library", |
| 43 |
"@in_yaml_go_yaml_v3//:go_default_library", |
| 44 |
"@io_bazel_rules_go//go/runfiles", |
| 45 |
"@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library", |
| 46 |
"@org_golang_google_protobuf//encoding/prototext:go_default_library", |
| 47 |
"@org_golang_google_protobuf//proto:go_default_library", |
| 48 |
"@org_golang_google_protobuf//reflect/protodesc:go_default_library", |
| 49 |
"@org_golang_google_protobuf//reflect/protoreflect:go_default_library", |
| 50 |
"@org_golang_google_protobuf//reflect/protoregistry:go_default_library", |
| 51 |
"@org_golang_google_protobuf//testing/protocmp:go_default_library", |
| 52 |
"@org_golang_google_protobuf//types/descriptorpb:go_default_library", |
| 53 |
"@org_golang_google_protobuf//types/dynamicpb:go_default_library", |
| 54 |
], |
| 55 |
) |
| 56 |
|
| 57 |
go_test( |
| 58 |
name = "go_default_test", |
| 59 |
size = "small", |
| 60 |
srcs = [ |
| 61 |
"test_coverage_reporter_test.go", |
| 62 |
"test_runner_test.go", |
| 63 |
], |
| 64 |
data = [ |
| 65 |
":testdata", |
| 66 |
"//policy:testdata", |
| 67 |
], |
| 68 |
embed = [":go_default_library"], |
| 69 |
deps = [ |
| 70 |
"//cel:go_default_library", |
| 71 |
"//common/ast:go_default_library", |
| 72 |
"//common/decls:go_default_library", |
| 73 |
"//common/types:go_default_library", |
| 74 |
"//common/types/ref:go_default_library", |
| 75 |
"//policy:go_default_library", |
| 76 |
"//test:go_default_library", |
| 77 |
"//tools/compiler:go_default_library", |
| 78 |
"@dev_cel_expr//conformance/test:go_default_library", |
| 79 |
"@in_yaml_go_yaml_v3//:go_default_library", |
| 80 |
] |
| 81 |
) |
| 82 |
|
| 83 |
filegroup( |
| 84 |
name = "testdata", |
| 85 |
srcs = glob(["testdata/**"]), |
| 86 |
) |
| 87 |
|
| 88 |
# trigger cel_go_test with resource files located under test_data_path |
| 89 |
cel_go_test( |
| 90 |
name = "pb_policy", |
| 91 |
cel_expr = "testdata/pb/policy.yaml", |
| 92 |
config = "testdata/pb/config.yaml", |
| 93 |
enable_coverage = True, |
| 94 |
file_descriptor_set = "//policy:test_all_types_fds", |
| 95 |
test_data_path = "//policy", |
| 96 |
test_src = "//policy/test:cel_test_runner.go", |
| 97 |
test_suite = "testdata/pb/tests.yaml", |
| 98 |
) |