From 932cba0fb733c083e5785a3014fb2bb4351a0635 Mon Sep 17 00:00:00 2001 From: Andrew Gallagher Date: Fri, 31 Jul 2015 03:10:03 -0700 Subject: [PATCH] folly: fix tests running under buck (w/ clang and dynamic linking) Summary: Various fixes to get tests passing using buck's dev mode. Reviewed By: @yfeldblum Differential Revision: D2299981 --- .../symbolizer/test/SymbolizerTest.cpp | 22 ++++++++++++++----- .../test/NestedCommandLineAppTest.cpp | 6 ++++- .../experimental/test/ProgramOptionsTest.cpp | 6 ++++- folly/test/DynamicConverterTest.cpp | 2 +- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/folly/experimental/symbolizer/test/SymbolizerTest.cpp b/folly/experimental/symbolizer/test/SymbolizerTest.cpp index 088ae1e7..84be15b7 100644 --- a/folly/experimental/symbolizer/test/SymbolizerTest.cpp +++ b/folly/experimental/symbolizer/test/SymbolizerTest.cpp @@ -34,13 +34,23 @@ TEST(Symbolizer, Single) { ASSERT_TRUE(symbolizer.symbolize(reinterpret_cast(foo), a)); EXPECT_EQ("folly::symbolizer::test::foo()", a.demangledName()); - auto path = a.location.file.toString(); - folly::StringPiece basename(path); - auto pos = basename.rfind('/'); - if (pos != folly::StringPiece::npos) { - basename.advance(pos + 1); + // The version of clang we use doesn't generate a `.debug_aranges` section, + // which the symbolizer needs to lookup the filename. + constexpr bool built_with_clang = + #ifdef __clang__ + true; + #else + false; + #endif + if (!built_with_clang) { + auto path = a.location.file.toString(); + folly::StringPiece basename(path); + auto pos = basename.rfind('/'); + if (pos != folly::StringPiece::npos) { + basename.advance(pos + 1); + } + EXPECT_EQ("SymbolizerTest.cpp", basename.str()); } - EXPECT_EQ("SymbolizerTest.cpp", basename.str()); } FrameArray<100> goldenFrames; diff --git a/folly/experimental/test/NestedCommandLineAppTest.cpp b/folly/experimental/test/NestedCommandLineAppTest.cpp index cdfcd318..0e7a7f67 100644 --- a/folly/experimental/test/NestedCommandLineAppTest.cpp +++ b/folly/experimental/test/NestedCommandLineAppTest.cpp @@ -26,8 +26,12 @@ namespace folly { namespace test { namespace { std::string getHelperPath() { + const auto basename = "nested_command_line_app_test_helper"; auto path = fs::executable_path(); - path.remove_filename() /= "nested_command_line_app_test_helper"; + path.remove_filename() /= basename; + if (!fs::exists(path)) { + path = path.parent_path().parent_path() / basename / basename; + } return path.native(); } diff --git a/folly/experimental/test/ProgramOptionsTest.cpp b/folly/experimental/test/ProgramOptionsTest.cpp index 3a0f4ca1..ef2b13af 100644 --- a/folly/experimental/test/ProgramOptionsTest.cpp +++ b/folly/experimental/test/ProgramOptionsTest.cpp @@ -27,8 +27,12 @@ namespace folly { namespace test { namespace { std::string getHelperPath() { + const auto basename = "program_options_test_helper"; auto path = fs::executable_path(); - path.remove_filename() /= "program_options_test_helper"; + path.remove_filename() /= basename; + if (!fs::exists(path)) { + path = path.parent_path().parent_path() / basename / basename; + } return path.native(); } diff --git a/folly/test/DynamicConverterTest.cpp b/folly/test/DynamicConverterTest.cpp index 2e5003de..031f650e 100644 --- a/folly/test/DynamicConverterTest.cpp +++ b/folly/test/DynamicConverterTest.cpp @@ -243,7 +243,7 @@ TEST(DynamicConverter, crazy) { dynamic dv1 = {}, dv2 = { ds1, ds2 }, - dv3 = { ds3 }; + dv3({ ds3 }); dynamic dm1 = dynamic::object(true, dv1)(false, dv2), -- 2.34.1