尝试使用nailgun 和 spork 让我的 rspec 1.2 测试在 JRuby 和 Rails 2.3.10 上运行得更快时出错

发布于 2024-11-07 18:09:15 字数 3527 浏览 0 评论 0原文

我最近开始在我的 Rails 2.3 Web 应用程序中使用 JRuby。从那时起,我的 rspec 测试一直缓慢……自从我切换到 JRuby 以来,测试运行时间太长。

在使用 MRI 时,我从来没有费心使用 spork 来更快地运行测试,但现在我需要加快测试的执行速度。

首先尝试了spork,但是没有成功,因为:

  1. spork 0.9 RC支持jruby,但不支持rails 2.3 (它只支持rails 3
  2. spork 0.8支持rails 2.3,但不支持jruby我认为它使用fork() 时,spork-0.8 gem 不会发生 安装在jruby上)。

我尝试在 jrubyrails 2.3spork 0.9 rc 上运行测试,但没有成功,实际上有一个警告消息说 spork 0.9 rc 仅支持 rails >= 3.0

然后我尝试了nailgun,我在我的jruby环境中安装了nailgun gem (gem installnailgun strong>)并启动了nailgun服务器(ruby --ng-server 在我的应用程序的根目录下)。 然后我运行我的规范之一(ruby --ng -S spec spec/lib/importacao_atividades_spec.rb)。我第一次执行规范时,一切顺利,但之后它不断引发 RuntimeError: invalid runtime

检查跟踪:

RuntimeError: invalid runtime
       require at org/jruby/RubyKernel.java:1038
       require at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/activesupport-2.3.10/lib/active_support/dependencies.rb:184
        (root) at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/mysql-2.8.1/lib/mysql.rb:3
       require at org/jruby/RubyKernel.java:1038
       require at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/mysql-2.8.1/lib/mysql.rb:68
          each at org/jruby/RubyArray.java:1602
       require at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:66
          each at org/jruby/RubyArray.java:1602
       require at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:55
       require at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/bundler-1.0.12/lib/bundler.rb:120
     load_gems at /Users/razenha/Projects/Pro/portaltrademarketing/config/boot.rb:116
       process at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/rails-2.3.10/lib/initializer.rb:164
          send at org/jruby/RubyKernel.java:2052
           run at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/rails-2.3.10/lib/initializer.rb:113
        (root) at /Users/razenha/Projects/Pro/portaltrademarketing/config/environment.rb:12
       require at org/jruby/RubyKernel.java:1038
       require at /Users/razenha/.rvm/rubies/jruby-1.6.1/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29
        (root) at /Users/razenha/Projects/Pro/portaltrademarketing/config/environment.rb:47
       require at org/jruby/RubyKernel.java:1038
       require at /Users/razenha/.rvm/rubies/jruby-1.6.1/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29
        (root) at /Users/razenha/Projects/Pro/portaltrademarketing/spec/spec_helper.rb:1
          load at org/jruby/RubyKernel.java:1063
    load_files at ./spec/lib/importacao_atividades_spec.rb:15
          each at org/jruby/RubyArray.java:1602
    load_files at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb:14
  run_examples at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/rspec-1.2.9/lib/spec/runner/options.rb:132
           run at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/rspec-1.2.9/lib/spec/runner/command_line.rb:9
        (root) at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/rspec-1.2.9/bin/spec:5
          load at org/jruby/RubyKernel.java:1063
        (root) at /Users/razenha/.rvm/gems/jruby-1.6.1/bin/spec:19

所以我真的被困在这里了。有人知道如何解决钉枪问题吗?如果没有,还有其他选择吗? jruby和rails 2.3中可以使用spork吗?

I recently start using JRuby in my Rails 2.3 webapp. Since then, I have been experiencing slowness in my rspec tests... the test are taking too long to run since I switched to JRuby.

While using MRI, I never bothered to use spork in order to run my tests faster, but now I need to speed up the execution of my test.

First, I tried spork, but I did't worked out because:

  1. spork 0.9 RC supports jruby, but does not support rails 2.3
    (it only supports rails 3)
  2. spork 0.8 supports rails 2.3, but does not support jruby I think it uses fork(), the spork-0.8 gem won't event
    install on jruby).

I tried to run my tests on jruby, rails 2.3 and spork 0.9 rc, but it didn't worked, in fact there was a warning message saying that spork 0.9 rc only supports rails >= 3.0

Then I tried nailgun, I installed the nailgun gem in my jruby environment (gem install nailgun) and started the nailgun server (ruby --ng-server at the root of my app).
Then I run one of my specs (ruby --ng -S spec spec/lib/importacao_atividades_spec.rb). The first time I executed the spec, it went just fine, but after that it kept raising RuntimeError: invalid runtime

Check the trace:

RuntimeError: invalid runtime
       require at org/jruby/RubyKernel.java:1038
       require at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/activesupport-2.3.10/lib/active_support/dependencies.rb:184
        (root) at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/mysql-2.8.1/lib/mysql.rb:3
       require at org/jruby/RubyKernel.java:1038
       require at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/mysql-2.8.1/lib/mysql.rb:68
          each at org/jruby/RubyArray.java:1602
       require at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:66
          each at org/jruby/RubyArray.java:1602
       require at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/bundler-1.0.12/lib/bundler/runtime.rb:55
       require at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/bundler-1.0.12/lib/bundler.rb:120
     load_gems at /Users/razenha/Projects/Pro/portaltrademarketing/config/boot.rb:116
       process at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/rails-2.3.10/lib/initializer.rb:164
          send at org/jruby/RubyKernel.java:2052
           run at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/rails-2.3.10/lib/initializer.rb:113
        (root) at /Users/razenha/Projects/Pro/portaltrademarketing/config/environment.rb:12
       require at org/jruby/RubyKernel.java:1038
       require at /Users/razenha/.rvm/rubies/jruby-1.6.1/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29
        (root) at /Users/razenha/Projects/Pro/portaltrademarketing/config/environment.rb:47
       require at org/jruby/RubyKernel.java:1038
       require at /Users/razenha/.rvm/rubies/jruby-1.6.1/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29
        (root) at /Users/razenha/Projects/Pro/portaltrademarketing/spec/spec_helper.rb:1
          load at org/jruby/RubyKernel.java:1063
    load_files at ./spec/lib/importacao_atividades_spec.rb:15
          each at org/jruby/RubyArray.java:1602
    load_files at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb:14
  run_examples at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/rspec-1.2.9/lib/spec/runner/options.rb:132
           run at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/rspec-1.2.9/lib/spec/runner/command_line.rb:9
        (root) at /Users/razenha/.rvm/gems/jruby-1.6.1/gems/rspec-1.2.9/bin/spec:5
          load at org/jruby/RubyKernel.java:1063
        (root) at /Users/razenha/.rvm/gems/jruby-1.6.1/bin/spec:19

So I am really stuck here. Anyone know how can I fix the nailgun issue? If not, is there an alternative? Is it possible to use spork in jruby and rails 2.3?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

分分钟 2024-11-14 18:09:15

哦...看起来 jruby 不喜欢旧版本的 Redis gem。更新了我的 Resque/Redis gem 版本并且它起作用了。

Oh... Looks like jruby does not like an older version of the Redis gem. Updated my Resque/Redis gem version and it worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文