0

I want to test cc_binay in bazel with py_test rule, how can I access the cc_binary in python file? My bazel BUILD file is:

py_test(
    name = 'simple_test',
    size = 'small',
    srcs = ['simple_test.py'],
    data = [':simple'],    # the tested cc_binary
)

Can anybody give me a example? Thank you!

anthony sottile
  • 61,815
  • 15
  • 148
  • 207

1 Answers1

0

cc_binary can be added as data dependency as below.

cc_binary(
    name = "my-bin",
    srcs = ["bin.cc"],
)

py_test(
    name = "my-test",
    srcs = ["my_test.py"],
    data = [":my-bin"],
    # any other attributes you need...
)
SG_Bazel
  • 343
  • 2
  • 7