From 05e06a9712d700993a296265d9651ea15929c9ec Mon Sep 17 00:00:00 2001
From: Christopher Dykes <cdykes@fb.com>
Date: Mon, 17 Jul 2017 18:59:11 -0700
Subject: [PATCH] Add support for tagging a test as BROKEN in the CMake build

Summary: Also use it to disable function_test and indexed_mem_pool_test for now while the source of their breakage is being investigated.

Reviewed By: yfeldblum

Differential Revision: D5440415

fbshipit-source-id: 630c884ccd2db660bfc3e4529a2d35941d3bd0d3
---
 CMake/FollyFunctions.cmake | 5 ++++-
 CMakeLists.txt             | 7 +++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/CMake/FollyFunctions.cmake b/CMake/FollyFunctions.cmake
index 61992c621..ee538856b 100755
--- a/CMake/FollyFunctions.cmake
+++ b/CMake/FollyFunctions.cmake
@@ -205,7 +205,9 @@ function(folly_define_tests)
                     "x${ARGV${currentArg}}" STREQUAL "xDIRECTORY")
               break()
             elseif (argumentState EQUAL 0)
-              if ("x${ARGV${currentArg}}" STREQUAL "xHANGING")
+              if ("x${ARGV${currentArg}}" STREQUAL "xBROKEN")
+                set(test_${cur_test}_tag "BROKEN")
+              elseif ("x${ARGV${currentArg}}" STREQUAL "xHANGING")
                 set(test_${cur_test}_tag "HANGING")
               elseif ("x${ARGV${currentArg}}" STREQUAL "xSLOW")
                 set(test_${cur_test}_tag "SLOW")
@@ -246,6 +248,7 @@ function(folly_define_tests)
   set(cur_test 0)
   while (cur_test LESS test_count)
     if ("x${test_${cur_test}_tag}" STREQUAL "xNONE" OR
+        ("x${test_${cur_test}_tag}" STREQUAL "xBROKEN" AND BUILD_BROKEN_TESTS) OR
         ("x${test_${cur_test}_tag}" STREQUAL "xSLOW" AND BUILD_SLOW_TESTS) OR
         ("x${test_${cur_test}_tag}" STREQUAL "xHANGING" AND BUILD_HANGING_TESTS)
     )
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 940e79a7f..6f717039c 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -243,6 +243,7 @@ file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/folly-deps.cmake "\ninclude(folly-target
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/folly-deps.cmake DESTINATION share/folly RENAME folly-config.cmake)
 
 option(BUILD_TESTS "If enabled, compile the tests." OFF)
+option(BUILD_BROKEN_TESTS "If enabled, compile tests that are known to be broken." OFF)
 option(BUILD_HANGING_TESTS "If enabled, compile tests that are known to hang." OFF)
 option(BUILD_SLOW_TESTS "If enabled, compile tests that take a while to run in debug mode." OFF)
 if (BUILD_TESTS)
@@ -502,7 +503,8 @@ if (BUILD_TESTS)
       TEST format_other_test SOURCES FormatOtherTest.cpp
       TEST format_test SOURCES FormatTest.cpp
       TEST function_scheduler_test SOURCES FunctionSchedulerTest.cpp
-      TEST function_test SOURCES FunctionTest.cpp
+      TEST function_test BROKEN
+        SOURCES FunctionTest.cpp
       TEST function_ref_test SOURCES FunctionRefTest.cpp
       TEST futex_test SOURCES FutexTest.cpp
       TEST group_varint_test SOURCES GroupVarintTest.cpp
@@ -510,7 +512,8 @@ if (BUILD_TESTS)
       TEST has_member_fn_traits_test SOURCES HasMemberFnTraitsTest.cpp
       TEST hash_test SOURCES HashTest.cpp
       TEST indestructible_test SOURCES IndestructibleTest.cpp
-      TEST indexed_mem_pool_test SOURCES IndexedMemPoolTest.cpp
+      TEST indexed_mem_pool_test BROKEN
+        SOURCES IndexedMemPoolTest.cpp
       # MSVC Preprocessor stringizing raw string literals bug
       #TEST json_test SOURCES JsonTest.cpp
       TEST json_other_test
-- 
2.26.2