[Rake-devel] Setting the description using a constructor

Daniel Berger djberg96 at gmail.com
Thu Nov 9 10:09:08 EST 2006

On 11/8/06, Jim Weirich <jim at weirichhouse.org> wrote:
> Daniel Berger said:
> > Hi,
> >
> > I noticed that if I create a task using a constructor, the description
> > doesn't seem to get picked up:
> >
> > desc "This is Dan's test"
> > Rake::TestTask.new do |t|
> >    # stuff here
> > end
> Ahh, that is because TestTask, despite its name, is not really a task
> object.  Rather it is a suite of tasks that are created under the control
> of the TestTask object.  You can think of it as a macro that creates a
> bunch of tasks with related dependencies. I've been wanting to rename it
> for some time, but haven't found quite the right terminology yet (suite is
> one contender).
> So the desc lines are defined within the TestTask object and aren't
> exposed to the end user unless the author took explicit action to make it
> so.

TestSuiteTask sounds better. :)

The reason I ask is that sometimes I want to setup two different test tasks,
with each task passing slightly different parameters or running a different
test case.  But, each test case would have the same general setup that a
TestTask creates, i.e push the "test" directory on the $LOAD_PATH, etc.

I'm trying to think how this would look.  Here's one idea:

TestSuiteTask.new do |ts|
   ts.libs << "test"

   ts.test.new(:test_18) do |tc|
      tc.desc "Tests for the 1.8 branch"
      tc.files = FileList["test/tc_18*"]

   ts.test.new(:test_19) do |tc|
      tc.desc "Tests for the 1.9 branch"
      tc.files = FileList["test/tc_19*"]

How does something like that look?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rake-devel/attachments/20061109/8d4c1f2a/attachment.html 

More information about the Rake-devel mailing list