SET(TEST_REFERENCE ${TEST_REFERENCE_DIR}/${TEST_RESULT})
SET(FILES_TO_CLEANUP ${TEST_OUTPUT})
IF (WIN32)
    SET(TEST_OUTPUT_CORRECTED ${TEST_OUTPUT}-win)
    CONFIGURE_FILE(${TEST_OUTPUT} ${TEST_OUTPUT_CORRECTED} NEWLINE_STYLE LF)
    SET(TEST_OUTPUT ${TEST_OUTPUT_CORRECTED})
    SET(FILES_TO_CLEANUP ${FILES_TO_CLEANUP} ${TEST_OUTPUT})
ENDIF()

MESSAGE("${CMAKE_COMMAND} -E compare_files ${TEST_OUTPUT} ${TEST_REFERENCE}")

EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E compare_files ${TEST_OUTPUT} ${TEST_REFERENCE}
                RESULT_VARIABLE OUTPUT_COMPARE)

IF (${OUTPUT_COMPARE} STREQUAL "0")
    MESSAGE("Success")
    EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E remove ${FILES_TO_CLEANUP})
    RETURN()
ENDIF()

MESSAGE("FAILURE")
