
FUNCTION( ADD_TEST_LABELS TEST_NAME TEST_LABELS )
  SET(SUCCESS FALSE)
  SET(TEST_LABELS_TEMP "")
  EXECUTE_PROCESS(COMMAND ${PROJECT_SOURCE_DIR}/tests/scripts/test_labels.py ${TEST_NAME} ${QMC_CUDA} ${QMC_COMPLEX} ${QMC_MIXED_PRECISION} OUTPUT_VARIABLE TEST_LABELS_TEMP RESULT_VARIABLE SUCCESS)
  #MESSAGE("  Label script return value: ${SUCCESS}")
  IF( NOT ${SUCCESS} STREQUAL "0" )
    MESSAGE("Warning: test labeling failed.  Test labeling error output:\n${TEST_LABELS_TEMP}")
    SET(TEST_LABELS_TEMP "")
  #ELSE()
  #  MESSAGE("  Test: ${TEST_NAME}")
  #  MESSAGE("    ${TEST_LABELS_TEMP}")
  ENDIF()
  # Remove unstable label from direct execution.
  # It will still be added to statistical child tests.
  SET(TEST_LABELS_LOCAL ${TEST_LABELS_TEMP})
  LIST(REMOVE_ITEM TEST_LABELS_LOCAL unstable)
  SET_PROPERTY(TEST ${TEST_NAME} APPEND PROPERTY LABELS ${TEST_LABELS_LOCAL})
  SET(${TEST_LABELS} ${TEST_LABELS_TEMP} PARENT_SCOPE)
ENDFUNCTION()
