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
This commit is contained in:
parent
c10cb0fde9
commit
cb5f136c66
@ -97,7 +97,12 @@ int cmCTestScriptHandler::ExecuteScript(std::string const& total_script_arg)
|
||||
this->CTest->GetInitialCommandLineArguments();
|
||||
//*** need to make sure this does not have the current script ***
|
||||
for (size_t i = 1; i < initArgs.size(); ++i) {
|
||||
argv.push_back(initArgs[i]);
|
||||
// in a nested subprocess, skip the parent's `-SR <path>` arguments.
|
||||
if (initArgs[i] == "-SR") {
|
||||
i++; // <path>
|
||||
} else {
|
||||
argv.push_back(initArgs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Now create process object
|
||||
|
@ -1975,9 +1975,12 @@ int cmCTest::Run(std::vector<std::string> const& args)
|
||||
};
|
||||
auto const dashSR =
|
||||
[&runScripts, &SRArgumentSpecified](std::string const& script) -> bool {
|
||||
SRArgumentSpecified = true;
|
||||
runScripts.emplace_back(cmSystemTools::ToNormalizedPathOnDisk(script),
|
||||
true);
|
||||
// -SR should be processed only once
|
||||
if (!SRArgumentSpecified) {
|
||||
SRArgumentSpecified = true;
|
||||
runScripts.emplace_back(cmSystemTools::ToNormalizedPathOnDisk(script),
|
||||
true);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
auto const dash_S =
|
||||
|
Loading…
Reference in New Issue
Block a user