set(EXPECTED_PASSED 40)
set(OUTFILE "@CDash_BINARY_DIR@/tests/ctest/alltests.out")
file(DOWNLOAD "@CDASH_TESTING_URL@/tests/alltests.php"
  "@CDash_BINARY_DIR@/TestData/alltests.out")
file(READ "@CDash_BINARY_DIR@/TestData/alltests.out" OUTDATA)
string(REGEX REPLACE ".*strong>([0-9]+).*strong.*passes.*" "\\1"
  PASSED "${OUTDATA}")
if("${PASSED}" STREQUAL "")
  set(PASSED 0)
endif()
string(REGEX REPLACE ".*strong>([0-9]+).*strong.*fails.*" "\\1"
  FAILED "${OUTDATA}")
if("${FAILED}" STREQUAL "")
  set(FAILED 0)
endif()
string(REGEX REPLACE ".*strong>([0-9]+).*strong.*exceptions.*" "\\1"
  EXCEPTIONS "${OUTDATA}")
if("${EXCEPTIONS}" STREQUAL "")
  set(EXCEPTIONS 0)
endif()
message("Passed = ${PASSED}")
message("Failed = ${FAILED}")
message("Exception = ${EXCEPTIONS}")
if(${FAILED} GREATER 0  OR ${EXCEPTIONS} GREATER 0)
  message(FATAL_ERROR "Test failures found: ${OUTDATA}")
endif()
if(${PASSED} LESS ${EXPECTED_PASSED})
  message(FATAL_ERROR
    "Not enough passed tests found: ${PASSED},"
    " expected ${EXPECTED_PASSED}):\n"
    "Output from tests:\n${OUTDATA}")
endif()
message("All Tests Passed.")
