move //c10:tests target to the shared //c10/test package (#70928)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/70928

ghstack-source-id: 148159366

Test Plan: Ensured that the same number of tests are found and run.

Reviewed By: malfet

Differential Revision: D33455272

fbshipit-source-id: fba1e3409b14794be3e6fe4445c56dd5361cfe9d
(cherry picked from commit b45fce500aa9c3f69915bf0857144ba6d268e649)
This commit is contained in:
mikey dagitses
2022-02-03 12:07:01 -08:00
committed by PyTorch MergeBot
parent c965b47995
commit 286f5a51f9
5 changed files with 58 additions and 21 deletions

View File

@ -1915,6 +1915,6 @@ test_suite(
"api_tests",
"jit_tests",
"torch_dist_autograd_test",
"//c10:tests",
"//c10/test:tests",
],
)

View File

@ -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__"],
)

4
c10/test/BUILD.bazel Normal file
View File

@ -0,0 +1,4 @@
load("//:tools/bazel.bzl", "rules")
load(":build.bzl", "define_targets")
define_targets(rules = rules)

50
c10/test/build.bzl Normal file
View File

@ -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,
)

View File

@ -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,