Skip to content

Commit

Permalink
Link folly test main() for OSS buck2 tests
Browse files Browse the repository at this point in the history
Summary:
This will properly set up folly init, which is necessary for most
tests that use folly. Since most OSS projects depend on folly, this is a
requirement for running buck2 tests for most OSS projects.

Reviewed By: bigfootjon

Differential Revision: D63441077

fbshipit-source-id: 495717c9dcb47c8f5c32126d73fb29be0c20814e
  • Loading branch information
Cullen Walsh authored and facebook-github-bot committed Sep 27, 2024
1 parent 21fad3f commit 20f328b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions shim/shims.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ _HEADER_SUFFIXES = (
"-defs.tcc",
)

CPP_UNITTEST_MAIN_DEP = "shim//third-party/googletest:cpp_unittest_main"
CPP_UNITTEST_LIB_DEPS = [
"shim//third-party/googletest:gtest",
"shim//third-party/googletest:gmock",
CPP_UNITTEST_DEPS = [
"shim//third-party/googletest:cpp_unittest_main",
]
CPP_FOLLY_UNITTEST_DEPS = [
"folly//folly/test/common:test_main_lib",
"folly//folly/ext/buck2:test_ext",
]

def _get_headers_from_sources(srcs):
Expand Down Expand Up @@ -208,7 +210,11 @@ def cpp_unittest(
resources = {},
**kwargs):
_unused = (supports_static_listing, allocator, owner, tags, emails, extract_helper_lib, compiler_specific_flags, default_strip_mode) # @unused
deps = deps + [CPP_UNITTEST_MAIN_DEP] + CPP_UNITTEST_LIB_DEPS
if read_config("oss", "folly_cxx_tests", True):
deps = deps + CPP_FOLLY_UNITTEST_DEPS
else:
deps = deps + CPP_UNITTEST_DEPS

prelude.cxx_test(
deps = _fix_deps(deps + external_deps_to_targets(external_deps)),
visibility = visibility,
Expand Down

0 comments on commit 20f328b

Please sign in to comment.