1"""Starlark definitions for Protobuf conformance tests. 2 3PLEASE DO NOT DEPEND ON THE CONTENTS OF THIS FILE, IT IS UNSTABLE. 4""" 5 6load("@rules_shell//shell:sh_test.bzl", "sh_test") 7 8def conformance_test( 9 name, 10 testee, 11 failure_list = None, 12 text_format_failure_list = None, 13 maximum_edition = None, 14 **kwargs): 15 """Conformance test runner. 16 17 Args: 18 name: the name for the test. 19 testee: a conformance test client binary. 20 failure_list: a text file with known failures, one per line. 21 text_format_failure_list: a text file with known failures (one per line) 22 for the text format conformance suite. 23 **kwargs: common arguments to pass to sh_test. 24 """ 25 args = ["--testee %s" % _strip_bazel(testee)] 26 failure_lists = [] 27 if failure_list: 28 args = args + ["--failure_list %s" % _strip_bazel(failure_list)] 29 failure_lists = failure_lists + [failure_list] 30 if text_format_failure_list: 31 args = args + ["--text_format_failure_list %s" % _strip_bazel(text_format_failure_list)] 32 failure_lists = failure_lists + [text_format_failure_list] 33 if maximum_edition: 34 args = args + ["--maximum_edition %s" % maximum_edition] 35 36 sh_test( 37 name = name, 38 srcs = ["//conformance:bazel_conformance_test_runner.sh"], 39 data = [testee] + failure_lists + [ 40 "//conformance:conformance_test_runner", 41 ], 42 args = args, 43 deps = [ 44 "@bazel_tools//tools/bash/runfiles", 45 ], 46 tags = ["conformance"], 47 **kwargs 48 ) 49 50def _strip_bazel(testee): 51 if testee.startswith("//"): 52 testee = testee.replace("//", "com_google_protobuf/") 53 return testee.replace(":", "/") 54