60 lines
3.6 KiB
CMake
60 lines
3.6 KiB
CMake
cmake_minimum_required(VERSION 4.0)
|
|
|
|
function(check_process expected_code expected_out_regex expected_err_regex)
|
|
execute_process(COMMAND "${VBS}" ${ARGN}
|
|
RESULT_VARIABLE code OUTPUT_VARIABLE out ERROR_VARIABLE err TIMEOUT 15)
|
|
if(NOT "${code}" STREQUAL "${expected_code}")
|
|
message(FATAL_ERROR "vbs ${ARGN}: expected exit ${expected_code}, got ${code}\nstdout=[${out}]\nstderr=[${err}]")
|
|
endif()
|
|
if(NOT "${expected_out_regex}" STREQUAL "" AND NOT out MATCHES "${expected_out_regex}")
|
|
message(FATAL_ERROR "vbs ${ARGN}: stdout did not match [${expected_out_regex}]\nactual=[${out}]")
|
|
endif()
|
|
if(NOT "${expected_err_regex}" STREQUAL "" AND NOT err MATCHES "${expected_err_regex}")
|
|
message(FATAL_ERROR "vbs ${ARGN}: stderr did not match [${expected_err_regex}]\nactual=[${err}]")
|
|
endif()
|
|
endfunction()
|
|
|
|
check_process(0 "Usage: vbs .*<command>.*Commands:" "" )
|
|
check_process(0 "Usage: vbs .*<command>.*Commands:" "" --help)
|
|
check_process(0 "Usage: vbs .*<command>.*Commands:" "" -h)
|
|
check_process(0 "^vbs ${VBS_VERSION}\n$" "" --version)
|
|
check_process(0 "^vbs ${VBS_VERSION}\n$" "" -V)
|
|
check_process(2 "" "unknown option: --invalid" --version --invalid)
|
|
check_process(2 "" "--version cannot be combined with subcommands" --version build)
|
|
check_process(2 "" "unknown subcommand: invalid" invalid)
|
|
check_process(0 "Usage: vbs build .*--native-foreign.*--profile.*\\(repeatable\\)" "" build --help)
|
|
check_process(0 "Usage: vbs test " "" test --help)
|
|
check_process(0 "Usage: vbs init " "" init --help)
|
|
check_process(0 "Usage: vbs clean " "" clean --help)
|
|
check_process(0 "Usage: vbs doctor " "" doctor --help)
|
|
check_process(0 "Usage: vbs graph " "" graph --help)
|
|
check_process(2 "" "unsupported --format" graph --format xml)
|
|
check_process(2 "" "multi-profile build requires --editor-profile" build --profile debug --profile release)
|
|
check_process(2 "" "must be one of the requested profiles" build --profile debug --profile release --editor-profile custom)
|
|
check_process(0 "Usage: vbs compdb <command>.*Commands:.*use.*show.*export.*watch" "" compdb --help)
|
|
check_process(0 "Usage: vbs compdb use " "" compdb use --help)
|
|
check_process(2 "" "missing subcommand for 'vbs compdb'" compdb)
|
|
check_process(2 "" "unknown subcommand: bogus" compdb bogus)
|
|
check_process(0 "Usage: vbs deps <command>.*Commands:.*resolve.*update" "" deps --help)
|
|
check_process(0 "Usage: vbs deps resolve " "" deps resolve --help)
|
|
check_process(2 "" "missing subcommand for 'vbs deps'" deps)
|
|
check_process(2 "" "--request and --output are required" bridge)
|
|
check_process(0 "Usage: vbs install " "" install --help)
|
|
check_process(2 "" "--prefix is required" install)
|
|
check_process(2 "" "--prefix is required" uninstall)
|
|
check_process(2 "" "--input and --output-dir are required" gen-tests)
|
|
check_process(0 "Usage: vbs publish " "" publish --help)
|
|
check_process(2 "" "--registry, --name, and --version are required" publish)
|
|
check_process(0 "Usage: vbs ide <command>.*Commands:.*generate.*query" "" ide --help)
|
|
check_process(0 "Usage: vbs ide generate " "" ide generate --help)
|
|
check_process(0 "Usage: vbs ide query " "" ide query --help)
|
|
check_process(2 "" "missing subcommand for 'vbs ide'" ide)
|
|
check_process(2 "" "unknown IDE kind" ide generate --editor invalid_ide)
|
|
|
|
execute_process(COMMAND "${VBS_REGISTRY}" --help
|
|
RESULT_VARIABLE reg_code OUTPUT_VARIABLE reg_out ERROR_VARIABLE reg_err TIMEOUT 15)
|
|
if(NOT "${reg_code}" STREQUAL "0" OR NOT reg_out MATCHES "Usage: vbs-registry")
|
|
message(FATAL_ERROR "vbs-registry --help failed: code=${reg_code}\nstdout=[${reg_out}]\nstderr=[${reg_err}]")
|
|
endif()
|
|
message(STATUS "37 native CLI and auto-generated Argparse help contracts verified")
|