if(NOT DEFINED NWFLAIM_TEST_COMMAND)
    message(FATAL_ERROR "NWFLAIM_TEST_COMMAND is required")
endif()
if(NOT DEFINED NWFLAIM_TEST_EXPECT)
    set(NWFLAIM_TEST_EXPECT "Usage:")
endif()

set(ENV{TERM} xterm)
execute_process(
    COMMAND "${NWFLAIM_TEST_COMMAND}" -?
    RESULT_VARIABLE _result
    OUTPUT_VARIABLE _stdout
    ERROR_VARIABLE _stderr
    TIMEOUT 20)

set(_combined "${_stdout}\n${_stderr}")
if(NOT _combined MATCHES "${NWFLAIM_TEST_EXPECT}")
    message(STATUS "stdout:\n${_stdout}")
    message(STATUS "stderr:\n${_stderr}")
    message(FATAL_ERROR "${NWFLAIM_TEST_COMMAND} did not print expected usage text")
endif()
