"rake test" broken after upgrade to 1.9.2 (NameError)

Hello List,

I've got a quite deep class and directory hierarchy. It worked perfectly
well with Ruby 1.9.1, but after the upgrade to 1.9.2 it ceased working.
However, it is not the app itself that gets killed, but "rake test".

This is my directory structure:

- ---%<---
./Rakefile
./src/gnyu
./src/gnyu/gnyubuild.rb
./src/gnyubuild*
./src/gnyu/gnyubuild
./src/gnyu/gnyubuild/mode.rb
./src/gnyu/gnyubuild/mode
./src/gnyu/gnyubuild/mode/repository.rb
./src/gnyu/config.rb
- --->%---

Along with a mirrored structure under test/ instead of src, which contain
the corresponding unit tests.

Now if I changed to src/ and run "ruby -I. ./gnyubuild", it works out fine.
However, running "rake test" fails:

- ---%<---
/usr/bin/ruby -I"lib:src" "/usr/lib/ruby/1.9.1/rake/rake_test_loader.rb"
"test/unit/gnyu/test_config.rb" "test/unit/gnyu/gnyubuild/test_mode.rb"
/home/eveith/Development/GNyU/gnyubuild/src/gnyu/gnyubuild/mode/repository.rb:16:in
`<module:GNyU>': uninitialized constant GNyU::GNyUBuild::Mode (NameError)
# ...
- --->%---

The definitions of the constants are made in the corresponding files, all
enclosed in a "module GNyU; ... ; end" definition. So, e.g., GNyU::Config
has the following preamble:

- ---%<---
module GNyU
  class GNyU::Config
    # ...
  end
end
- --->%---

Plus, I use "require" to load the super-class, e.g.
GNyU::GNyUBuild::Mode::Repository has a "require 'gnyu/gnyubuild/mode'" in
it.

The ./src/gnyu/gnyubuild.rb file does not only house the definition of the
GNyU::GNyUBuild class, but also serves as a mediator. That is, it loads and
initializes the different "mode classes", and as such has statements along
the lines of "require 'gnyu/gnyubuild/mode/repository'" in it. Removing it
immediately causes the tests to run smoothly again.

The question now is: Why are the tests failing, while a "normal" run of the
software works? Is there some sort of "circular name resolution" thingy that
kills me?

Thanks in advance for all answers. Let me know if you need some
clarification.

      Eric

It's probably the removal of "." from the load path. Try adding

$: << "."

at the start of your rakefile and see if that helps matters.

martin

···

On Sat, Aug 21, 2010 at 3:54 AM, Eric MSP Veith <eveith@wwweb-library.net> wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello List,

I've got a quite deep class and directory hierarchy. It worked perfectly
well with Ruby 1.9.1, but after the upgrade to 1.9.2 it ceased working.

Martin,

thanks for your answer!

It's probably the removal of "." from the load path. Try adding

Naw, it's not. The rake TestTask already adds the "src" subdirectory to
ruby's include path, and adding "." doesn't bring any benefit. (Rakefile
lies in the top project directory, tests are in the "test" sub-directory,
and the actual sources reside in "src").

I'm beginning to doubt that is has anything to do with $: at all (or the
upgrade to 1.9.2 for this matter), but may be a sheer problem of my layout
of the sources. Can anybody confirm this?

      Eric

···

On Friday 20 August 2010, Martin DeMello <martindemello@gmail.com> wrote: