|
@@ -10,12 +10,13 @@ a file which can be accessed as a list. This avoids long argument parsing.
|
|
|
|
|
|
|
|
load("@rules_cc//cc:defs.bzl", "cc_test")
|
|
load("@rules_cc//cc:defs.bzl", "cc_test")
|
|
|
load("//bazel/cc_toolchains:defs.bzl", "cc_env")
|
|
load("//bazel/cc_toolchains:defs.bzl", "cc_env")
|
|
|
-load("//bazel/manifest:defs.bzl", "manifest")
|
|
|
|
|
|
|
+load("//bazel/manifest:defs.bzl", "manifest", "manifest_as_cpp")
|
|
|
|
|
|
|
|
def file_test(
|
|
def file_test(
|
|
|
name,
|
|
name,
|
|
|
tests,
|
|
tests,
|
|
|
srcs = [],
|
|
srcs = [],
|
|
|
|
|
+ deps = [],
|
|
|
data = [],
|
|
data = [],
|
|
|
args = [],
|
|
args = [],
|
|
|
prebuilt_binary = None,
|
|
prebuilt_binary = None,
|
|
@@ -30,6 +31,7 @@ def file_test(
|
|
|
name: The base name of the tests.
|
|
name: The base name of the tests.
|
|
|
tests: The list of test files to use as data, typically a glob.
|
|
tests: The list of test files to use as data, typically a glob.
|
|
|
srcs: Passed to cc_test.
|
|
srcs: Passed to cc_test.
|
|
|
|
|
+ deps: Passed to cc_test.
|
|
|
data: Passed to cc_test.
|
|
data: Passed to cc_test.
|
|
|
args: Passed to cc_test.
|
|
args: Passed to cc_test.
|
|
|
prebuilt_binary: If set, specifies a prebuilt test binary to use instead
|
|
prebuilt_binary: If set, specifies a prebuilt test binary to use instead
|
|
@@ -38,34 +40,41 @@ def file_test(
|
|
|
"""
|
|
"""
|
|
|
|
|
|
|
|
# Ensure tests are always a filegroup for tests_as_input_file_rule.
|
|
# Ensure tests are always a filegroup for tests_as_input_file_rule.
|
|
|
- tests_file = "{0}.tests".format(name)
|
|
|
|
|
- manifest(
|
|
|
|
|
- name = tests_file,
|
|
|
|
|
- srcs = tests,
|
|
|
|
|
- testonly = 1,
|
|
|
|
|
- )
|
|
|
|
|
- data = [":" + tests_file] + tests + data
|
|
|
|
|
-
|
|
|
|
|
if prebuilt_binary:
|
|
if prebuilt_binary:
|
|
|
# TODO: The prebuilt_binary support is only used by explorer. We should
|
|
# TODO: The prebuilt_binary support is only used by explorer. We should
|
|
|
# remove this once explorer is removed, and think about better factoring
|
|
# remove this once explorer is removed, and think about better factoring
|
|
|
# approaches if we need it later for toolchain.
|
|
# approaches if we need it later for toolchain.
|
|
|
|
|
+ tests_file = "{0}.tests".format(name)
|
|
|
|
|
+ manifest(
|
|
|
|
|
+ name = tests_file,
|
|
|
|
|
+ srcs = tests,
|
|
|
|
|
+ testonly = 1,
|
|
|
|
|
+ )
|
|
|
args = ["--explorer_test_targets_file=$(rootpath :{0})".format(tests_file)] + args
|
|
args = ["--explorer_test_targets_file=$(rootpath :{0})".format(tests_file)] + args
|
|
|
|
|
+
|
|
|
native.sh_test(
|
|
native.sh_test(
|
|
|
name = name,
|
|
name = name,
|
|
|
srcs = srcs + [prebuilt_binary],
|
|
srcs = srcs + [prebuilt_binary],
|
|
|
- data = data,
|
|
|
|
|
|
|
+ deps = deps,
|
|
|
|
|
+ data = [":" + tests_file] + tests + data,
|
|
|
args = args,
|
|
args = args,
|
|
|
env = cc_env(),
|
|
env = cc_env(),
|
|
|
**kwargs
|
|
**kwargs
|
|
|
)
|
|
)
|
|
|
else:
|
|
else:
|
|
|
|
|
+ manifest_cpp = "{0}_autogen_manifest.cpp".format(name)
|
|
|
|
|
+ manifest_as_cpp(
|
|
|
|
|
+ name = manifest_cpp,
|
|
|
|
|
+ var_name = "CarbonFileTestManifest",
|
|
|
|
|
+ srcs = tests,
|
|
|
|
|
+ testonly = 1,
|
|
|
|
|
+ )
|
|
|
cc_test(
|
|
cc_test(
|
|
|
name = name,
|
|
name = name,
|
|
|
- srcs = srcs + ["//testing/file_test:file_test_manifest.cpp"],
|
|
|
|
|
- data = data,
|
|
|
|
|
|
|
+ srcs = srcs + [":" + manifest_cpp],
|
|
|
|
|
+ deps = deps + ["//testing/file_test:manifest_impl"],
|
|
|
|
|
+ data = tests + data,
|
|
|
args = args,
|
|
args = args,
|
|
|
env = cc_env(),
|
|
env = cc_env(),
|
|
|
- local_defines = ["CARBON_FILE_TEST_MANIFEST='\"$(rootpath :{0})\"'".format(tests_file)],
|
|
|
|
|
**kwargs
|
|
**kwargs
|
|
|
)
|
|
)
|