Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Response File Capabilities to XUnit Console Runner #1843

Merged
merged 3 commits into from
Jan 28, 2019

Conversation

josalem
Copy link
Contributor

@josalem josalem commented Jan 19, 2019

  • consume a path prefixed by the @ symbol
  • file should be a space/tab delimited list of command line arguments
    (may be on multiple lines)
  • does not check file extension but typically it is .rsp

#1613

CC - @sergiy-k

* consume a path prefixed by the @ symbol
* file should be a space/tab delimited list of command line arguments
(may be on multiple lines)
* does not check file extension but typically it is .rsp
@josalem josalem added the xunit console runner work concerning the XUnit console runner label Jan 19, 2019
@josalem josalem self-assigned this Jan 19, 2019
@@ -109,13 +109,29 @@ static bool IsConfigFile(string fileName)
public static CommandLine Parse(params string[] args)
=> new CommandLine(args);

protected void ParseRspFile(string path)
{
if (!File.Exists(path))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need a File.Exists check here as File.ReadLines already throws a corresponding FileNotFoundException if the file doesn't exist.


foreach (string line in File.ReadLines(path))
{
foreach (var arg in line.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Reverse())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not work with paths that contain spaces. CommandLineUtils developed by @natemcmaster does this really well. Please take a look at his parser for the correct implementation: https://github.com/natemcmaster/CommandLineUtils/blob/f498cc7383b27730fd24486510573ab61ccab9d6/src/CommandLineUtils/Internal/ResponseFileParser.cs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 - I share @ViktorHofer's concern. Splitting on spaces alone is insufficient for response file parsing. How would a caller escape parameters with spaces in them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Will modify appropriately.

Copy link
Member

@ViktorHofer ViktorHofer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit worried that we don't have any tests for added functionality. I don't think we should port the whole test suite over but maybe add tests for new features? Of course that only makes sense if we plan to make more changes in the runner.

@jonfortescue
Copy link
Member

/AzurePipelines run arcade-ci

@azure-pipelines
Copy link

Success! 1 created and queued.

Copy link
Member

@jonfortescue jonfortescue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @josalem -- MC is showing some test failures for your build. The build is passing because there's a known issue where we can't download test results to builds triggered from forks; in the meantime, make sure you examine those and get them fixed before merging

@jonfortescue
Copy link
Member

@josalem -- looks like the failures were not caused by your PR but by something that was already merged, so ignore what I said for now

John Salem added 2 commits January 22, 2019 14:48
… characters and spaces

* Add attribution for response file reader code, and modified response file parser
@ViktorHofer
Copy link
Member

ViktorHofer commented Jan 24, 2019

I know that there are multiple modes in @natemcmaster's CommandLineUtils rsp implementation. Which mode did you port? The line one? Do we also need the other one?

Copy link
Contributor

@natemcmaster natemcmaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@josalem
Copy link
Contributor Author

josalem commented Jan 24, 2019

I know that there are multiple modes in @natemcmaster's CommandLineUtils rsp implementation. Which mode did you port? The line one? Do we also need the other one?

I ported the "space delimited" version, since it is more flexible. It reads the file line-by-line and parses each line so any combination of new-line delimited and space delimited args should work, e.g.,

-flag "arg \" with quotes and \' spaces" -otherFlag "otherFlag argument"

and

-flag
"arg \" with quotes and \' spaces"
-otherFlag
"otherFlag argument"

so I didn't see the point in including both impls.

@ViktorHofer
Copy link
Member

LGTM if you have tested it locally and it works fine. Thanks for doing this!

@josalem josalem merged commit 18c02fe into dotnet:master Jan 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
xunit console runner work concerning the XUnit console runner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants