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

[Fixes #260] Make space trimming consistent for all task arguments #259

Merged
merged 2 commits into from
Mar 8, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rake/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def parse_task_string(string) # :nodoc:
args = []

begin
/((?:[^\\,]|\\.)*?)\s*(?:,\s*(.*))?$/ =~ remaining_args
/\s*((?:[^\\,]|\\.)*?)\s*(?:,\s*(.*))?$/ =~ remaining_args

remaining_args = $2
args << $1.gsub(/\\(.)/, '\1')
Expand Down
4 changes: 2 additions & 2 deletions test/test_rake_task_argument_parsing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def test_two_arguments
assert_equal ["one", "two"], args
end

def test_can_handle_spaces_between_args
name, args = @app.parse_task_string("name[one, two,\tthree , \tfour]")
def test_can_handle_spaces_between_all_args
name, args = @app.parse_task_string("name[ one , two ,\tthree , \tfour ]")
Copy link
Member

Choose a reason for hiding this comment

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

Keep the existing test and add a new test as this is technically a new feature. Also, make sure it doesn't strip out whitespaces in a string literal:

rake name[one,two,three]     # => should be interpreted as `rake name[one,two,three]`
rake name[ one , two, three] # => should be interpreted as `rake name[one,two,three]`

rake name["one two",three]   # => should be interpreted as `rake name["one two",three]`
rake name[ "one two", three] # => should be interpreted as `rake name["one two",three]`

Copy link
Contributor Author

@grzuy grzuy Mar 7, 2018

Choose a reason for hiding this comment

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

Thanks for the feedback.

Added original test back.
Regarding your second comment, i think there's already a test case below testing that white-spaces embedded in arguments are not stripped out. Let me know if that covers it or not.

Added new commit, let me know if you prefer amend.

assert_equal "name", name
assert_equal ["one", "two", "three", "four"], args
end
Expand Down