gemspec should accept a glob option in its argument hash #3464
Conversation
Thanks for the contribution! Unfortunately there is a failing spec (I think because it's now passing other options from Also, would you be able to update the man page for Gemfile with the new option? Thanks! |
Thanks for willingness to accept it. Interesting, it complained of a "development_group" not being listed as an allowed option, but my I added it (+ran the options through sort) an it's green now. The last commit only documents the new option in the man page so it should be green too. |
I don't think that's the right way to fix this. |
Done |
@@ -42,6 +42,7 @@ def eval_gemfile(gemfile, contents = nil) | |||
|
|||
def gemspec(opts = nil) | |||
path = opts && opts[:path] || '.' | |||
glob = opts && opts[:glob] #|| nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why || nil
is commented out?
maybe we should remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes it look symmetrical with the rest of the column, but is not really needed. I can remove it or uncomment it, whatever you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it is not necessary I would remove it.
Because I don't know how else to make travis-ci retry my pull request, which it errored out on.
All green. Kind of fragmented, but |
I think we need to add tests for this new option. |
Squashed here (gemspec_options2 branch): |
As for the test, this patch doesn't really do much -- the glob option already exists underneath. This only allows it to be accessed via the Building upon describe "bundle install with explicit globs" do
it "supports gemspec syntax with an explicit glob" do
build_lib "foo", "1.0", :path => lib_path("foo") do |s|
s.add_dependency "rack", "1.0"
end
expect(Dir).to receive(:[]).with('*.gemspec')
install_gemfile <<-G
source "file://#{gem_repo1}"
gemspec :path => "#{lib_path("foo")}", :glob => '*.gemspec'
G
end
end This would, however, require rspec-mocks. I'm not really that familiar with bundler's codebase to do it without it. |
@pjump the test looks good. |
While you won't be able to use |
Most of the existing tests in Bundler are end-to-end integration tests, and I think we'd want at least two of those to verify that the feature works as intended and isn't broken by future changes:
|
gemspec should accept a glob option in its argument hash
This allows a glob option for gemspec to pass through.
An example case for when this is useful would be a lazy static test suite where running
bundle exec rake test
for a second time is a no-op and changing some source files will only cause its dependent test to be rerun on the nextbundle exec test
. That can be done by mapping test outputs to textfiles such as something_test.rb.txt (mainly for the timestamp ) and a) keeping file dependencies of tests explicitly in rake/make/whatever b) plugging in a build system like tup or fabricate.py, which handles such dependencies implicitly by tracking file reads that take place during each build (build = test run). This can be a huge time-saver for repos with large test-suites that take a long time, especially if the tests onlyrequire
the part of the app they really need.Therein is a problem with the current bundler implementation without this patch. In a repo that has a Gemfile with a gemspec in it, running bundle exec to invoke a test will cause a call to Dir'{,,*}.gemspec', which will recursively scan the whole repo for more gemspec files. Since
bundle exec
would be used to invoke each test, this would make, in the eyes of build system that track file reads, each test dependent on every other file (it does for tup, anyway). Allowing the glob option to pass through and giving it a value of '*.gemspec' solves this problem, and it's only a small change to the codebase for that can be used to save a lot of wasted CPU time.