Previously these were allowed but ignored.
This change implements one of the settings simplifications listed in #17508. Change includes release notes.
908@@ -887,7 +909,7 @@ BOOST_FIXTURE_TEST_CASE(util_ArgsMerge, ArgsMergeTestingSetup)
909 // Results file is formatted like:
910 //
911 // <input> || <IsArgSet/IsArgNegated/GetArg output> | <GetArgs output> | <GetUnsuitable output>
912- BOOST_CHECK_EQUAL(out_sha_hex, "b835eef5977d69114eb039a976201f8c7121f34fe2b7ea2b73cafb516e5c9dc8");
913+ BOOST_CHECK_EQUAL(out_sha_hex, "8fd4877bb8bf337badca950ede6c917441901962f160e52514e06a60dea46cde");
In commit “util: Disallow network-qualified command line options” (baf24fc2ee7b57d46dc57f18f840c6961a963540)
Effect of this change is to remove a lot of lines that contain network-qualified command line options from test output:
0-net=test -main.server=a1 -main.server=a2 noserver=1 main.server=c1 main.server=c2 server=c3 server=c4 soft || c3 | c3 c4
Lines without network-qualified command line options are unaffected:
0 net=test -server=a1 -server=a2 main.server=c1 main.server=c2 noserver=1 server=c3 server=c4 soft || a2 | a1 a2 c3 c4
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
339- m_settings.command_line_options[key].push_back(value);
340- }
341- } else {
342- error = strprintf("Invalid parameter -%s", key);
343+
344+ if (!flags || !section.empty()) {
nit, alternatively could have a detailed error, like:
0if (!flags) {
1 error = strprintf("Unknown parameter %s", key);
2 return false;
3} else if (!section.empty()) {
4 error = strprintf("Invalid parameter %s, section %s now allowed", argv[i], section);
5 return false;
6}
re: #17482 (review)
nit, could have a comment like “command line options unknown or with section prefixes are invalid”
Thanks added comment.
nit, alternatively could have a detailed error, like:
0if (!flags) { 1 error = strprintf("Unknown parameter %s", key); 2 return false; 3} else if (!section.empty()) { 4 error = strprintf("Invalid parameter %s, section %s now allowed", argv[i], section); 5 return false; 6}
That error message seems worse to me. In the first branch, it provides less information and could make the bad argument harder to identify, and in the second branch it references the “section” of a command line parameter which isn’t actually a thing that exists, or someone would expect to exist.
237+ TestArgsManager test;
238+ test.SetupArgs({{"-registered", ArgsManager::ALLOW_ANY}});
239+
240+ const char* argv[] = {"ignored", "-registered"};
241+ std::string error;
242+ BOOST_CHECK(test.ParseParameters(2, (char**)argv, error));
re: #17482 (review)
nit, success case seems unnecessary.
It helps ensure the test passes for right reason. That ParseParameters calls below aren’t returning false for some other reason. Generally it’s nice when test cases vary one input at a time, so you can be sure about what causes the observed output.
335- // line options with section prefixes are allowed but ignored. It
336- // would be better if these options triggered the Invalid parameter
337- // error below.
338- if (section.empty()) {
339- m_settings.command_line_options[key].push_back(value);
340- }
Code review and tested ACK 124841f
Tested network-qualified command line args with/without this patchset and errors are now thrown as expected.
pr/wdqual.2
-> pr/wdqual.3
, compare) just adding suggested comment
Previously these were allowed but ignored.