Skip to content

Commit 600941e

Browse files
committed
(CONT-237) - Remove legacy code (pre v6)
1 parent 78ff5fe commit 600941e

File tree

3 files changed

+4
-101
lines changed

3 files changed

+4
-101
lines changed

lib/puppetlabs_spec_helper/module_spec_helper.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def verify_contents(subject, title, expected_lines)
6666
c.formatter = 'RSpec::Github::Formatter'
6767
end
6868

69-
c.environmentpath = spec_path if Puppet.version.to_f >= 4.0
69+
c.environmentpath = spec_path
7070
c.module_path = module_path
7171
c.manifest_dir = File.join(fixture_path, 'manifests')
7272
c.parser = 'future' if ENV['FUTURE_PARSER'] == 'yes'
@@ -78,12 +78,7 @@ def verify_contents(subject, title, expected_lines)
7878
Puppet.features.stubs(:root?).returns(true)
7979
end
8080

81-
# stringify_facts and trusted_node_data were removed in puppet4
82-
if Puppet.version.to_f < 4.0
83-
Puppet.settings[:stringify_facts] = false if ENV['STRINGIFY_FACTS'] == 'no'
84-
Puppet.settings[:trusted_node_data] = true if ENV['TRUSTED_NODE_DATA'] == 'yes'
85-
end
86-
Puppet.settings[:strict_variables] = true if ENV['STRICT_VARIABLES'] == 'yes' || (Puppet.version.to_f >= 4.0 && ENV['STRICT_VARIABLES'] != 'no')
81+
Puppet.settings[:strict_variables] = true if ENV['STRICT_VARIABLES'] == 'yes' || ENV['STRICT_VARIABLES'] != 'no'
8782
Puppet.settings[:ordering] = ENV['ORDERING'] if ENV['ORDERING']
8883
end
8984
end

lib/puppetlabs_spec_helper/puppet_spec_helper.rb

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -51,83 +51,6 @@
5151
# Continue gracefully
5252
end
5353

54-
# This is just a utility class to allow us to isolate the various version-specific
55-
# branches of initialization logic into methods without polluting the global namespace.#
56-
class Puppet::PuppetSpecInitializer
57-
# This method is for initializing puppet state for testing for older versions
58-
# of puppet that do not support the new TestHelper API. As you can see,
59-
# this involves explicitly modifying global variables, directly manipulating
60-
# Puppet's Settings singleton object, and other fun implementation details
61-
# that code external to puppet should really never know about.
62-
def self.initialize_via_fallback_compatibility(config)
63-
warn('Warning: you appear to be using an older version of puppet; spec_helper will use fallback compatibility mode.')
64-
config.before :all do
65-
# nothing to do for now
66-
end
67-
68-
config.after :all do
69-
# nothing to do for now
70-
end
71-
72-
config.before :each do
73-
# these globals are set by Application
74-
$puppet_application_mode = nil # rubocop:disable Style/GlobalVars
75-
$puppet_application_name = nil # rubocop:disable Style/GlobalVars
76-
77-
# REVISIT: I think this conceals other bad tests, but I don't have time to
78-
# fully diagnose those right now. When you read this, please come tell me
79-
# I suck for letting this float. --daniel 2011-04-21
80-
Signal.stubs(:trap)
81-
82-
# Set the confdir and vardir to gibberish so that tests
83-
# have to be correctly mocked.
84-
Puppet[:confdir] = '/dev/null'
85-
Puppet[:vardir] = '/dev/null'
86-
87-
# Avoid opening ports to the outside world
88-
Puppet.settings[:bindaddress] = '127.0.0.1'
89-
end
90-
91-
config.after :each do
92-
Puppet.settings.clear
93-
94-
Puppet::Node::Environment.clear
95-
Puppet::Util::Storage.clear
96-
Puppet::Util::ExecutionStub.reset if Puppet::Util.constants.include? 'ExecutionStub'
97-
98-
PuppetlabsSpec::Files.cleanup
99-
end
100-
end
101-
end
102-
103-
# JJM Hack to make the stdlib tests run in Puppet 2.6 (See puppet commit cf183534)
104-
unless Puppet.constants.include? 'Test'
105-
module Puppet::Test
106-
# This is a stub class to allow the stdlib tests to run in Puppet 2.6
107-
# This class will be removed in another commit.
108-
class LogCollector
109-
def initialize(logs)
110-
@logs = logs
111-
end
112-
113-
def <<(value)
114-
@logs << value
115-
end
116-
end
117-
end
118-
Puppet::Util::Log.newdesttype :log_collector do
119-
match 'Puppet::Test::LogCollector'
120-
121-
def initialize(messages)
122-
@messages = messages
123-
end
124-
125-
def handle(msg)
126-
@messages << msg
127-
end
128-
end
129-
end
130-
13154
# And here is where we do the main rspec configuration / setup.
13255
RSpec.configure do |config|
13356
# Detect whether the module is overriding the choice of mocking framework

lib/puppetlabs_spec_helper/rake_tasks.rb

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -122,22 +122,10 @@
122122

123123
desc 'Build puppet module package'
124124
task :build do
125-
if Gem::Specification.find_by_name('puppet').version < Gem::Version.new('6.0.0')
126-
Rake::Task['build:pmt'].invoke
127-
else
128-
Rake::Task['build:pdk'].invoke
129-
end
125+
Rake::Task['build:pdk'].invoke
130126
end
131127

132128
namespace :build do
133-
desc 'Build Puppet module package with PMT (Puppet < 6.0.0 only)'
134-
task :pmt do
135-
require 'puppet/face'
136-
137-
pmod = Puppet::Face['module', :current]
138-
pmod.build('./')
139-
end
140-
141129
desc 'Build Puppet module with PDK'
142130
task :pdk do
143131
require 'pdk/util'
@@ -204,9 +192,6 @@
204192
PuppetSyntax.exclude_paths << 'vendor/**/*'
205193
PuppetSyntax.exclude_paths << '.vendor/**/*'
206194
PuppetSyntax.exclude_paths << 'plans/**/*'
207-
if Puppet.version.to_f < 4.0
208-
PuppetSyntax.exclude_paths << 'types/**/*'
209-
end
210195

211196
desc 'Check syntax of Ruby files and call :syntax and :metadata_lint'
212197
task :validate do
@@ -254,7 +239,7 @@
254239
# If the branch is a release branch we append an 'r' into the new_version,
255240
# this is due to the release branch buildID conflicting with main branch when trying to push to the staging forge.
256241
# More info can be found at https://tickets.puppetlabs.com/browse/FM-6170
257-
new_version = if (build = (ENV['BUILD_NUMBER'] || ENV['TRAVIS_BUILD_NUMBER']))
242+
new_version = if (build = ENV['BUILD_NUMBER'])
258243
if branch.eql? 'release'
259244
'%s-%s%04d-%s' % [version, 'r', build, sha] # legacy support code # rubocop:disable Style/FormatStringToken
260245
else

0 commit comments

Comments
 (0)