diff --git a/BUILD.bazel b/BUILD.bazel index 3f38761d8d8..ff602ccb7f2 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1915,6 +1915,6 @@ test_suite( "api_tests", "jit_tests", "torch_dist_autograd_test", - "//c10:tests", + "//c10/test:tests", ], ) diff --git a/c10/BUILD.bazel b/c10/BUILD.bazel index 77f97d82da4..9ae01ae1716 100644 --- a/c10/BUILD.bazel +++ b/c10/BUILD.bazel @@ -1,5 +1,5 @@ load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") +load("@rules_cc//cc:defs.bzl", "cc_library") load("//tools/config:defs.bzl", "if_cuda") # The bool_flag targets allow configuring the build from the @@ -68,21 +68,3 @@ cc_library( alwayslink = True, visibility = ["//:__pkg__"], ) - -cc_test( - name = "tests", - size = "small", - srcs = glob([ - "test/util/*.cpp", - "test/util/*.h", - "test/core/*.cpp", - "test/core/impl/*.cpp", - ]), - copts = ["-Wno-deprecated-declarations"], - deps = [ - ":c10", - ":headers", - "@com_google_googletest//:gtest_main", - ], - visibility = ["//:__pkg__"], -) diff --git a/c10/test/BUILD.bazel b/c10/test/BUILD.bazel new file mode 100644 index 00000000000..d1a0db360d2 --- /dev/null +++ b/c10/test/BUILD.bazel @@ -0,0 +1,4 @@ +load("//:tools/bazel.bzl", "rules") +load(":build.bzl", "define_targets") + +define_targets(rules = rules) diff --git a/c10/test/build.bzl b/c10/test/build.bzl new file mode 100644 index 00000000000..0c6b2a5486f --- /dev/null +++ b/c10/test/build.bzl @@ -0,0 +1,50 @@ +def define_targets(rules): + rules.cc_test( + name = "tests", + size = "small", + srcs = rules.glob([ + "util/*.cpp", + "core/*.cpp", + "core/impl/*.cpp", + ]), + copts = ["-Wno-deprecated-declarations"], + deps = [ + ":Macros", + ":complex_math_test_common", + ":complex_test_common", + "@com_google_googletest//:gtest_main", + "//c10/core:base", + "//c10/macros", + "//c10/util:base", + "//c10/util:typeid", + ], + visibility = ["//:__pkg__"], + ) + + rules.cc_library( + name = "Macros", + hdrs = ["util/Macros.h"], + testonly = True, + visibility = ["//:__subpackages__"], + ) + + rules.cc_library( + name = "complex_math_test_common", + hdrs = ["util/complex_math_test_common.h"], + deps = [ + "@com_google_googletest//:gtest", + "//c10/util:base", + ], + testonly = True, + ) + + rules.cc_library( + name = "complex_test_common", + hdrs = ["util/complex_test_common.h"], + deps = [ + "@com_google_googletest//:gtest", + "//c10/macros", + "//c10/util:base", + ], + testonly = True, + ) diff --git a/tools/bazel.bzl b/tools/bazel.bzl index 04d690dbdf6..b932b812c32 100644 --- a/tools/bazel.bzl +++ b/tools/bazel.bzl @@ -1,4 +1,4 @@ -load("@rules_cc//cc:defs.bzl", "cc_library") +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load("@rules_cuda//cuda:defs.bzl", "requires_cuda_enabled") load("//c10/macros:cmake_configure_file.bzl", "cmake_configure_file") @@ -7,6 +7,7 @@ load("//c10/macros:cmake_configure_file.bzl", "cmake_configure_file") # the rules simply forward to the Bazel definitions. rules = struct( cc_library = cc_library, + cc_test = cc_test, cmake_configure_file = cmake_configure_file, filegroup = native.filegroup, glob = native.glob,