if(NOT DEFINED PANO_CLI)
    message(FATAL_ERROR "PANO_CLI must be set")
endif()

if(NOT DEFINED EXPECTED_OUTPUT)
    message(FATAL_ERROR "EXPECTED_OUTPUT must be set")
endif()

if(NOT DEFINED EXPECT_UNKNOWN_KIND)
    set(EXPECT_UNKNOWN_KIND OFF)
endif()

if(EXPECT_UNKNOWN_KIND)
    execute_process(
        COMMAND "${PANO_CLI}" plan-brush-package-import
            --kind zip
            --path D:/Paint/Brushes/clouds.zip
        RESULT_VARIABLE result
        OUTPUT_VARIABLE output
        ERROR_VARIABLE error)
else()
    execute_process(
        COMMAND "${PANO_CLI}" plan-brush-package-import
            --kind ppbr
        RESULT_VARIABLE result
        OUTPUT_VARIABLE output
        ERROR_VARIABLE error)
endif()

if(result EQUAL 0)
    message(FATAL_ERROR "Expected pano_cli plan-brush-package-import to fail, but it exited 0")
endif()

set(combined_output "${output}${error}")
string(FIND "${combined_output}" "${EXPECTED_OUTPUT}" expected_index)
if(expected_index LESS 0)
    message(FATAL_ERROR
        "Expected output to contain '${EXPECTED_OUTPUT}', got: ${combined_output}")
endif()
