Rails 测试系统堆栈错误
Posted
技术标签:
【中文标题】Rails 测试系统堆栈错误【英文标题】:Rails Testing System Stack Error 【发布时间】:2010-04-14 14:14:44 【问题描述】:我在暂停后继续测试我的 rails 应用程序。现在在我的 rails 应用程序上运行测试会返回 SystemStackError。即使是像
这样的简单测试def test_per_page
assert_instance_of Fixnum, Activity.per_page
结束
给我
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/m odule/introspection.rb:74:in `local_constants': 堆栈级别太深(SystemStac 错误)
from C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/module/introspection.rb:73:in `select'
from C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/module/introspection.rb:73:in `local_constants'
from C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/module/introspection.rb:86:in `local_constant_names'
from C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:531:in `new_constants_in'
from C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:525:in `collect'
from C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:525:in `new_constants_in'
from C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
from C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails/plugin/locator.rb:89:in `plugins'
... 12095 levels...
from ./unit/../test_helper.rb:2
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from unit/my_test.rb:1
我发现我们已经安装并删除了 test-unit gem。即使在那之后,同样的问题不断出现。我在使用 rcov 的同时也安装了 rcov 和同样的东西..
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/specification.rb:666:in `hash': 堆栈级别太深 (SystemStackError)
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `inject'
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/specification.rb:664:in `each'
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/specification.rb:664:in `inject'
from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/specification.rb:664:in `hash'
from C:/Ruby/lib/ruby/1.8/tsort.rb:219:in `[]='
from C:/Ruby/lib/ruby/1.8/tsort.rb:219:in `each_strongly_connected_component_from'
from C:/Ruby/lib/ruby/1.8/tsort.rb:219:in `each'
from C:/Ruby/lib/ruby/1.8/tsort.rb:219:in `each_strongly_connected_component_from'
... 12099 levels...
from C:/Ruby/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0-x86-mswin32/bin/rcov:554:in `load'
from C:/Ruby/lib/ruby/gems/1.8/gems/rcov-0.8.1.2.0-x86-mswin32/bin/rcov:554
from C:/Ruby/bin/rcov:19:in `load'
from C:/Ruby/bin/rcov:19
以前有没有人遇到过这样的事情..我知道 gem require 被一遍又一遍地调用..有没有办法解决这个问题?
【问题讨论】:
我尝试创建一个新项目并在同一系统上编写一个简单的单元测试,它就像一个魅力......所以我猜问题出在我安装的一个插件上。 .而且每次我开始运行测试时,这个警告首先出现.. C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails/gem_dependency.rb:99:Warning: Gem:: Dependency#version_requirements 已弃用,并将在 2010 年 8 月或之后删除。使用 #requirement 我使用 gem update --system 更新了 gem,但仍然给我同样的错误。提前感谢所有帮助... 【参考方案1】:哎呀!当环境启动时,我有两个为 rcov 运行的初始化程序。一个在 environment.rb 文件中,另一个在 config 文件夹的 env 子文件夹中的单独的 test.rb 文件中。所以它一直在不断地循环下去。无论如何问题都解决了,地球还在旋转。
谢谢
【讨论】:
以上是关于Rails 测试系统堆栈错误的主要内容,如果未能解决你的问题,请参考以下文章
Rails:ExecJS :: ProgramError:RangeError:超出最大调用堆栈大小
ArgumentError:升级 Rails 6.1.3 时出现错误数量的参数错误