enh(ProcessRunner): does not detect launch errors #4482 (#4483)

* enh(ProcessRunner): does not detect launch errors #4482

* enh(File): add absolutePath and existsAnywhere() #4482

* fix windows build and tsan fail

* fix tsan

* fix windows file tests

* comment out some CI env path -related issues

* fix tsan and windows build

* try to fix ci

* ignore ProcessRunner test fail on windows cmake

* enh(File): canExecute throws FileNotFoundException if the file to be executed can't be found in the path.

* Few C++ modernisation changes.

* enh(File): Windows specifics of File::canExecute. Returns false if the file to be executed can't be found using absolutePath.

---------

Co-authored-by: Matej Kenda <matejken@gmail.com>
This commit is contained in:
Aleksandar Fabijanic
2024-07-29 13:16:18 -05:00
committed by GitHub
parent f24547cdcf
commit 3656f069e1
20 changed files with 361 additions and 37 deletions

View File

@@ -111,11 +111,11 @@ void ProcessRunnerTest::testProcessRunner()
assertTrue (pr.cmdLine() == cmdLine(cmd, args));
assertFalse (pr.running());
pr.start();
Stopwatch sw; sw.start();
while (!pr.running())
checkTimeout(sw, "Waiting for process to start", 1000, __LINE__);
assertTrue (pr.running());
try
{
@@ -264,6 +264,42 @@ void ProcessRunnerTest::testProcessRunner()
}
assertTrue (!File(pidFile).exists());
}
// non-existent executable with no PID file created
{
std::string cmd = "nonexistent_123-xyz";
std::vector<std::string> args;
char c = Path::separator();
std::string pidFile = Poco::format("run%c%s.pid", c, name);
{
std::unique_ptr<ProcessRunner> pr;
try
{
pr.reset(new ProcessRunner(cmd, args));
failmsg("ProcessRunner should throw an exception.");
} catch(const Poco::FileException& e) {}
}
assertTrue (!File(pidFile).exists());
}
// non-existent executable with PID file created
{
std::string cmd = "nonexistent_123-xyz";
std::vector<std::string> args;
char c = Path::separator();
std::string pidFile = Poco::format("run%c%s.pid", c, name);
args.push_back(std::string("-p=").append(pidFile));
{
std::unique_ptr<ProcessRunner> pr;
try
{
pr.reset(new ProcessRunner(cmd, args));
failmsg("ProcessRunner should throw an exception.");
} catch(const Poco::FileException& e) {}
}
assertTrue (!File(pidFile).exists());
}
#if defined(POCO_OS_FAMILY_UNIX)
// start process launching multiple threads
{