[common] Add a way to set the process startup directory (#63)

This will be needed later for switching to sftp, since calling lcd in
sftp is tricky to get right (e.g. may or may not require /cygwin/c on
Windows, depending on whether sftp is native or not).
This commit is contained in:
Lutz Justen
2023-01-16 12:26:45 +01:00
committed by GitHub
parent 42f5ee9b44
commit f2177969fe
3 changed files with 24 additions and 2 deletions
+15
View File
@@ -342,5 +342,20 @@ TEST_F(ProcessTest, TerminateAlreadyExited) {
EXPECT_OK(process->Terminate());
}
TEST_F(ProcessTest, StartupDir) {
ProcessStartInfo start_info;
start_info.command = "cmd /C cd";
start_info.startup_dir = "C:\\";
std::string std_out;
start_info.stdout_handler = [&std_out](const char* data, size_t) {
std_out += data;
return absl::OkStatus();
};
EXPECT_OK(process_factory_.Run(start_info));
EXPECT_EQ(std_out, "C:\\\r\n");
}
} // namespace
} // namespace cdc_ft