Process launcher updates (#6183)
* Enable process and ap connection tests on linux * Updated 'OpenProjectManager' to use new the ProcessLauncher argument type * Add logic to double-escape escaped double quotes in arguments on windows platforms * Updated argument for LaunchProjectManager to reflect new ProcessLauncher argument type * Fixed unit test arguments for 'arg=value' condition * Fix compile errors for BuilderManager and RHI.Edit\Utils.cpp * PAL'ify the GetCommandLineParametersAsString() to handle windows specific behavior Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com> Co-authored-by: byrcolin <byrcolin@amazon.com>
This commit is contained in:
@@ -75,7 +75,8 @@ namespace UnitTest
|
||||
AzFramework::ProcessOutput processOutput;
|
||||
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
|
||||
|
||||
processLaunchInfo.m_commandlineParameters = AZ_TRAIT_TEST_ROOT_FOLDER "ProcessLaunchTest";
|
||||
processLaunchInfo.m_commandlineParameters.emplace<AZStd::string>(AZStd::string(AZ_TRAIT_TEST_ROOT_FOLDER "ProcessLaunchTest"));
|
||||
|
||||
processLaunchInfo.m_workingDirectory = AZ::Test::GetCurrentExecutablePath();
|
||||
processLaunchInfo.m_showWindow = false;
|
||||
bool launchReturn = AzFramework::ProcessWatcher::LaunchProcessAndRetrieveOutput(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT, processOutput);
|
||||
@@ -90,7 +91,9 @@ namespace UnitTest
|
||||
AzFramework::ProcessOutput processOutput;
|
||||
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
|
||||
|
||||
processLaunchInfo.m_commandlineParameters = AZ_TRAIT_TEST_ROOT_FOLDER "ProcessLaunchTest -param1 param1val -param2=param2val";
|
||||
processLaunchInfo.m_commandlineParameters.emplace<AZStd::vector<AZStd::string>>(
|
||||
AZStd::vector<AZStd::string>{AZStd::string(AZ_TRAIT_TEST_ROOT_FOLDER "ProcessLaunchTest"), "-param1", "param1val","-param2", "param2val"});
|
||||
|
||||
processLaunchInfo.m_workingDirectory = AZ::Test::GetCurrentExecutablePath();
|
||||
processLaunchInfo.m_showWindow = false;
|
||||
bool launchReturn = AzFramework::ProcessWatcher::LaunchProcessAndRetrieveOutput(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT, processOutput);
|
||||
@@ -117,14 +120,16 @@ namespace UnitTest
|
||||
#if AZ_TRAIT_DISABLE_FAILED_PROCESS_LAUNCHER_TESTS
|
||||
TEST_F(ProcessLaunchParseTests, DISABLED_ProcessLauncher_StringsWithCommas_Success)
|
||||
#else
|
||||
TEST_F(ProcessLaunchParseTests, ProcessLauncher_StringsWithCommas_Success)
|
||||
TEST_F(ProcessLaunchParseTests, ProcessLauncher_WithCommas_Success)
|
||||
#endif // AZ_TRAIT_DISABLE_FAILED_PROCESS_LAUNCHER_TESTS
|
||||
{
|
||||
ProcessLaunchParseTests::ParsedArgMap argMap;
|
||||
AzFramework::ProcessOutput processOutput;
|
||||
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
|
||||
|
||||
processLaunchInfo.m_commandlineParameters = AZ_TRAIT_TEST_ROOT_FOLDER R"(ProcessLaunchTest -param1 "\"param,1val\"" -param2="\"param2v,al\"")";
|
||||
processLaunchInfo.m_commandlineParameters.emplace<AZStd::vector<AZStd::string>>(
|
||||
AZStd::vector<AZStd::string>{AZStd::string(AZ_TRAIT_TEST_ROOT_FOLDER "ProcessLaunchTest"), "-param1", "param,1val","-param2", "param2v,al"});
|
||||
|
||||
processLaunchInfo.m_workingDirectory = AZ::Test::GetCurrentExecutablePath();
|
||||
processLaunchInfo.m_showWindow = false;
|
||||
bool launchReturn = AzFramework::ProcessWatcher::LaunchProcessAndRetrieveOutput(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT, processOutput);
|
||||
@@ -137,28 +142,32 @@ namespace UnitTest
|
||||
EXPECT_NE(param1itr, argMap.end());
|
||||
AZStd::vector<AZStd::string> param1{ param1itr->second };
|
||||
|
||||
EXPECT_EQ(param1.size(), 1);
|
||||
EXPECT_EQ(param1[0], "param,1val");
|
||||
EXPECT_EQ(param1.size(), 2);
|
||||
EXPECT_EQ(param1[0], "param");
|
||||
EXPECT_EQ(param1[1], "1val");
|
||||
|
||||
auto param2itr = argMap.find("param2");
|
||||
EXPECT_NE(param2itr, argMap.end());
|
||||
AZStd::vector<AZStd::string> param2{ param2itr->second };
|
||||
|
||||
EXPECT_EQ(param2.size(), 1);
|
||||
EXPECT_EQ(param2[0], "param2v,al");
|
||||
EXPECT_EQ(param2.size(), 2);
|
||||
EXPECT_EQ(param2[0], "param2v");
|
||||
EXPECT_EQ(param2[1], "al");
|
||||
}
|
||||
|
||||
#if AZ_TRAIT_DISABLE_FAILED_PROCESS_LAUNCHER_TESTS
|
||||
TEST_F(ProcessLaunchParseTests, DISABLED_ProcessLauncher_StringsWithSpaces_Success)
|
||||
#else
|
||||
TEST_F(ProcessLaunchParseTests, ProcessLauncher_StringsWithSpaces_Success)
|
||||
TEST_F(ProcessLaunchParseTests, ProcessLauncher_WithSpaces_Success)
|
||||
#endif // AZ_TRAIT_DISABLE_FAILED_PROCESS_LAUNCHER_TESTS
|
||||
{
|
||||
ProcessLaunchParseTests::ParsedArgMap argMap;
|
||||
AzFramework::ProcessOutput processOutput;
|
||||
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
|
||||
|
||||
processLaunchInfo.m_commandlineParameters = AZ_TRAIT_TEST_ROOT_FOLDER R"(ProcessLaunchTest -param1 "\"param 1val\"" -param2="\"param2v al\"")";
|
||||
processLaunchInfo.m_commandlineParameters.emplace<AZStd::vector<AZStd::string>>(AZStd::vector<AZStd::string>{
|
||||
AZStd::string(AZ_TRAIT_TEST_ROOT_FOLDER "ProcessLaunchTest"), "-param1", R"("param 1val")", R"(-param2="param2v al")" });
|
||||
|
||||
processLaunchInfo.m_workingDirectory = AZ::Test::GetCurrentExecutablePath();
|
||||
processLaunchInfo.m_showWindow = false;
|
||||
bool launchReturn = AzFramework::ProcessWatcher::LaunchProcessAndRetrieveOutput(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT, processOutput);
|
||||
@@ -185,14 +194,16 @@ namespace UnitTest
|
||||
#if AZ_TRAIT_DISABLE_FAILED_PROCESS_LAUNCHER_TESTS
|
||||
TEST_F(ProcessLaunchParseTests, DISABLED_ProcessLauncher_StringsWithSpacesAndComma_Success)
|
||||
#else
|
||||
TEST_F(ProcessLaunchParseTests, ProcessLauncher_StringsWithSpacesAndComma_Success)
|
||||
TEST_F(ProcessLaunchParseTests, ProcessLauncher_WithSpacesAndComma_Success)
|
||||
#endif // AZ_TRAIT_DISABLE_FAILED_PROCESS_LAUNCHER_TESTS
|
||||
{
|
||||
ProcessLaunchParseTests::ParsedArgMap argMap;
|
||||
AzFramework::ProcessOutput processOutput;
|
||||
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
|
||||
|
||||
processLaunchInfo.m_commandlineParameters = AZ_TRAIT_TEST_ROOT_FOLDER R"(ProcessLaunchTest -param1 "\"par,am 1val\"" -param2="\"param,2v al\"")";
|
||||
processLaunchInfo.m_commandlineParameters.emplace<AZStd::vector<AZStd::string>>(AZStd::vector<AZStd::string>{
|
||||
AZStd::string(AZ_TRAIT_TEST_ROOT_FOLDER "ProcessLaunchTest"), "-param1", R"("param, 1val")", R"(-param2="param,2v al")" });
|
||||
|
||||
processLaunchInfo.m_workingDirectory = AZ::Test::GetCurrentExecutablePath();
|
||||
processLaunchInfo.m_showWindow = false;
|
||||
bool launchReturn = AzFramework::ProcessWatcher::LaunchProcessAndRetrieveOutput(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT, processOutput);
|
||||
@@ -206,7 +217,7 @@ namespace UnitTest
|
||||
AZStd::vector<AZStd::string> param1{ param1itr->second };
|
||||
|
||||
EXPECT_EQ(param1.size(), 1);
|
||||
EXPECT_EQ(param1[0], "par,am 1val");
|
||||
EXPECT_EQ(param1[0], "param, 1val");
|
||||
|
||||
auto param2itr = argMap.find("param2");
|
||||
EXPECT_NE(param2itr, argMap.end());
|
||||
@@ -216,35 +227,4 @@ namespace UnitTest
|
||||
EXPECT_EQ(param2[0], "param,2v al");
|
||||
}
|
||||
|
||||
TEST_F(ProcessLaunchParseTests, ProcessLauncher_CommaStringNoQuotes_Success)
|
||||
{
|
||||
ProcessLaunchParseTests::ParsedArgMap argMap;
|
||||
AzFramework::ProcessOutput processOutput;
|
||||
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
|
||||
|
||||
processLaunchInfo.m_commandlineParameters = AZ_TRAIT_TEST_ROOT_FOLDER "ProcessLaunchTest -param1 param,1val -param2=param2v,al";
|
||||
processLaunchInfo.m_workingDirectory = AZ::Test::GetCurrentExecutablePath();
|
||||
processLaunchInfo.m_showWindow = false;
|
||||
bool launchReturn = AzFramework::ProcessWatcher::LaunchProcessAndRetrieveOutput(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT, processOutput);
|
||||
|
||||
EXPECT_EQ(launchReturn, true);
|
||||
|
||||
argMap = ProcessLaunchParseTests::ParseParameters(processOutput.outputResult);
|
||||
|
||||
auto param1itr = argMap.find("param1");
|
||||
EXPECT_NE(param1itr, argMap.end());
|
||||
AZStd::vector<AZStd::string> param1{ param1itr->second };
|
||||
|
||||
EXPECT_EQ(param1.size(), 2);
|
||||
EXPECT_EQ(param1[0], "param");
|
||||
EXPECT_EQ(param1[1], "1val");
|
||||
|
||||
auto param2itr = argMap.find("param2");
|
||||
EXPECT_NE(param2itr, argMap.end());
|
||||
AZStd::vector<AZStd::string> param2{ param2itr->second };
|
||||
|
||||
EXPECT_EQ(param2.size(), 2);
|
||||
EXPECT_EQ(param2[0], "param2v");
|
||||
EXPECT_EQ(param2[1], "al");
|
||||
}
|
||||
} // namespace UnitTest
|
||||
|
||||
Reference in New Issue
Block a user