What is the purpose of test_files configuration in a gemspec

浪子不回头ぞ 提交于 2020-07-18 08:42:27

问题


The RubyGems Specification Reference says:

A collection of unit test files. They will be loaded as unit tests when the user requests a gem to be unit tested.

However there is no gem test command, and unlike the files config which is used in the packaging, I don't see any obvious place this is used. Google also seems not to turn up anything.

Is there any point for specifying test_files in a gem?


回答1:


I've been trying to find an answer to this as well, and while I haven't turned up a definitive "don't use test_files" it seems that support has been somewhat deprecated.

From what I can tell, the answer to your question is "it depends". There are some points to specifying test_files, but they might not be what you expect/want:

  1. From a test perspective, rubygems doesn't seem to do anything as far as running the test files specified.
  2. From a packaging standpoint, they will be installed, which may or may not be useful for an end user.

Some references:

  • An open Issue #735 to not install test_files, deferred to a post-2.x RubyGems release due to 'backward compatibility'
  • Commit 429f88... in the RubyGems github repo, which removed code that tests gems (included back in v1.5.0)
  • A closed Bug #27507 to remove -t from gem install (it was removed after some discussion included in the bug)


来源:https://stackoverflow.com/questions/18871541/what-is-the-purpose-of-test-files-configuration-in-a-gemspec

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!