From 0ee7c4da6158f33d57ccbbd51fe5c40b8e909d35 Mon Sep 17 00:00:00 2001 From: Steven Pritchard Date: Wed, 27 May 2026 16:46:42 +0000 Subject: [PATCH] Add JRuby 10.0.5.0 and 10.1.0.0 to test matrix Adding JRuby 10 to the test matrix exposed RSpec failures: * JRuby 10's backtrace format reports module methods unqualified ('stack' instead of 'Puppet::Pops::PuppetStack.stack'), so the PUPPET_STACK_INSERTION_FRAME regex never matched and PuppetStack pseudo-frames stopped being interleaved into log backtraces. Broaden the regex to handle Ruby 3.3 (backtick), Ruby 3.4+ (qualified) and JRuby 10+ (unqualified) formats. * The integration specs for agent logging and the RDoc parser depend on the syslog and rdoc gems, which are restricted to platforms: [:ruby] in the Gemfile and so are absent on JRuby; skip those describes on JRuby, matching the existing idiom used elsewhere. * JRuby 10.1.0.0 raises ArgumentError('string contains null byte') instead of MRI's 'path name contains null byte' when a filename contains a NUL; accept either message in the affected json/yaml specs. Co-Authored-By: Claude Opus 4.7 (1M context) Signed-off-by: Steven Pritchard --- .github/workflows/tests.yaml | 2 ++ lib/puppet/util.rb | 11 ++++++----- spec/integration/agent/logging_spec.rb | 2 +- spec/integration/util/rdoc/parser_spec.rb | 2 +- spec/unit/util/json_spec.rb | 2 +- spec/unit/util/yaml_spec.rb | 4 ++-- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index edf0e9308b..fc9e4731ce 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -48,6 +48,8 @@ jobs: - {os: ubuntu-24.04, ruby: '4.0'} - {os: ubuntu-24.04, ruby: 'jruby-9.4.8.0'} - {os: ubuntu-24.04, ruby: 'jruby-9.4.14.0'} + - {os: ubuntu-24.04, ruby: 'jruby-10.0.5.0'} + - {os: ubuntu-24.04, ruby: 'jruby-10.1.0.0'} - {os: windows-2025, ruby: '3.2'} - {os: windows-2025, ruby: '3.3'} - {os: windows-2025, ruby: '3.4'} diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index e7fc70cfd2..6356eb2d8f 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -523,11 +523,12 @@ def thinmark module_function :thinmark - PUPPET_STACK_INSERTION_FRAME = if RUBY_VERSION >= '3.4' - /.*puppet_stack\.rb.*in.*'Puppet::Pops::PuppetStack\.stack'/ - else - /.*puppet_stack\.rb.*in.*`stack'/ - end + # Matches the frame where Puppet::Pops::PuppetStack.stack appears in a Ruby + # backtrace. The format varies by Ruby version and implementation: + # Ruby 3.3: in `stack' + # Ruby 3.4+: in 'Puppet::Pops::PuppetStack.stack' (qualified for module method) + # JRuby 10+: in 'stack' (unqualified) + PUPPET_STACK_INSERTION_FRAME = /puppet_stack\.rb.*in ['`](?:Puppet::Pops::PuppetStack\.)?stack'/ # utility method to get the current call stack and format it to a human-readable string (which some IDEs/editors # will recognize as links to the line numbers in the trace) diff --git a/spec/integration/agent/logging_spec.rb b/spec/integration/agent/logging_spec.rb index 50bbf36f5c..a1044b312f 100644 --- a/spec/integration/agent/logging_spec.rb +++ b/spec/integration/agent/logging_spec.rb @@ -37,7 +37,7 @@ # # Note that this test does not have anything to say about what happens to logging after # daemonizing. -describe 'agent logging' do +describe 'agent logging', unless: Puppet::Util::Platform.jruby? do ONETIME = '--onetime' DAEMONIZE = '--daemonize' NO_DAEMONIZE = '--no-daemonize' diff --git a/spec/integration/util/rdoc/parser_spec.rb b/spec/integration/util/rdoc/parser_spec.rb index 9894fa41db..6d5325166a 100644 --- a/spec/integration/util/rdoc/parser_spec.rb +++ b/spec/integration/util/rdoc/parser_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'puppet/util/rdoc' -describe "RDoc::Parser", :unless => Puppet::Util::Platform.windows? do +describe "RDoc::Parser", :unless => Puppet::Util::Platform.windows? || Puppet::Util::Platform.jruby? do require 'puppet_spec/files' include PuppetSpec::Files diff --git a/spec/unit/util/json_spec.rb b/spec/unit/util/json_spec.rb index b630c7583b..ed91e1e8e4 100644 --- a/spec/unit/util/json_spec.rb +++ b/spec/unit/util/json_spec.rb @@ -81,7 +81,7 @@ it 'returns nil when the filename is illegal and debug logs about it' do expect(Puppet).to receive(:debug) - .with(/Could not retrieve JSON content .+: path ?name contains null byte/).and_call_original + .with(/Could not retrieve JSON content .+: (?:path ?name|string) contains null byte/).and_call_original expect(Puppet::Util::Json.load_file_if_valid("not\0allowed")).to eql(nil) end diff --git a/spec/unit/util/yaml_spec.rb b/spec/unit/util/yaml_spec.rb index dd6e383160..a1e5faf22a 100644 --- a/spec/unit/util/yaml_spec.rb +++ b/spec/unit/util/yaml_spec.rb @@ -128,7 +128,7 @@ it 'raises an error when the filename is illegal' do expect { Puppet::Util::Yaml.safe_load_file("not\0allowed") - }.to raise_error(ArgumentError, /path ?name contains null byte/) + }.to raise_error(ArgumentError, /(?:path ?name|string) contains null byte/) end it 'raises an error when the file does not exist' do @@ -156,7 +156,7 @@ it 'returns nil when the filename is illegal and debug logs about it' do expect(Puppet).to receive(:debug) - .with(/Could not retrieve YAML content .+: path ?name contains null byte/).and_call_original + .with(/Could not retrieve YAML content .+: (?:path ?name|string) contains null byte/).and_call_original expect(Puppet::Util::Yaml.safe_load_file_if_valid("not\0allowed")).to eql(nil) end