Browse Source

Fix testing for cmake >=3.18

They're changed names parsing, so this fix is necessary
See cmake#20965 for details.
Alexey N. Vinogradov 5 years ago
parent
commit
3f1358cc1f
4 changed files with 41 additions and 16 deletions
  1. 9 6
      api/libsphinxclient/CMakeLists.txt
  2. 14 0
      cmake/fixup_test_name.cmake
  3. 6 2
      src/CMakeLists.txt
  4. 12 8
      test/CMakeLists.txt

+ 9 - 6
api/libsphinxclient/CMakeLists.txt

@@ -29,20 +29,23 @@ if ( NOT DISABLE_TESTING AND NOT DISABLE_GTESTS AND NOT WIN32 )
 	configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/smoke_data.csv ${CMAKE_CURRENT_BINARY_DIR}/smoke_data.csv COPYONLY )
 	configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/smoke_test.conf ${CMAKE_CURRENT_BINARY_DIR}/smoke_test.conf COPYONLY )
 
-	set ( test "\"Prepare API test\"" )
-	add_test ( NAME "${test}" COMMAND indexer -c smoke_test.conf --all
+	# since cmake 3.18 names need fixup
+	include(fixup_test_name)
+
+	fixup_test_name ( test "Prepare API test" )
+	add_test ( NAME ${test} COMMAND indexer -c smoke_test.conf --all
 			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
-	SET_TESTS_PROPERTIES ( "${test}" PROPERTIES LABELS "API"
+	SET_TESTS_PROPERTIES ( ${test} PROPERTIES LABELS "API"
 			FIXTURES_SETUP APIINDEX  )
 
-	set ( test "\"Perform API smoke test\"" )
-	add_test ( NAME "${test}" COMMAND ${CMAKE_COMMAND}
+	fixup_test_name ( test "Perform API smoke test" )
+	add_test ( NAME ${test} COMMAND ${CMAKE_COMMAND}
 			-D SEARCHD=$<TARGET_FILE:searchd>
 			-D CLI=$<TARGET_FILE:testcli>
 			-D SRCDIR=${CMAKE_CURRENT_SOURCE_DIR}
 			-P ${CMAKE_CURRENT_SOURCE_DIR}/smoke.cmake
 			WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
-	SET_TESTS_PROPERTIES ( "${test}" PROPERTIES LABELS "API"
+	SET_TESTS_PROPERTIES ( ${test} PROPERTIES LABELS "API"
 			FIXTURES_REQUIRED APIINDEX )
 
 endif()

+ 14 - 0
cmake/fixup_test_name.cmake

@@ -0,0 +1,14 @@
+if (__fixup_test_name)
+	return()
+endif ()
+set(__fixup_test_name YES)
+
+# Work around CMake 3.18.0 change in `add_test()`, before the escaped quotes were neccessary,
+# beginning with CMake 3.18.0 the escaped double quotes confuse the call
+function(fixup_test_name outvar test)
+	if (${CMAKE_VERSION} VERSION_LESS "3.18")
+		set("${outvar}" "\"${test}\"" PARENT_SCOPE)
+	else ()
+		set("${outvar}" "${test}" PARENT_SCOPE)
+	endif ()
+endfunction()

+ 6 - 2
src/CMakeLists.txt

@@ -338,9 +338,11 @@ if ( NOT DISABLE_TESTING )
 
 	# first check syntax
 	if (NOT WIN32 )
+	# since cmake 3.18 names need fixup
+	include(fixup_test_name)
 	find_package ( PythonInterp QUIET )
 	if ( PYTHONINTERP_FOUND AND NOT DISABLE_GTESTS )
-		set ( RESERVED_TEST "\"SphinxQL reserved keywords consistency\"" )
+		fixup_test_name ( RESERVED_TEST "SphinxQL reserved keywords consistency" )
 		message ( STATUS "python binary is ${PYTHON_EXECUTABLE}" ) # !COMMIT
 		add_test ( NAME ${RESERVED_TEST}
 				WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
@@ -348,7 +350,9 @@ if ( NOT DISABLE_TESTING )
 		SET_TESTS_PROPERTIES ( ${RESERVED_TEST} PROPERTIES LABELS LINTER )
 	endif()
 	endif()
-	add_test ( NAME "\"Internal src/tests\""
+
+	fixup_test_name (tst "Internal src/tests")
+	add_test ( NAME ${tst}
 			#    	CONFIGURATIONS Debug
 			WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
 			COMMAND "tests" )

+ 12 - 8
test/CMakeLists.txt

@@ -40,19 +40,23 @@ if ( NOT "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
 	configure_file ( "ubertest.php.in" "${MANTICORE_BINARY_DIR}/test/ubertest.php" @ONLY )
 endif()
 	
-	
 if ( NOT SEARCHD_CLI_EXTRA )
 	set ( SEARCHD_CLI_EXTRA "" )
 endif()
 
-add_test ( NAME "\"Cleaning guess cache\""
+# since cmake 3.18 names need fixup
+include(fixup_test_name)
+
+fixup_test_name(tst "Cleaning guess cache")
+add_test ( NAME ${tst}
 		#    	CONFIGURATIONS Debug
 		COMMAND ${CMAKE_COMMAND} -E remove guess.txt )
-SET_TESTS_PROPERTIES ( "\"Cleaning guess cache\"" PROPERTIES FIXTURES_SETUP UBER )
-	
-add_test ( NAME "\"Cleaning errors\""
+SET_TESTS_PROPERTIES (${tst} PROPERTIES FIXTURES_SETUP UBER )
+
+fixup_test_name(tst "Cleaning errors")
+add_test ( NAME ${tst}
 		COMMAND ${CMAKE_COMMAND} -E remove error_all.txt )
-SET_TESTS_PROPERTIES ( "\"Cleaning errors\"" PROPERTIES FIXTURES_SETUP UBER )
+SET_TESTS_PROPERTIES ( ${tst} PROPERTIES FIXTURES_SETUP UBER )
 
 foreach ( test ${tests} )
 	# get the last dir (filename)
@@ -141,7 +145,7 @@ foreach ( test ${tests} )
 	if ( ADD_TEST )
 		# conditionally add plain test
 		if ( NOT "FORCE-RT" IN_LIST REQUIRES )
-			set (tstn "\"test_${tst_name}\"")
+			fixup_test_name (tstn "test_${tst_name}")
 			add_test ( NAME "${tstn}"
 					#    	CONFIGURATIONS Debug
 					WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
@@ -166,7 +170,7 @@ foreach ( test ${tests} )
 
 		# conditionally add rt test
 		if ( NOT "NON-RT" IN_LIST REQUIRES )
-			set ( tstn "\"rt_${tst_name}\"" )
+			fixup_test_name(tstn "rt_${tst_name}")
 			add_test ( NAME "${tstn}"
 					#			CONFIGURATIONS "Debug"
 					WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"