Debian Codegraph @

conformance/conformance_test.bzl

raw
1 # Copyright 2024 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 """
16 This module contains build rules for generating the conformance test targets.
17 """
18
19 # Converts the list of tests to skip from the format used by the original Go test runner to a single
20 # flag value where each test is separated by a comma. It also performs expansion, for example
21 # `foo/bar,baz` becomes two entries which are `foo/bar` and `foo/baz`.
22 def _expand_tests_to_skip(tests_to_skip):
23 result = []
24 for test_to_skip in tests_to_skip:
25 comma = test_to_skip.find(",")
26 if comma == -1:
27 result.append(test_to_skip)
28 continue
29 slash = test_to_skip.rfind("/", 0, comma)
30 if slash == -1:
31 slash = 0
32 else:
33 slash = slash + 1
34 for part in test_to_skip[slash:].split(","):
35 result.append(test_to_skip[0:slash] + part)
36 return result
37
38 def _conformance_test_args(data, skip_tests, dashboard):
39 args = []
40 args.append("--skip_tests={}".format(",".join(_expand_tests_to_skip(skip_tests))))
41 args.append("--tests={}".format(",".join(["$(location " + test + ")" for test in data])))
42 if dashboard:
43 args.append("--dashboard")
44 return args
45
46 def conformance_test(name, data, dashboard, skip_tests = []):
47 native.sh_test(
48 name = name,
49 size = "small",
50 srcs = ["//conformance:conformance_test.sh"],
51 args = ["$(location //conformance:go_default_test)"] + _conformance_test_args(data, skip_tests, dashboard),
52 data = ["//conformance:go_default_test"] + data,
53 tags = [
54 "guitar",
55 "manual",
56 "notap",
57 ] if dashboard else [],
58 )