diff --git a/cmake/AddFdbTest.cmake b/cmake/AddFdbTest.cmake index 8a5068f21d..f5dbe64388 100644 --- a/cmake/AddFdbTest.cmake +++ b/cmake/AddFdbTest.cmake @@ -84,12 +84,19 @@ function(add_fdb_test) if (NOT "${ADD_FDB_TEST_TEST_NAME}" STREQUAL "") set(test_name ${ADD_FDB_TEST_TEST_NAME}) endif() + math(EXPR test_idx "${CURRENT_TEST_INDEX} + 1") + set(CURRENT_TEST_INDEX "${test_idx}" PARENT_SCOPE) + # set( PARENT_SCOPE) doesn't set the + # value in this scope (only in the parent scope). So + # if the value was undefined before, it will still be + # undefined. + math(EXPR assigned_id "${test_idx} - 1") if(ADD_FDB_TEST_UNIT) message(STATUS - "ADDING UNIT TEST ${test_name}") + "ADDING UNIT TEST ${assigned_id} ${test_name}") else() message(STATUS - "ADDING SIMULATOR TEST ${test_name}") + "ADDING SIMULATOR TEST ${assigned_id} ${test_name}") endif() set(test_files "") foreach(curr_test_file ${ADD_FDB_TEST_TEST_FILES}) @@ -99,9 +106,6 @@ function(add_fdb_test) if (ENABLE_BUGGIFY) set(BUGGIFY_OPTION "-B") endif() - math(EXPR test_idx "${CURRENT_TEST_INDEX} + 1") - set(CURRENT_TEST_INDEX "${test_idx}" CACHE INTERNAL "The index used for the last added test" FORCE) - message("Added ${test_name} with idx ${CURRENT_TEST_INDEX}") list(TRANSFORM ADD_FDB_TEST_TEST_FILES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/") add_test(NAME ${test_name} COMMAND $ ${TestRunner}