Skip to content

Commit

Permalink
Merge pull request #29686 from loganharbour/global_cli_subapps
Browse files Browse the repository at this point in the history
Add test for checking global cli parameters across subapps
  • Loading branch information
loganharbour authored Jan 14, 2025
2 parents 2df0918 + 3fd0406 commit b451641
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion unit/src/CommandLineTest.C
Original file line number Diff line number Diff line change
Expand Up @@ -500,13 +500,13 @@ TEST(CommandLineTest, initSubAppCommandLine)
const auto subapp_cl =
cl.initSubAppCommandLine(multiapp_name, subapp_name, std::vector<std::string>());
ASSERT_EQ(expected_args, subapp_cl->getArguments());

subapp_cl->parse();
subapp_cl->populateCommandLineParams(params);

const auto subsubapp_cl =
subapp_cl->initSubAppCommandLine(multiapp_name, subsubapp_name, std::vector<std::string>());
ASSERT_EQ(subexpected_args, subsubapp_cl->getArguments());
subsubapp_cl->parse();
};

test({"--global",
Expand All @@ -526,6 +526,32 @@ TEST(CommandLineTest, initSubAppCommandLine)
test({"--unused", "--another_global"}, "sub", "sub1", "subsub1", {}, {});
}

TEST(CommandLineTest, globalCommandLineParamSubapp)
{
InputParameters params = emptyInputParameters();
params.addCommandLineParam<bool>("global", "--global", "Doc1");
params.setGlobalCommandLineParam("global");
InputParameters subapp_params = params;
InputParameters subsubapp_params = params;

CommandLine cl;
cl.addArgument("/path/to/exe");
cl.addArgument("--global");
cl.parse();
cl.populateCommandLineParams(params);
ASSERT_TRUE(params.get<bool>("global"));

const auto subapp_cl = cl.initSubAppCommandLine("sub", "sub0", {});
subapp_cl->parse();
subapp_cl->populateCommandLineParams(subapp_params);
ASSERT_TRUE(subapp_params.get<bool>("global"));

const auto subsubapp_cl = cl.initSubAppCommandLine("subsub", "subsub0", {});
subsubapp_cl->parse();
subsubapp_cl->populateCommandLineParams(subsubapp_params);
ASSERT_TRUE(subsubapp_params.get<bool>("global"));
}

TEST(CommandLineTest, requiredParameter)
{
InputParameters params = emptyInputParameters();
Expand Down

0 comments on commit b451641

Please sign in to comment.