New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rake test bootstraps two environments #560

Closed
bascht opened this Issue May 26, 2011 · 13 comments

Comments

Projects
None yet
5 participants
@bascht

bascht commented May 26, 2011

Padrino seems to bootstrap the development environment before it starts the tests.

  $ rake test
  => Located unlocked Gemfile for development
  […]
   "/home/vagrant/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.0/lib/rake/rake_test_loader.rb" "test/**/*_test.rb" 
  => Located unlocked Gemfile for test

I am new to Padrino but it feels like it slows down my tests as it takes ~ 5 seconds before he's at Located unlocked Gemfile for test.

Is it a bug or is there some way I can get rid of that?

@ghost ghost assigned DAddYE May 30, 2011

@DAddYE

This comment has been minimized.

Show comment
Hide comment
@DAddYE

DAddYE Jun 6, 2011

Member

Pretty strange... I will look into this. Thanks!

Member

DAddYE commented Jun 6, 2011

Pretty strange... I will look into this. Thanks!

@DAddYE

This comment has been minimized.

Show comment
Hide comment
@DAddYE

DAddYE Jun 6, 2011

Member

I confirm your problem and I've fixed in 0ff2514, basically is super fast to apply the patch edit /test or /spec rakefile and remove first two lines:

PADRINO_ENV = 'test' unless defined?(PADRINO_ENV)
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
Member

DAddYE commented Jun 6, 2011

I confirm your problem and I've fixed in 0ff2514, basically is super fast to apply the patch edit /test or /spec rakefile and remove first two lines:

PADRINO_ENV = 'test' unless defined?(PADRINO_ENV)
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")

@DAddYE DAddYE closed this Jun 6, 2011

@achiu achiu reopened this Jun 8, 2011

@achiu

This comment has been minimized.

Show comment
Hide comment
@achiu

achiu Jun 8, 2011

Member

this probably works on rspec but i don't think you tested this on shoulda, riot, bacon, etc... @davide. Without those two lines it breaks the tests(riot/shoulda for me). @nesquena can also confirm. We need to think of another way to address this double loading issue. @bascht what test suite are you running? did the removal of the lines work for your use case?

Member

achiu commented Jun 8, 2011

this probably works on rspec but i don't think you tested this on shoulda, riot, bacon, etc... @davide. Without those two lines it breaks the tests(riot/shoulda for me). @nesquena can also confirm. We need to think of another way to address this double loading issue. @bascht what test suite are you running? did the removal of the lines work for your use case?

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena Jun 8, 2011

Member

@DAddYE I can confirm if you generate an app like this:

padrino-gen project test_again2 -r /tmp -t shoulda -d activerecord
padrino g model account
padrino ar:migrate -e test
padrino rake test

Things were broken after this fix. We need to figure out a way to prevent it from loading twice that doesn't break shoulda and riot.

Member

nesquena commented Jun 8, 2011

@DAddYE I can confirm if you generate an app like this:

padrino-gen project test_again2 -r /tmp -t shoulda -d activerecord
padrino g model account
padrino ar:migrate -e test
padrino rake test

Things were broken after this fix. We need to figure out a way to prevent it from loading twice that doesn't break shoulda and riot.

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena Jun 8, 2011

Member

Another problem is that even if we bring back test_config for running tests, in padrino rake test we also have it called twice.

So we load at the beginning of "rake" here: https://github.com/padrino/padrino-framework/blob/master/padrino-core/lib/padrino-core/cli/base.rb#L56 so that means its already loaded once at the beginning. If it's done in test_config at all then it will happen twice.

Member

nesquena commented Jun 8, 2011

Another problem is that even if we bring back test_config for running tests, in padrino rake test we also have it called twice.

So we load at the beginning of "rake" here: https://github.com/padrino/padrino-framework/blob/master/padrino-core/lib/padrino-core/cli/base.rb#L56 so that means its already loaded once at the beginning. If it's done in test_config at all then it will happen twice.

@DAddYE

This comment has been minimized.

Show comment
Hide comment
@DAddYE

DAddYE Jun 8, 2011

Member

