rvm / pluginator

A simple plugin system based on Gem.find_files
GNU Lesser General Public License v3.0
34 stars 8 forks source link

error running tests #14

Open logicminds opened 7 years ago

logicminds commented 7 years ago

I can't seem to run these tests locally. Am I missing something?

docker run -ti --rm -w /app -v ${PWD}:/app ruby:2.3 bash
root@48f9b6ff0907:/app# bundle install
Fetching gem metadata from https://rubygems.org/.............
Fetching version metadata from https://rubygems.org/.
Installing rake 12.0.0
Installing ansi 1.5.0
Installing ast 2.3.0
Installing builder 3.2.3
Installing minitest 5.10.2
Installing ruby-progressbar 1.8.1
Installing parallel 1.11.2
Using pluginator 1.5.0 from source at `.`
Installing powerpack 0.1.1
Installing unicode-display_width 1.2.1
Using bundler 1.14.6
Installing rainbow 2.2.2 with native extensions
Installing parser 2.4.0.0
Installing minitest-reporters 1.1.14
Installing rubocop 0.49.1
Bundle complete! 5 Gemfile dependencies, 15 gems now installed.
Bundled gems are installed into /usr/local/bundle.
root@48f9b6ff0907:/app# rake
/usr/local/bin/ruby -w -I"lib:test" -I"/usr/local/bundle/gems/rake-12.0.0/lib" "/usr/local/bundle/gems/rake-12.0.0/lib/rake/rake_test_loader.rb" "test/pluginator/autodetect_test.rb" "test/pluginator/extendable_autodetect_test.rb" "test/pluginator/group_test.rb" "test/pluginator/name_converter_test.rb" "test/pluginator_test.rb" "test/plugins_test/extensions/class_exist_test.rb" "test/plugins_test/extensions/conversions_test.rb" "test/plugins_test/extensions/first_ask_test.rb" "test/plugins_test/extensions/first_class_test.rb" "test/plugins_test/extensions/matching_test.rb" "test/plugins_test/extensions/plugins_map_test.rb"
/app/lib/pluginator/autodetect.rb:25:in `<module:Pluginator>': superclass mismatch for class Autodetect (TypeError)
    from /app/lib/pluginator/autodetect.rb:24:in `<top (required)>'
    from /app/test/test_helper.rb:70:in `require'
    from /app/test/test_helper.rb:70:in `block in <top (required)>'
    from /app/test/test_helper.rb:70:in `each'
    from /app/test/test_helper.rb:70:in `<top (required)>'
    from /app/test/pluginator/autodetect_test.rb:20:in `require'
    from /app/test/pluginator/autodetect_test.rb:20:in `<top (required)>'
    from /usr/local/bundle/gems/rake-12.0.0/lib/rake/rake_test_loader.rb:15:in `require'
    from /usr/local/bundle/gems/rake-12.0.0/lib/rake/rake_test_loader.rb:15:in `block in <main>'
    from /usr/local/bundle/gems/rake-12.0.0/lib/rake/rake_test_loader.rb:4:in `select'
    from /usr/local/bundle/gems/rake-12.0.0/lib/rake/rake_test_loader.rb:4:in `<main>'
rake aborted!
Command failed with status (1): [ruby -w -I"lib:test" -I"/usr/local/bundle/gems/rake-12.0.0/lib" "/usr/local/bundle/gems/rake-12.0.0/lib/rake/rake_test_loader.rb" "test/pluginator/autodetect_test.rb" "test/pluginator/extendable_autodetect_test.rb" "test/pluginator/group_test.rb" "test/pluginator/name_converter_test.rb" "test/pluginator_test.rb" "test/plugins_test/extensions/class_exist_test.rb" "test/plugins_test/extensions/conversions_test.rb" "test/plugins_test/extensions/first_ask_test.rb" "test/plugins_test/extensions/first_class_test.rb" "test/plugins_test/extensions/matching_test.rb" "test/plugins_test/extensions/plugins_map_test.rb" ]
/usr/local/bundle/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => default => test
(See full trace by running task with --trace)
mpapis commented 7 years ago

try ruby -I lib:test test/pluginator/autodetect_test.rb

logicminds commented 7 years ago

https://github.com/rvm/pluginator/blob/master/lib/pluginator/autodetect.rb#L24

What is the purpose of doing this as I think it is causing the error above.

mpapis commented 7 years ago

For me it fixed the same problem... I do not see Autodetect being defined anywhere earlier, does it also happen on master?

mpapis commented 7 years ago

to show what problem I'm solving with it I put up this example test.rb:

test.rb 
class A ; end

# Example 1 - how it's written now, first definition, then used as namespace
class B < A ; end
class B
  class C ; end
end

# Example 2 - what happens if we require first, then define class
class D
  class E; end
end
class D < A ; end

Running it yields this:

# ruby test.rb 
test.rb:13:in `<main>': superclass mismatch for class D (TypeError)

It is necessary to define the class with inheritance before we can use it as namespace, especially if we want to use it in other file.

mpapis commented 7 years ago

can you check with #16 (https://github.com/rvm/pluginator/blob/bugfix/ensure-order-of-loading-files-in-tests/test/test_helper.rb#L71)