simpletest_discover_impl.cmake 884 B

1234567891011121314151617181920212223242526272829303132
  1. if(NOT DEFINED TEST_EXE OR NOT DEFINED OUT_FILE)
  2. # noqa: spellcheck off
  3. message(FATAL_ERROR "simpletest_discover: need -DTEST_EXE and -DOUT_FILE")
  4. # noqa: spellcheck on
  5. endif()
  6. execute_process(
  7. COMMAND ${TEST_EXE} --list
  8. RESULT_VARIABLE _rc
  9. OUTPUT_VARIABLE _out
  10. ERROR_VARIABLE _err
  11. OUTPUT_STRIP_TRAILING_WHITESPACE
  12. )
  13. if(NOT _rc EQUAL 0)
  14. file(WRITE ${OUT_FILE} "# simpletest: --list failed (rc=${_rc})\n")
  15. message(FATAL_ERROR "simpletest_discover: '${TEST_EXE} --list' failed (${_rc})\n${_err}")
  16. endif()
  17. if(_out STREQUAL "")
  18. file(WRITE ${OUT_FILE} "# simpletest: no tests\n")
  19. return()
  20. endif()
  21. string(REPLACE "," ";" _names "${_out}")
  22. file(WRITE ${OUT_FILE} "# Auto-generated by simpletest_discover_impl.cmake\n")
  23. foreach(_name IN LISTS _names)
  24. file(APPEND ${OUT_FILE}
  25. "add_test([=[${_name}]=] \"${TEST_EXE}\" \"--test\" \"${_name}\")\n"
  26. )
  27. endforeach()