ctest: Prevent infinite loop in ctest_run_script(NEW_PROCESS)

ctest passes an internal -SR argument to inform a subprocess which
script to run. Because all arguments are propagated to the subprocess,
nested subprocess receives multiple -SR arguments and re-runs
the parent script in addition to its own, leading to a loop.

Ignore redundant -SR arguments on input and also filter out parent's
-SR argument when constructing a child process.

Fixes: #8837
2 files changed