为什么测试在生产模式下运行并导致我的脚本/运行器失败?

Jer*_*ise 2 ruby-on-rails

所以我在cron作业中设置了一些脚本/运行器,但根据日志,我在下面收到此错误.首先,我不确定为什么Test :: Unit自动转轮开始在生产中发生.我没有自动测试或自动测试.其次,我不知道如何解决这个讨厌的无效选项错误.我正在使用javan -never gem来处理cron计划.有帮助吗?

0 tests, 0 assertions, 0 failures, 0 errors

invalid option: -e
Test::Unit automatic runner.
Usage: /apps/ion/releases/20091210210633/script/runner [options] [-- untouched arguments]

-r, --runner=RUNNER              Use the given RUNNER.
                                 (c[onsole], f[ox], g[tk], g[tk]2, t[k])
-n, --name=NAME                  Runs tests matching NAME.
                                 (patterns may be used).
-t, --testcase=TESTCASE          Runs tests in TestCases matching TESTCASE.
                                 (patterns may be used).
-I, --load-path=DIR[:DIR...]     Appends directory list to $LOAD_PATH.
-v, --verbose=[LEVEL]            Set the output level (default is verbose).
                                 (s[ilent], p[rogress], n[ormal], v[erbose])
    --                           Stop processing options so that the
                                 remaining options will be passed to the
                                 test.
-h, --help                       Display this help.

Deprecated options:
    --console                    Console runner (use --runner).
    --gtk                        GTK runner (use --runner).
    --fox                        Fox runner (use --runner).
Run Code Online (Sandbox Code Playgroud)

Bra*_*dan 5

这是因为您的环境中需要一些东西Test::Unit.我rails runner在Rails 3.1.0应用程序中运行时遇到了同样的问题,这是因为我们gem test-unit的Gemfile中包含所有组,而不仅仅是实际需要的测试组.一旦我将其移入测试组,我的跑步者就按预期跑了.

这段代码似乎是罪魁祸首:

# test_unit/lib/test/unit.rb
at_exit do
  unless $! || Test::Unit.run?
    exit Test::Unit::AutoRunner.run
  end
end
Run Code Online (Sandbox Code Playgroud)

如果您无法删除该要求Test::Unit,则可以在您的环境中的某处添加此hack以防止AutoRunner自动运行:

Test::Unit.run = true
Run Code Online (Sandbox Code Playgroud)