Skip to content

Commit

Permalink
Fix param_file_arg error message
Browse files Browse the repository at this point in the history
The error message incorrectly escaped the missing format specifier. As
a result, the 'Expected string with a single "%s"' read 'Expected string
with a single "<value of the arg>"' instead.

Closes #15637.

PiperOrigin-RevId: 473714483
Change-Id: Ib2d757134f21fcf915dfefb06c0ea9cc9be2d80e
  • Loading branch information
fmeum authored and copybara-github committed Sep 12, 2022
1 parent 382c118 commit 19b299d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,8 @@ public CommandLineArgsApi useParamsFile(String paramFileArg, Boolean useAlways)
Starlark.checkMutable(this);
if (!SingleStringArgFormatter.isValid(paramFileArg)) {
throw Starlark.errorf(
"Invalid value for parameter \"param_file_arg\": Expected string with a single \"%s\"",
"Invalid value for parameter \"param_file_arg\": Expected string with a single \"%%s\","
+ " got \"%s\"",
paramFileArg);
}
this.flagFormatString = paramFileArg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2387,11 +2387,12 @@ public void testWriteArgsToParamFile() throws Exception {
public void testLazyArgsWithParamFileInvalidFormatString() throws Exception {
setRuleContext(createRuleContext("//foo:foo"));
ev.checkEvalErrorContains(
"Invalid value for parameter \"param_file_arg\": Expected string with a single \"--file=\"",
"Invalid value for parameter \"param_file_arg\": "
+ "Expected string with a single \"%s\", got \"--file=\"",
"args = ruleContext.actions.args()\n" + "args.use_param_file('--file=')");
ev.checkEvalErrorContains(
"Invalid value for parameter \"param_file_arg\": "
+ "Expected string with a single \"--file=%s%s\"",
+ "Expected string with a single \"%s\", got \"--file=%s%s\"",
"args = ruleContext.actions.args()\n" + "args.use_param_file('--file=%s%s')");
}

Expand Down

0 comments on commit 19b299d

Please sign in to comment.