I mainly concerned the difference of tf_cc_test and cc_test here.(I'm the new player of bazel due to tensorflow)
I use the following command:
bazel build -c dbg //tensorflow/core:lib_random_weighted_picker_test
to build lib_random_weighted_picker_test, all thing goes well.
while I use
bazel build -c dbg //tensorflow/core:higher_level_tests
to get the test instance about graph_partition_test which is in the tensorflow/core/graph/graph_partition_test.cc, it reported the following error:
ERROR: no such target '//tensorflow/core:higher_level_tests': target 'higher_level_tests' not declared in package 'tensorflow/core' defined by /home/pzz/workspace/tensorflow/tensorflow/core/BUILD. INFO: Elapsed time: 0.151s
And finally I found that I can use bazel build -c dbg //tensorflow/core:graph_graph_partition_test to get the test instance under the graph_partition_test.cc. and all the tests in the higher_level_test can get from the above way.
The higher_level_test is come from the tensorflow/core/BUILD#1705,
1704 tf_cc_tests(
1705 name = "higher_level_tests",
1706 size = "small",
1707 srcs = [
1708 "common_runtime/device_set_test.cc",
1709 "common_runtime/optimization_registry_test.cc",
1710 "common_runtime/pending_counts_test.cc",
1711 "common_runtime/session_test.cc",
1712 "common_runtime/simple_placer_test.cc",
1713 "example/feature_util_test.cc",
1714 "framework/allocator_test.cc",
1715 "framework/attr_value_util_test.cc",
1716 "framework/bfloat16_test.cc",
1717 "framework/cancellation_test.cc",
1718 "framework/common_shape_fns_test.cc",
1719 "framework/function_test.cc",
1720 "framework/graph_def_util_test.cc",
1721 "framework/kernel_def_builder_test.cc",
1722 "framework/memory_types_test.cc",
1723 "framework/node_def_builder_test.cc",
1724 "framework/node_def_util_test.cc",
1725 "framework/op_compatibility_test.cc",
Question: But I still cannot make sense the difference about tf_cc_test and cc_test in the BUILD !! If I want to write some test, which way should I take in the BUILD file?
Any advice will be good, thanks.
tf_cc_test
is a macro that is just a wrapper for cc_test
, as Zhenzhong Pan points out.
Concrete location: https://github.com/tensorflow/tensorflow/blob/r1.0/tensorflow/tensorflow.bzl#L321-L332
You can read about build rule macros here: https://bazel.build/versions/master/docs/skylark/macros.html