“rake test”的问题rake 报告“找不到任务 ./test/whatever-my-first-test-file-is.rb”

发布于 2024-09-12 10:48:35 字数 1699 浏览 4 评论 0原文

我已将此信息放入粘贴中,但在此处重复(粘贴链接 http://pastie.org/private /4vprzwhllqv35egrf8jzwg

问题出现在我自己的项目中,但我不知道我做错了什么:这是完整的输出:

$ rake test

(in /Users/me/Projects/version-three)
/Users/me/.rvm/rubies/ruby-1.9.2-rc2/bin/ruby -I"lib:test" "/Users/me/.rvm/gems/ruby-1.9.2-rc2/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "./test/test_a.rb" "./test/test_configuration.rb" "./test/test_generator_base.rb" "./test/test_lazy_attr_accessor.rb" "./test/test_output_spokesman.rb" "./test/test_path_for_executable.rb" 
Test run options: --seed 28629

Loaded suite /Users/me/.rvm/gems/ruby-1.9.2-rc2/gems/rake-0.8.7/lib/rake/rake_test_loader
Started

...............Could not find task "./test/test_a.rb".
......

Finished in 0.014943 seconds.

21 tests, 19 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 28629

如您所见,有一个错误的无法找到任务”。 /test/test_a.rb" - 我添加此文件只是为了防止它在我的第一个文件中因重要测试而阻塞!

Rakefile 再简单不过了,就是这样:

require 'rake/testtask'

task :default => :test

Rake::TestTask.new do |t|
  t.libs << "test"
  t.test_files = FileList['./test/test_*.rb']
  t.verbose = true
end

我正在使用以下版本的相关工具,如您所见,我正在使用 RVM,并且我在 Ruby 1.8.7 上看到了同样的问题。

$ rake --version
  rake, version 0.8.7

$ ruby --version
  ruby 1.9.2dev (2010-07-11 revision 28618) [x86_64-darwin10.4.0]

$ rvm --version
  rvm 0.1.43 by Wayne E. Seguin ([email protected]) [http://rvm.beginrescueend.com/]

I've put this information into a pastie, but repeated it here (pastie link http://pastie.org/private/4vprzwhllqv35egrf8jzwg )

The problem showed up in my own project, but I have no idea what i'm doing wrong: here's the full output:

$ rake test

(in /Users/me/Projects/version-three)
/Users/me/.rvm/rubies/ruby-1.9.2-rc2/bin/ruby -I"lib:test" "/Users/me/.rvm/gems/ruby-1.9.2-rc2/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" "./test/test_a.rb" "./test/test_configuration.rb" "./test/test_generator_base.rb" "./test/test_lazy_attr_accessor.rb" "./test/test_output_spokesman.rb" "./test/test_path_for_executable.rb" 
Test run options: --seed 28629

Loaded suite /Users/me/.rvm/gems/ruby-1.9.2-rc2/gems/rake-0.8.7/lib/rake/rake_test_loader
Started

...............Could not find task "./test/test_a.rb".
......

Finished in 0.014943 seconds.

21 tests, 19 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 28629

As you can see there is an erroneous Could not find task "./test/test_a.rb" - I added this file simply to stop it choking on my first file with important tests!

The Rakefile couldn't be simpler, just this:

require 'rake/testtask'

task :default => :test

Rake::TestTask.new do |t|
  t.libs << "test"
  t.test_files = FileList['./test/test_*.rb']
  t.verbose = true
end

I'm using the following versions of relevant tools, as you can see I'm using RVM and I see the same problem on Ruby 1.8.7.

$ rake --version
  rake, version 0.8.7

$ ruby --version
  ruby 1.9.2dev (2010-07-11 revision 28618) [x86_64-darwin10.4.0]

$ rvm --version
  rvm 0.1.43 by Wayne E. Seguin ([email protected]) [http://rvm.beginrescueend.com/]

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

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

发布评论

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

评论(1

峩卟喜欢 2024-09-19 10:48:35

看来这个问题是在需要雷神时出现的——据说这是一个耙子替代品——也许我需要更多地研究它,但我的一个测试是测试雷神支持的发电机。

我会更彻底地调查发生了什么!

我已经确定了(愚蠢的)问题,该消息实际上来自 Thor,我有一行内容如下:

  def test_banner_if_starting_generator_with_no_args
    ::Cli::Generator.start(ARGV)
    # Test the banner output here...
  end

当然 ARGV 被设置为由 Rake 的 FileList 组装的列表中的第一个文件,并传递给测试加载器。

很抱歉浪费了任何研究此问题的人的时间。

解决方案:将 ARGV 存根为 [],因为这实际上是我正在测试的内容!

It appears this problem comes up when requiring Thor - it's a rake replacement, supposedly - perhaps I need to look into it more, but one of my tests was testing a Thor backed generator.

I'll look into what's going on more thoroughly!

I have identified the (foolish) problem, the message is actually coming out of Thor, I had a line that read like:

  def test_banner_if_starting_generator_with_no_args
    ::Cli::Generator.start(ARGV)
    # Test the banner output here...
  end

And of course ARGV was being set to the first file in the list assembled by Rake's FileList and passed to the test loader.

Sorry for wasting anyone's time who looked into this.

Solution: stub the ARGV to [] since that's effectively what I'm testing!

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