Reputation: 37131
I have a Bazel executable target (of type fsharp_binary
, but I don't think it should matter) that I can run using bazel run
.
bazel run //my_app.exe
I would like to use this executable as a test, so that when I call bazel test
it gets built and executed, and a non-zero exit code is considered a test failure.
bazel test //...
What I am looking for is something like this:
test_of_executable(
name = "my_test",
executable = "//my_app.exe",
success_codes = [ 0 ],
)
Then:
bazel test //:my_test
How can I achieve this in Bazel?
Upvotes: 0
Views: 1795
Reputation: 8170
Just wrap your app as a sh_test
. See for example https://github.com/bazelbuild/bazel/issues/1969.
What I use in my codebase is:
BUILD.bazel:
sh_test(
name = "test",
srcs = ["test.sh"],
data = [
"//:some_binary",
],
)
test.sh
some_project/some_subdir/some_binary
See here for an real example.
Upvotes: 2