On Fri, 2006-03-10 at 08:29 +0900, Daniel N. wrote:
Is there a way to pass Rake tasks arguments?
You can do the easy way:
$ cat Rakefile
task :default do
$ rake SOMEVAR=321
Another sneaky thing I’ve done before when embedding rake in other stuff
is to have a task that creates a Rake rule that matches everything, so
that all arguments following that task are grabbed by that rule.
task :create do
rule '' do |t|
argument_passed = t.name
# do stuff with argument...
This is only good when you don’t want to have further tasks on the same
commandline, but works pretty nice in some cases e.g.
rake create myproject
I’d like to do something where I break my unit tests up into test
suites by just dropping them into folders and then being able to
invoke a Rake task like rake suite “sweet” or rake suite
“sweet/saccharine”, if I wanted a test suite inside of a test suite.
Or, alternatively, I’d like to be able to invoke test cases named
“sucrose” by rake test_case “sucrose”
The Rake test-task lets you specify the name for the task, so it’s
pretty easy to split up your tests into groups in the Rakefile by simply
defining separate tasks for e.g. functional and unit tests. I often have
a couple of separate tasks, with a single task bringing them together
via task dependencies as an :alltest task.
Also, as others have mentioned, testrb is pretty handy for this stuff:
$ testrb tests/tc*.rb -n ‘/test_ruby_xml.*/’
47 tests, 339 assertions, 0 failures, 0 errors
$ testrb tests/tc*.rb -n ‘/test_ruby_xml_document.*/’
15 tests, 129 assertions, 0 failures, 0 errors
(output trimmed for brevity)