Arthur will explain u better why, the problem is that we have test gem 'rack/test', :group => :test and when we call boot.rb in cli/base we need to call it with the correct env.

Best Regards,
Davide D'Agostino

Tel. +39 0331 386985
Mobile. +39 349 7079458

Twitter: @DAddYE

http://www.lipsiasoft.com

On mercoledì 8 giugno 2011 at 09.08, nesquena wrote:

Another problem is that even if we bring back test_config for running tests, in padrino rake test we also have it called twice.

So we load at the beginning of "rake" here: https://github.com/padrino/padrino-framework/blob/master/padrino-core/lib/padrino-core/cli/base.rb#L56 so that means its already loaded once at the beginning.

Reply to this email directly or view it on GitHub:
#560 (comment)

Member

DAddYE commented Jun 8, 2011

Arthur will explain u better why, the problem is that we have test gem 'rack/test', :group => :test and when we call boot.rb in cli/base we need to call it with the correct env.

Best Regards,
Davide D'Agostino

Tel. +39 0331 386985
Mobile. +39 349 7079458

Twitter: @DAddYE

http://www.lipsiasoft.com

On mercoledì 8 giugno 2011 at 09.08, nesquena wrote:

Another problem is that even if we bring back test_config for running tests, in padrino rake test we also have it called twice.

So we load at the beginning of "rake" here: https://github.com/padrino/padrino-framework/blob/master/padrino-core/lib/padrino-core/cli/base.rb#L56 so that means its already loaded once at the beginning.

Reply to this email directly or view it on GitHub:
#560 (comment)

@DAddYE

This comment has been minimized.

Show comment
Hide comment
@DAddYE

DAddYE Jun 8, 2011

Member

There is no way to prevent it, @nesquena any idea? Basically

rake foo -> sh 'ruby test/my_test.rb'

Require to load two times bundler, once for bootstrap rake correctly, once to run sh command.

@achiu or @nesquena can u switch back changes? Thx.

Member

DAddYE commented Jun 8, 2011

There is no way to prevent it, @nesquena any idea? Basically

rake foo -> sh 'ruby test/my_test.rb'

Require to load two times bundler, once for bootstrap rake correctly, once to run sh command.

@achiu or @nesquena can u switch back changes? Thx.

@achiu

This comment has been minimized.

Show comment
Hide comment
@achiu

achiu Jun 8, 2011

Member

@DAddYE done. ignore c9f3ed3 as that has been reverted as well.

Member

achiu commented Jun 8, 2011

@DAddYE done. ignore c9f3ed3 as that has been reverted as well.

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena Jun 8, 2011

Member

Ok sounds good, we will leave as is for now... should we close this?

Member

nesquena commented Jun 8, 2011

Ok sounds good, we will leave as is for now... should we close this?

@DAddYE

This comment has been minimized.

Show comment
Hide comment
@DAddYE

DAddYE Jun 8, 2011

Member

Thanks man!

Member

DAddYE commented Jun 8, 2011

Thanks man!

@DAddYE DAddYE closed this Jun 8, 2011

@skade skade reopened this Jan 31, 2013

@skade

This comment has been minimized.

Show comment
Hide comment
@skade

skade Jan 31, 2013

Member

I'd like to reopen this issue, as it is still present and plagues larger padrino installations. Basically, it means that the full framework is loaded twice in a testing environment. My proposed fix would be to add an explicit task that loads that environment that all tasks that need an environment depend upon.

Member

skade commented Jan 31, 2013

I'd like to reopen this issue, as it is still present and plagues larger padrino installations. Basically, it means that the full framework is loaded twice in a testing environment. My proposed fix would be to add an explicit task that loads that environment that all tasks that need an environment depend upon.

@skade

This comment has been minimized.

Show comment
Hide comment
@skade

skade Jan 31, 2013

Member

@ujifgc might be interested in this ;).

Member

skade commented Jan 31, 2013

@ujifgc might be interested in this ;).

@skade

This comment has been minimized.

Show comment
Hide comment
@skade

skade Feb 7, 2013

Member

Closed by #1045

Member

skade commented Feb 7, 2013

Closed by #1045

@skade skade closed this Feb 7, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment