Disable litmus when Ruby 3

The latest version of bolt (3.22.1[1] at the time of writing) does not
support Ruby 3 yet. Ruby 3 is already available in CentOS Stream 9 and
this is currently causing failure during `gem install`.

This change excludes litmus and bolt when Ruby 3 is installed so that
unit tests can be executed in CentOS Stream 9.

[1] https://rubygems.org/gems/bolt/versions/3.22.1

Change-Id: I2ca0b9ae0c4b7c930b9f67b68643d8905bfecab0
This commit is contained in:
Takashi Kajinami 2022-04-20 08:37:20 +09:00
parent 2b1b5641e0
commit 57e6de9985
2 changed files with 13 additions and 3 deletions

View File

@ -3,7 +3,11 @@ require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
require 'puppet-syntax/tasks/puppet-syntax'
require 'metadata-json-lint/rake_task'
require 'puppet_litmus/rake_tasks'
begin
require 'puppet_litmus/rake_tasks'
rescue LoadError
# In case puppet_litmus does not support the OS (eg. CentOS Stream 9)
end
require 'json'
modname = JSON.parse(open('metadata.json').read)['name'].split('-')[1]

View File

@ -50,7 +50,13 @@ Gem::Specification.new do |spec|
spec.add_dependency 'pathspec', ['< 1.0.0']
end
spec.add_dependency 'bolt'
spec.add_dependency 'puppet_litmus'
# NOTE(tkajinam): The latest bolt does not support Ruby 3 yet. Disable litmus
# so that we can run unit tests in CentOS Stream 9 which has
# Ruby 3.
if RUBY_VERSION < '3.0.0'
spec.add_dependency 'bolt'
spec.add_dependency 'puppet_litmus', ['0.33.2']
end
spec.add_dependency 'serverspec'
end