File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -591,10 +591,12 @@ def perform_initial_import
591
591
if file == NO_MANIFEST
592
592
empty_parse_result
593
593
elsif File . directory? ( file )
594
- parse_results = Puppet ::FileSystem ::PathPattern . absolute ( File . join ( file , '**/*.pp' ) ) . glob . sort . map do | file_to_parse |
595
- parser . file = file_to_parse
596
- parser . parse
597
- end
594
+ # JRuby does not properly perform Dir.glob operations with wildcards, (see PUP-11788 and https://github.com/jruby/jruby/issues/7836).
595
+ # We sort the results because Dir.glob order is inconsistent in Ruby < 3 (see PUP-10115).
596
+ parse_results = Puppet ::FileSystem ::PathPattern . absolute ( File . join ( file , '**/*' ) ) . glob . select { |globbed_file | globbed_file . end_with? ( '.pp' ) } . sort . map do | file_to_parse |
597
+ parser . file = file_to_parse
598
+ parser . parse
599
+ end
598
600
# Use a parser type specific merger to concatenate the results
599
601
Puppet ::Parser ::AST ::Hostclass . new ( '' , :code => Puppet ::Parser ::ParserFactory . code_merger . concatenate ( parse_results ) )
600
602
else
Original file line number Diff line number Diff line change 1
1
require 'spec_helper'
2
2
require 'puppet_spec/files'
3
3
require 'puppet/file_system'
4
+ require 'puppet/util'
4
5
5
6
describe Puppet ::FileSystem ::PathPattern do
6
7
include PuppetSpec ::Files
132
133
File . join ( dir , "found_two" ) ] )
133
134
end
134
135
136
+ it 'globs wildcard patterns properly' do
137
+ # See PUP-11788 and https://github.com/jruby/jruby/issues/7836.
138
+ pending 'JRuby does not properly handle Dir.glob' if Puppet ::Util ::Platform . jruby?
139
+
140
+ dir = tmpdir ( 'globtest' )
141
+ create_file_in ( dir , 'foo.pp' )
142
+ create_file_in ( dir , 'foo.pp.pp' )
143
+
144
+ pattern = Puppet ::FileSystem ::PathPattern . absolute ( File . join ( dir , '**/*.pp' ) )
145
+
146
+ expect ( pattern . glob ) . to match_array ( [ File . join ( dir , 'foo.pp' ) ,
147
+ File . join ( dir , 'foo.pp.pp' ) ] )
148
+ end
149
+
135
150
def create_file_in ( dir , name )
136
151
File . open ( File . join ( dir , name ) , "w" ) { |f | f . puts "data" }
137
152
end
You can’t perform that action at this time.
0 commit comments