Explain the relationship between --format and --out - #1889
Conversation
A single --out is applied to every --format rather than to the first one, and nothing said so. Combining a console formatter with junit therefore failed with a message about a path the user never meant for that formatter. The option help now states the rule, and the message of ConsoleOutputFactory says where the directory came from. It also adopts the wording its two sibling factories already use, and is split over several lines because the Symfony error box does not wrap.
acoulton
left a comment
There was a problem hiding this comment.
Thanks @Amoifr
On this point:
junit creates a directory named report.xml containing default.xml, and then pretty fails saying a file name was expected. The user gave a file name, so the message contradicts what they typed. Happy to open a separate issue if you think that deserves one.
I think we leave that. Although it could be confusing, the user didn't necessarily give a file name (report.xml is a valid directory name, even if it looks like a file). The underlying issue is the design of the --out API and we could get into quite a lot of complexity trying to work out the most meaningful exception message for every possible usage.
The main thing is that the documentation of the --out parameter is now much clearer, so if users do have errors that should allow them to understand what's gone wrong.
Fixes #1409, scoped to the two points @acoulton reopened it for: the option help and the error message.
Reproducing it first turned up something the issue does not say. A single
--outis not applied to the first formatter, it is applied to every one, throughsetFormattersParameter(). The index pairing only starts once there are two or more--out. So in the reported command the console formatter receives the directory meant for junit, and complains about a path the user never intended for it.The message now says where that directory came from, and adopts the wording the two sibling factories already use:
It is split over three lines because the Symfony error box does not wrap: as a single sentence it rendered as a box 230 characters wide. The path is no longer interpolated, matching
FileOutputFactoryandFilesystemOutputFactory, and it is still on the exception throughgetPath().The help of
--outnow states the rule, and--formatpoints at it, which is what @stof asked for:A scenario in
features/multiple_formats.featurepins the message, using the reported command. Worth knowing for whoever reads it:-f pretty -f progress --out=filedoes not fail, because two console formatters both write to the file and the second simply overwrites the first. Only mixing a console formatter with junit trips it, since junit creates the directory that the console formatter then chokes on.One thing I left alone
The symmetric case is worse and I did not touch it, since it is behaviour rather than wording:
junit creates a directory named
report.xmlcontainingdefault.xml, and then pretty fails saying a file name was expected. The user gave a file name, so the message contradicts what they typed. Happy to open a separate issue if you think that deserves one.