Skip to content

Commit

Permalink
Update JRuby in tests to 9.4.7.0
Browse files Browse the repository at this point in the history
This commit updates the version of JRuby used in spec tests from 9.4.3.0
to 9.4.7.0, which matches what is used in the latest version of Puppet
Server 8.x. (See: puppetlabs/jruby-utils@1180711.)

JRuby 9.4.7.0 includes bug fixes to several issues that we have worked
around in Puppet in the past:

- Dir.glob not properly supporting wildcard syntax (worked around in
  Puppet in 663062a, resolved in JRuby in jruby/jruby@a39cd49).
- format and sprintf not supporting %a and %A (worked aroundin Puppet in
  334ea05, resolved in JRuby in
jruby/jruby#7996).

Because of these bug fixes in JRuby, this commit also removes Puppet's
workarounds.
  • Loading branch information
mhashizume committed May 21, 2024
1 parent b0d63e5 commit ab460e6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rspec_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- {os: ubuntu-latest, ruby: '3.1'}
- {os: ubuntu-20.04, ruby: '3.2'} # openssl 1.1.1
- {os: ubuntu-22.04, ruby: '3.2'} # openssl 3
- {os: ubuntu-latest, ruby: 'jruby-9.4.3.0'}
- {os: ubuntu-latest, ruby: 'jruby-9.4.7.0'}
- {os: windows-2019, ruby: '3.1'}
- {os: windows-2019, ruby: '3.2'} # openssl 3

Expand Down
6 changes: 2 additions & 4 deletions lib/puppet/node/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -593,12 +593,10 @@ def perform_initial_import
if file == NO_MANIFEST
empty_parse_result
elsif File.directory?(file)
# JRuby does not properly perform Dir.glob operations with wildcards, (see PUP-11788 and https://github.com/jruby/jruby/issues/7836).
# We sort the results because Dir.glob order is inconsistent in Ruby < 3 (see PUP-10115).
parse_results = Puppet::FileSystem::PathPattern.absolute(File.join(file, '**/*')).glob.select { |globbed_file| globbed_file.end_with?('.pp') }.sort.map do |file_to_parse|
parse_results = Puppet::FileSystem::PathPattern.absolute(File.join(file, '**/*.pp')).glob.map do | file_to_parse |
parser.file = file_to_parse
parser.parse
end
end
# Use a parser type specific merger to concatenate the results
Puppet::Parser::AST::Hostclass.new('', :code => Puppet::Parser::ParserFactory.code_merger.concatenate(parse_results))
else
Expand Down
4 changes: 0 additions & 4 deletions spec/unit/file_system/path_pattern_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'spec_helper'
require 'puppet_spec/files'
require 'puppet/file_system'
require 'puppet/util'

describe Puppet::FileSystem::PathPattern do
include PuppetSpec::Files
Expand Down Expand Up @@ -134,9 +133,6 @@
end

it 'globs wildcard patterns properly' do
# See PUP-11788 and https://github.com/jruby/jruby/issues/7836.
pending 'JRuby does not properly handle Dir.glob' if Puppet::Util::Platform.jruby?

dir = tmpdir('globtest')
create_file_in(dir, 'foo.pp')
create_file_in(dir, 'foo.pp.pp')
Expand Down
13 changes: 2 additions & 11 deletions spec/unit/pops/types/string_converter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@
'%o' => '22',
'%4.2o' => ' 22',
'%#o' => '022',
'%#6.4o' => ' 0022',
'%b' => '10010',
'%7.6b' => ' 010010',
'%#b' => '0b10010',
Expand All @@ -316,18 +317,11 @@
'%.1f' => '18.0',
}.each do |fmt, result |
it "the format #{fmt} produces #{result}" do
pending("PUP-8612 %a and %A not support on JRuby") if RUBY_PLATFORM == 'java' && fmt =~ /^%[aA]$/
string_formats = { Puppet::Pops::Types::PIntegerType::DEFAULT => fmt}
expect(converter.convert(18, string_formats)).to eq(result)
end
end

it 'the format %#6.4o produces 0022' do
string_formats = { Puppet::Pops::Types::PIntegerType::DEFAULT => '%#6.4o' }
result = RUBY_PLATFORM == 'java' ? ' 00022' : ' 0022'
expect(converter.convert(18, string_formats)).to eq(result)
end

it 'produces a unicode char string by using format %c' do
string_formats = { Puppet::Pops::Types::PIntegerType::DEFAULT => '%c'}
expect(converter.convert(0x1F603, string_formats)).to eq("\u{1F603}")
Expand Down Expand Up @@ -410,7 +404,6 @@
'%#B' => '0B10010',
}.each do |fmt, result |
it "the format #{fmt} produces #{result}" do
pending("PUP-8612 %a and %A not support on JRuby") if RUBY_PLATFORM == 'java' && fmt =~ /^%[-.014]*[aA]$/
string_formats = { Puppet::Pops::Types::PFloatType::DEFAULT => fmt}
expect(converter.convert(18.0, string_formats)).to eq(result)
end
Expand Down Expand Up @@ -587,7 +580,6 @@
"%#Y" => 'Y',
}.each do |fmt, result |
it "the format #{fmt} produces #{result}" do
pending("PUP-8612 %a and %A not support on JRuby") if RUBY_PLATFORM == 'java' && fmt =~ /^%[aA]$/
string_formats = { Puppet::Pops::Types::PBooleanType::DEFAULT => fmt}
expect(converter.convert(true, string_formats)).to eq(result)
end
Expand Down Expand Up @@ -634,7 +626,6 @@
"%#Y" => 'N',
}.each do |fmt, result |
it "the format #{fmt} produces #{result}" do
pending("PUP-8612 %a and %A not support on JRuby") if RUBY_PLATFORM == 'java' && fmt =~ /^%[aA]$/
string_formats = { Puppet::Pops::Types::PBooleanType::DEFAULT => fmt}
expect(converter.convert(false, string_formats)).to eq(result)
end
Expand Down Expand Up @@ -692,7 +683,7 @@
short_array_t => "%(a",
long_array_t => "%[a",
}
expect(converter.convert([1, 2], string_formats)).to eq('(1, 2)') unless RUBY_PLATFORM == 'java' # PUP-8615
expect(converter.convert([1, 2], string_formats)).to eq('(1, 2)')
expect(converter.convert([1, 2, 3], string_formats)).to eq('[1, 2, 3]')
end

Expand Down

0 comments on commit ab460e6

Please sign in to comment.