-----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.
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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkxvAIkACgkQhS0drJ3goJI29QCfUYUwRlUZnTxWahTNjYZWdMad
TAsAn3wHrMrqElk/QuBdfZj1hFnSsjfv
=gAhq
-----END PGP SIGNATURE-----