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 Rails command infrastructure #22457

Merged
merged 1 commit into from Dec 4, 2015
Merged

Add Rails command infrastructure #22457

merged 1 commit into from Dec 4, 2015

Conversation

ccallebs
Copy link
Contributor

Corollary of #21254. Isolates command infrastructure and reduces sprawl of previous PR.

@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @arthurnn (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@kaspth kaspth assigned kaspth and unassigned arthurnn Dec 1, 2015
@kaspth kaspth added this to the 5.0.0 milestone Dec 1, 2015
system "rake #{task_name}"
end
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

We should only add code we're using. Kill this method 😄

@kaspth
Copy link
Contributor

kaspth commented Dec 1, 2015

Don't worry about the documentation for now, I'll write it after this is merged.

We also need some tests for the general functionality here. Some simple integration tests modeled after https://github.com/rails/rails/blob/master/railties/test/application/test_runner_test.rb would do.

The helpers you'll need are here: https://github.com/rails/rails/blob/master/railties/test/isolation/abstract_unit.rb

@kaspth
Copy link
Contributor

kaspth commented Dec 1, 2015

Also thanks for working on this! ❤️

@ccallebs
Copy link
Contributor Author

ccallebs commented Dec 1, 2015

@kaspth No problem! Sorry it's taken so long, and I appreciate the patience.

Dir.chdir(app_path) { `bin/rails #{task}` }
end

def create_command(class_name: :test, task:)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kaspth I think we're going to have a problem testing here -- I see no way given the way commands are currently loaded to "inject" new ones into the process. My idea was to create an lib/commands directory (similar to lib/tasks, but for these commands) . That's a pretty big decision though, so I wanted to get feedback. If you can think of a way to dynamically create commands, let me know and this becomes a non-issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you mean by new ones? We don't have to generate a new command, it's fine to just use one of the existing ones (which will be the dev_cache command because it's the only one that exists currently) .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kaspth I guess I misunderstood then -- I thought you just wanted generic tests surrounding the addition of new commands. What would be different about these tests vs. the dev_cache tests below?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just that we are exercising the command running code a bit. But then again I guess any behavior is tested through the commands we ship with.

Alright, if all the Railties tests pass, then it's fine. I'll look into what other tests need after this then 😁

@rafaelfranca
Copy link
Member

r? @kaspth

klass.new(@argv)
rescue
nil
end
Copy link
Contributor

Choose a reason for hiding this comment

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

This blanket rescue shouldn't be needed. Why is it needed currently? 😁

@kaspth
Copy link
Contributor

kaspth commented Dec 4, 2015

@ccallebs we don't have much time left to get this in. Please address my last comments as soon as you can and squash your commits down to one. Then I'll merge and we can start transforming more tasks to commands ❤️

@ccallebs
Copy link
Contributor Author

ccallebs commented Dec 4, 2015

@kaspth Will do, just had one more question. Anything more will be addressed today, I won't let this linger any longer.

@ccallebs
Copy link
Contributor Author

ccallebs commented Dec 4, 2015

@kaspth Everything is addressed and squashed! Let me know if you need anything else. I'll jump in to help with some of the other commands once this is merged.

kaspth added a commit that referenced this pull request Dec 4, 2015
@kaspth kaspth merged commit 6616724 into rails:master Dec 4, 2015
@kaspth
Copy link
Contributor

kaspth commented Dec 4, 2015

Awesome work! ❤️

@ccallebs
Copy link
Contributor Author

ccallebs commented Dec 4, 2015

@kaspth It's been a long crazy trip! :)

@kaspth
Copy link
Contributor

kaspth commented Dec 4, 2015

And we ain't out of the woods yet ;)


test 'dev:cache deletes file and outputs message' do
Dir.chdir(app_path) do
output = `rails dev:cache`
Copy link

Choose a reason for hiding this comment

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

This assignation is unneeded

Choose a reason for hiding this comment

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

Duplicate line, yes?

Copy link
Contributor

Choose a reason for hiding this comment

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

Cleared it up with some comments: 2af9c08 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants