-
-
Notifications
You must be signed in to change notification settings - Fork 942
Description
Suppose we have a jar with following files:
$ jar tf foo.jar
META-INF/
META-INF/MANIFEST.MF
foo/bar.txt
Dir["file:/.../foo.jar!/**/*"] will report correctly all three entries, whereas Dir.glob("file:/.../foo.jar!/**/*") will skip over foo/bar.txt
The reason Dir[] works is that RubyDir.aref uses special logic for jars to convert glob into a regex: https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/RubyDir.java#L209
The reason Dir.glob doesn't work is because it delegates control to MRI-style Dir.push_glob which descends into a directory only if it exists, and file:/.../foo.jar!foo/ does not exist.
To add insult to injury, https://github.com/jruby/jruby/blob/master/spec/java_integration/utilities/jar_glob_spec.rb is supposed to test this behavior, but it overrides Dir.glob that it is supposed to test, so it happily passes although implementation is broken.
Things to do:
-
Fix the jar_glob_spec.rb test to behave properly.
-
Fix the test.
As far fixing the test goes, I'm going to remove the jar specific logic from RubyDir in favor of making Dir.push_glob use FileResources as part of the #1452 effort. This should fix the issue, since JarDirectoryResource("foo/") will exist, allowing the logic to descend properly. If for some reason that won't work out (or we'd like the build fixed sooner) I could also try to refactor RubyDir.glob to perform the jar-specific logic of RubyDir.aref, and have RubyDir.aref invoke glob(..., 0) like it should.