ctest_start() invoked by script launched with ctest_run_script() sets ShouldRunCurrentScript on wrong cmCTestScriptHandler instance
ctest -S script.cmake on an empty file, leads to an error that
CTEST_COMMAND are not set. This is the
declarative dashboard script mode.
ctest_start(Experimental "." ".") is added to the file, the error disappears, because
ctest_start() activates the
command-driven dashboard script mode.
When launching the script with the
ctest_run_script() command from another script, the error message is back.
Looking at the source code, we see that inside the functon
cmCTestScriptHandler::RunScript an instance of
cmCTestScriptHandler is created for the nested script. However, in
SetRunCurrentScript(false) is called on the instance of the outer script.
ctest_start() (and maybe also
ctest_run_script()?) should call
SetRunCurrentScript(false) on the
cmCTestScriptHandler of the script where it is actually invoked.