Making task#invoke work inside a task#invoke #1

Open
halostatue opened this Issue Aug 26, 2011 · 2 comments

Projects

None yet

2 participants

@halostatue

I haven't looked at the how of drake's operations are implemented, but I can see one major problem that needs to be resolved with some form of call or syntax: you can't pass parameters to dependent rake tasks except through #invoke. That is, I just implemented something for rspec-dev (which would benefit from drake because of the number of tests involved, although it would require a larger reorganization to recognize it) that looks like:

task :setup, :binstubs do |t, args|
  Rake::Task['git:clone'].invoke
  Rake::Task['bundle:install'].invoke(args.binstubs)
end

Since most users are going to call rake setup[jruby-bin] but not git:clone and bundle:install[jruby-bin], it becomes important to be able to pass args.binstubs from setup to bundle:install.

There's another problem with the theory of under-specified dependencies, too: one could remove the first call to Rake::Task['git:clone'].invoke by making git:clone a dependency of bundle:install, but it isn't a strict dependent task; it's only a dependent task for the convenience task setup and it must be executed before bundle:install when called from setup, but one could manually prepare the source tree and manually call bundle:install[jruby-bin] without ill effects (which would be important on systems that don't have git available).

@quix
Owner
quix commented Aug 26, 2011

A famous rubyist opens issue #1 :)

Is this a bug in Rake? Shouldn't dependent tasks inherit arguments? This seems to be the intention since TaskArguments recursively checks parents. It works with rules (jimweirich#27) even though the inspect output is deceptive.

I may be misunderstanding something (been a long day) -- I'll look into it sometime this weekend.

@halostatue

You're right about part #1 of this issue (I should have opened two issues, but they're about the same conceptual code). This is not a well-documented facet of Rake, unfortunately. I think I might have to try to help by trying to document this.

task :echo, :message do |t, args|
  args.with_defaults(:message => "Hello, world")
  puts args[:message]
end

task :default, [ :message ] => :echo

Calling default[foo] puts 'foo'.

How do you want to discuss the second part (starting with "There's another problem…"); shall we close this issue and discuss this separately re-framed? I can see how one might address the dependencies (make it such that bundle:install depends on the existence of particular files that could be satisfied by git:clone, but need not be satisfied by git:clone if you wanted to do it manually. That doesn't, however, make the Rakefile easy to scale, whereas the RSpec (rspec/rspec-dev) Rakefile can scale—vertically at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment