Rake TestTask running its block anytime rake is invoked

Discussion in 'Ruby' started by Adam Anderson, Sep 19, 2007.

  1. --
    require 'rake/testtask'

    Rake::TestTask.new do |t|
    chdir './../'
    puts pwd
    end

    desc "print working directory"
    task :pwd do
    puts "Working Directory #{pwd}"
    end
    --

    $ rake -T
    cd ./../
    /Users/scudco/projects
    rake chdir # change directory
    rake test # Run tests

    $ rake chdir
    cd ./../
    /Users/scudco/projects
    Working Directory /Users/scudco/projects


    So the question is why does the chdir in the TestTask get executed every
    time no matter what? It is quite frustrating when code specific to a
    block is being executed for every other task. Any ideas?
    --
    Posted via http://www.ruby-forum.com/.
    Adam Anderson, Sep 19, 2007
    #1
    1. Advertising

  2. --
    require 'rake/testtask'

    Rake::TestTask.new do |t|
    chdir './../'
    puts pwd
    end

    desc "print working directory"
    task :pwd do
    puts "Working Directory #{pwd}"
    end
    --

    $ rake -T
    cd ./../
    /Users/scudco/projects
    rake pwd # print working directory
    rake test # Run tests

    $ rake pwd
    cd ./../
    /Users/scudco/projects
    Working Directory /Users/scudco/projects

    Attachments:
    http://www.ruby-forum.com/attachment/313/Rakefile

    --
    Posted via http://www.ruby-forum.com/.
    Adam Anderson, Sep 19, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. peppermonkey
    Replies:
    1
    Views:
    243
    Gregory Brown
    Feb 10, 2007
  2. gga
    Replies:
    0
    Views:
    81
  3. Michael Barton
    Replies:
    0
    Views:
    109
    Michael Barton
    Feb 14, 2008
  4. Drew Olson
    Replies:
    3
    Views:
    242
    Stefan Lang
    Mar 11, 2008
  5. thunk
    Replies:
    1
    Views:
    307
    thunk
    Mar 30, 2010
Loading...

Share This Page