提交 0fdd019f 编辑于 作者: sdong's avatar sdong 提交者: Andrew Kryczka
浏览文件

Fix test in buck test (#7076)

Summary:
This is to fix special logic to run tests inside FB.
Buck test is broken after moving to cpp_unittest(). Move c_test back to the previous approach.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/7076

Test Plan: Watch the Sandcastle run

Reviewed By: ajkr

Differential Revision: D22370096

fbshipit-source-id: 4a464d0903f2c76ae2de3a8ad373ffc9bedec64c
上级 43107e0a
...@@ -447,6 +447,25 @@ cpp_library( ...@@ -447,6 +447,25 @@ cpp_library(
external_deps = ROCKSDB_EXTERNAL_DEPS, external_deps = ROCKSDB_EXTERNAL_DEPS,
) )
cpp_binary(
name = "c_test_bin",
srcs = ["db/c_test.c"],
arch_preprocessor_flags = ROCKSDB_ARCH_PREPROCESSOR_FLAGS,
os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS,
compiler_flags = ROCKSDB_COMPILER_FLAGS,
preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS,
deps = [":rocksdb_test_lib"],
)
custom_unittest(
"c_test",
command = [
native.package_name() + "/buckifier/rocks_test_runner.sh",
"$(location :{})".format("c_test_bin"),
],
type = "simple",
)
cpp_library( cpp_library(
name = "env_basic_test_lib", name = "env_basic_test_lib",
srcs = ["env/env_basic_test.cc"], srcs = ["env/env_basic_test.cc"],
...@@ -560,13 +579,6 @@ ROCKS_TESTS = [ ...@@ -560,13 +579,6 @@ ROCKS_TESTS = [
[], [],
[], [],
], ],
[
"c_test",
"db/c_test.c",
"serial",
[],
[],
],
[ [
"cache_simulator_test", "cache_simulator_test",
"utilities/simulator_cache/cache_simulator_test.cc", "utilities/simulator_cache/cache_simulator_test.cc",
......
...@@ -64,8 +64,6 @@ def get_cc_files(repo_path): ...@@ -64,8 +64,6 @@ def get_cc_files(repo_path):
continue continue
for filename in fnmatch.filter(filenames, '*.cc'): for filename in fnmatch.filter(filenames, '*.cc'):
cc_files.append(os.path.join(root, filename)) cc_files.append(os.path.join(root, filename))
for filename in fnmatch.filter(filenames, '*.c'):
cc_files.append(os.path.join(root, filename))
return cc_files return cc_files
...@@ -178,10 +176,18 @@ def generate_targets(repo_path, deps_map): ...@@ -178,10 +176,18 @@ def generate_targets(repo_path, deps_map):
+ ["test_util/testutil.cc"]) + ["test_util/testutil.cc"])
print("Extra dependencies:\n{0}".format(json.dumps(deps_map))) print("Extra dependencies:\n{0}".format(json.dumps(deps_map)))
# test for every test we found in the Makefile
# c_test.c is added through TARGETS.add_c_test(). If there
# are more than one .c test file, we need to extend
# TARGETS.add_c_test() to include other C tests too.
TARGETS.add_c_test()
# test for every .cc test we found in the Makefile
for target_alias, deps in deps_map.items(): for target_alias, deps in deps_map.items():
for test in sorted(tests): for test in sorted(tests):
match_src = [src for src in cc_files if ("/%s.c" % test) in src] if test == 'c_test':
continue
match_src = [src for src in cc_files if ("/%s.cc" % test) in src]
if len(match_src) == 0: if len(match_src) == 0:
print(ColorString.warning("Cannot find .cc file for %s" % test)) print(ColorString.warning("Cannot find .cc file for %s" % test))
continue continue
......
...@@ -76,6 +76,28 @@ class TARGETSBuilder(object): ...@@ -76,6 +76,28 @@ class TARGETSBuilder(object):
pretty_list(deps))) pretty_list(deps)))
self.total_bin = self.total_bin + 1 self.total_bin = self.total_bin + 1
def add_c_test(self):
self.targets_file.write("""
cpp_binary(
name = "c_test_bin",
srcs = ["db/c_test.c"],
arch_preprocessor_flags = ROCKSDB_ARCH_PREPROCESSOR_FLAGS,
os_preprocessor_flags = ROCKSDB_OS_PREPROCESSOR_FLAGS,
compiler_flags = ROCKSDB_COMPILER_FLAGS,
preprocessor_flags = ROCKSDB_PREPROCESSOR_FLAGS,
deps = [":rocksdb_test_lib"],
)
custom_unittest(
"c_test",
command = [
native.package_name() + "/buckifier/rocks_test_runner.sh",
"$(location :{})".format("c_test_bin"),
],
type = "simple",
)
""")
def register_test(self, def register_test(self,
test_name, test_name,
src, src,
......
支持 Markdown
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册