2
0
Fork 0
mirror of https://github.com/bazelbuild/bazel-skylib synced 2024-11-28 08:43:51 +00:00
bazel-skylib/tests/native_binary/BUILD
László Csomor 58068fe0cc
Delete maprule. Fix Buildifier lint errors. (#192)
* Delete maprule. Fix Buildifier lint errors.

Delete maprule and its tests: I wrote this rule,
and I no longer plan to release it. Alternative
rules exist that serve users' needs better.

Fix also Buildifier lint errors that were making
BuildKite red: https://buildkite.com/bazel/bazel-skylib/builds/659#ab98ac31-6e1c-415e-b8a8-5f8868340c7d
2019-09-17 14:03:22 +02:00

104 lines
3.2 KiB
Python

load("//rules:copy_file.bzl", "copy_file")
load("//rules:native_binary.bzl", "native_binary", "native_test")
load("@rules_cc//cc:defs.bzl", "cc_binary")
package(
default_testonly = 1,
default_visibility = ["//visibility:private"],
)
cc_binary(
name = "assertarg",
srcs = ["assertarg.cc"],
)
cc_binary(
name = "assertdata",
srcs = ["assertdata.cc"],
deps = ["@bazel_tools//tools/cpp/runfiles"],
# Depends on the runfiles library but doesn't have data-dependencies, on
# purpose. We supplement the runfiles in the native_binary / native_test
# rule.
)
# A rule that copies "assertarg"'s output as an opaque executable, simulating a
# binary that's not built from source and needs to be wrapped in native_binary.
copy_file(
name = "copy_assertarg_exe",
src = ":assertarg",
# On Windows we need the ".exe" extension.
# On other platforms the extension doesn't matter.
# Therefore we can use ".exe" on every platform.
out = "assertarg_copy.exe",
is_executable = True,
)
# A rule that copies "assertdata"'s output as an opaque executable, simulating a
# binary that's not built from source and needs to be wrapped in native_binary.
copy_file(
name = "copy_assertdata_exe",
src = ":assertdata",
# On Windows we need the ".exe" extension.
# On other platforms the extension doesn't matter.
# Therefore we can use ".exe" on every platform.
out = "assertdata_copy.exe",
is_executable = True,
)
_ARGS = [
"'a b'",
"c\\ d",
"$(location testdata.txt) $$(location testdata.txt) $(location testdata.txt)",
"'$(location testdata.txt) $$(location testdata.txt) $(location testdata.txt)'",
"$$TEST_SRCDIR",
# TODO(laszlocsomor): uncomment this (and its counterpart in assertarg.cc)
# after https://github.com/bazelbuild/bazel/issues/6622 is resolved and the
# Bash-less test wrapper is the default on Windows.
# "$${TEST_SRCDIR}",
]
native_binary(
name = "args_bin",
src = ":copy_assertarg_exe",
# On Windows we need the ".exe" extension.
# On other platforms the extension doesn't matter.
# Therefore we can use ".exe" on every platform.
out = "args_bin.exe",
args = _ARGS,
# We only need the data-dependency for $(location) expansion.
data = ["testdata.txt"],
)
native_test(
name = "args_test",
src = ":copy_assertarg_exe",
# On Windows we need the ".exe" extension.
# On other platforms the extension doesn't matter.
# Therefore we can use ".exe" on every platform.
out = "args_test.exe",
args = _ARGS,
# We only need the data-dependency for $(location) expansion.
data = ["testdata.txt"],
)
native_binary(
name = "data_bin",
src = ":copy_assertdata_exe",
# On Windows we need the ".exe" extension.
# On other platforms the extension doesn't matter.
# Therefore we can use ".exe" on every platform.
out = "data_bin.exe",
data = ["testdata.txt"],
)
native_test(
name = "data_test",
src = ":copy_assertdata_exe",
# On Windows we need the ".exe" extension.
# On other platforms the extension doesn't matter.
# Therefore we can use ".exe" on every platform.
out = "data_test.exe",
data = ["testdata.txt"],
)