if(NOT DEFINED PANO_CLI)
    message(FATAL_ERROR "PANO_CLI is required")
endif()

if(NOT DEFINED OPEN_PATH)
    message(FATAL_ERROR "OPEN_PATH is required")
endif()

if(NOT DEFINED EXPECTED_OUTPUT)
    message(FATAL_ERROR "EXPECTED_OUTPUT is required")
endif()

execute_process(
    COMMAND "${PANO_CLI}" classify-open --path "${OPEN_PATH}"
    RESULT_VARIABLE result
    OUTPUT_VARIABLE output
    ERROR_VARIABLE error)

if(result EQUAL 0)
    message(FATAL_ERROR "pano_cli classify-open unexpectedly succeeded: ${output}${error}")
endif()

string(FIND "${output}${error}" "${EXPECTED_OUTPUT}" found_at)
if(found_at EQUAL -1)
    message(FATAL_ERROR
        "pano_cli classify-open failure output did not contain expected text.\nExpected: ${EXPECTED_OUTPUT}\nOutput: ${output}${error}")
endif()
