Skip to content

Commit 13c244d

Browse files
CEL Dev Teamcopybara-github
authored andcommitted
Add support for textproto parser for testsuite.
PiperOrigin-RevId: 750196930
1 parent 5b4b234 commit 13c244d

File tree

6 files changed

+183
-14
lines changed

6 files changed

+183
-14
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# proto-file: google3/third_party/cel/spec/proto/cel/expr/conformance/test/suite.proto
2+
# proto-message: cel.expr.conformance.test.TestSuite
3+
4+
name: "context_msg_tests"
5+
description: "Protobuf input tests"
6+
sections {
7+
name: "valid"
8+
description: "Valid protobuf input tests"
9+
tests {
10+
name: "good spec"
11+
description: "Valid protobuf input tests"
12+
input_context {
13+
context_message {
14+
[type.googleapis.com/cel.expr.conformance.proto3.TestAllTypes] {
15+
single_int32: 10
16+
}
17+
}
18+
}
19+
output {
20+
result_expr: "optional.none()"
21+
}
22+
}
23+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# proto-file: google3/third_party/cel/spec/proto/cel/expr/conformance/test/suite.proto
2+
# proto-message: cel.expr.conformance.test.TestSuite
3+
4+
name: "context_pb_tests"
5+
description: "Protobuf input tests"
6+
sections {
7+
name: "valid"
8+
description: "Valid protobuf input tests"
9+
tests {
10+
name: "good spec"
11+
description: "Valid protobuf input tests"
12+
input_context {
13+
context_expr: "TestAllTypes{single_int32: 10}"
14+
}
15+
output {
16+
result_expr: "optional.none()"
17+
}
18+
}
19+
}
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
# proto-file: google3/google/api/expr/conformance/test_suite.proto
2-
# proto-message: google.api.expr.conformance.TestSuite
1+
# proto-file: google3/third_party/cel/spec/proto/cel/expr/conformance/test/suite.proto
2+
# proto-message: cel.expr.conformance.test.TestSuite
33

4+
name: "expr_value_output_tests"
45
description: "Value as expected output"
5-
66
sections {
77
name: "basic value"
8+
description: "Basic value"
89
tests {
910
name: "basic value test"
10-
value {
11-
bool_value: true
11+
description: "Basic value test"
12+
output {
13+
result_value {
14+
bool_value: true
15+
}
1216
}
1317
}
1418
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# proto-file: google3/third_party/cel/spec/proto/cel/expr/conformance/test/suite.proto
2+
# proto-message: cel.expr.conformance.test.TestSuite
3+
4+
name: "late_function_binding_tests"
5+
description: "Tests for late function binding."
6+
sections: {
7+
name: "late_function_binding_tests_section"
8+
description: "Tests for late function binding."
9+
tests: {
10+
name: "true_by_default"
11+
description: "Test that the default value of a late function binding is true."
12+
input: {
13+
key: "a"
14+
value: {
15+
expr: "'foo'"
16+
}
17+
}
18+
output: {
19+
result_value: {
20+
bool_value: true
21+
}
22+
}
23+
}
24+
tests: {
25+
name: "false_by_default"
26+
description: "Test that the default value of a late function binding is false."
27+
input: {
28+
key: "a"
29+
value: {
30+
value: {
31+
string_value: "baz"
32+
}
33+
}
34+
}
35+
output {
36+
result_value {
37+
bool_value: false
38+
}
39+
}
40+
}
41+
}
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
# proto-file: google3/google/api/expr/conformance/test_suite.proto
2-
# proto-message: google.api.expr.conformance.TestSuite
3-
1+
# proto-file: google3/third_party/cel/spec/proto/cel/expr/conformance/test/suite.proto
2+
# proto-message: cel.expr.conformance.test.TestSuite
43
# This testcase is used to test the eval error output in the test runner which
54
# fails because the function is declared in the compiler but not in the runtime.
65

6+
name: "eval_error_tests"
77
description: "Nested rule conformance tests with eval errors"
8-
98
sections {
109
name: "permitted"
10+
description: "Permitted nested rule"
1111
tests {
1212
name: "valid_origin"
13+
description: "Valid origin"
1314
input {
1415
key: "resource"
1516
value {
16-
expr_value {
17+
value {
1718
object_value {
1819
[type.googleapis.com/google.protobuf.Struct] {
1920
fields {
@@ -25,10 +26,12 @@ sections {
2526
}
2627
}
2728
}
28-
eval_error {
29-
errors {
30-
message: "evaluation error: No matching overload for function 'foo'. Overload candidates: foo_id"
29+
output {
30+
eval_error {
31+
errors {
32+
message: "evaluation error: No matching overload for function 'foo'. Overload candidates: foo_id"
33+
}
3134
}
3235
}
3336
}
34-
}
37+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# proto-file: google3/third_party/cel/spec/proto/cel/expr/conformance/test/suite.proto
2+
# proto-message: cel.expr.conformance.test.TestSuite
3+
4+
name: "nested_rule"
5+
description: "Nested rule conformance tests"
6+
sections {
7+
name: "valid"
8+
description: "Valid nested rule"
9+
tests {
10+
name: "restricted_origin"
11+
description: "Restricted origin"
12+
input {
13+
key: "resource"
14+
value {
15+
value {
16+
object_value {
17+
[type.googleapis.com/google.protobuf.Struct] {
18+
fields {
19+
key: "origin"
20+
value { string_value: "ir" }
21+
}
22+
}
23+
}
24+
}
25+
}
26+
}
27+
output {
28+
result_expr: "{'banned': true}"
29+
}
30+
}
31+
tests {
32+
name: "by_default"
33+
description: "By default"
34+
input {
35+
key: "resource"
36+
value {
37+
value {
38+
object_value {
39+
[type.googleapis.com/google.protobuf.Struct] {
40+
fields {
41+
key: "origin"
42+
value { string_value: "'de'" }
43+
}
44+
}
45+
}
46+
}
47+
}
48+
}
49+
output {
50+
result_expr: "{'banned': true}"
51+
}
52+
}
53+
}
54+
55+
sections {
56+
name: "permitted"
57+
description: "Permitted nested rule"
58+
tests {
59+
name: "valid_origin"
60+
input {
61+
key: "resource"
62+
value {
63+
value {
64+
object_value {
65+
[type.googleapis.com/google.protobuf.Struct] {
66+
fields {
67+
key: "origin"
68+
value { string_value: "uk" }
69+
}
70+
}
71+
}
72+
}
73+
}
74+
}
75+
output {
76+
result_expr: "{'banned': false}"
77+
}
78+
}
79+
}

0 commit comments

Comments
 (0)