-
Notifications
You must be signed in to change notification settings - Fork 202
/
Rakefile
91 lines (79 loc) · 2.26 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
require 'rake'
require 'rspec/core/rake_task'
require 'bundler/gem_tasks'
require 'fileutils'
require 'puppet'
task :default => :test
task :spec => :test
require 'rspec-puppet/tasks/release_test' unless RUBY_VERSION.start_with?('1')
fixtures_dir = File.expand_path(File.join(__FILE__, '..', 'spec', 'fixtures', 'modules'))
fixtures = {
'augeas_core' => {
:url => 'https://github.com/puppetlabs/puppetlabs-augeas_core',
:requirement => Gem::Requirement.new('>= 6.0.0'),
},
'stdlib' => {
:url => 'https://github.com/puppetlabs/puppetlabs-stdlib',
:requirement => Gem::Requirement.new('>= 0'),
:ref => '4.2.0',
},
'registry' => {
:url => 'https://github.com/puppetlabs/puppetlabs-registry',
:requirement => Gem::Requirement.new('>= 0'),
},
}
namespace :test do
RSpec::Core::RakeTask.new(:spec) do |t|
if t.respond_to?(:exclude_pattern)
t.exclude_pattern = 'spec/fixtures/**/*_spec.rb'
else
t.pattern = 'spec/{applications,classes,defines,functions,hosts,type_aliases,types,unit}/**/*_spec.rb'
end
end
RSpec::Core::RakeTask.new(:spec_unit) do |t|
t.pattern = 'spec/unit/**/*_spec.rb'
end
task :setup do
puppet_version = Gem::Version.new(Puppet.version)
Dir.chdir(fixtures_dir) do
fixtures.each do |name, fixture|
next if File.directory?(name)
next unless fixture[:requirement].satisfied_by?(puppet_version)
system('git', 'clone', fixture[:url], name)
fail unless $?.success?
if fixture.key?(:ref)
Dir.chdir(name) do
system('git', 'checkout', fixture[:ref])
fail unless $?.success?
end
end
end
end
end
task :teardown do
Dir.chdir(fixtures_dir) do
fixtures.each do |name, _|
next unless File.directory?(name)
FileUtils.rm_r(name)
end
end
end
task :unit do
begin
Rake::Task['test:setup'].invoke
ENV['COVERAGE'] = 'local'
Rake::Task['test:spec_unit'].invoke
ensure
ENV.delete('COVERAGE')
Rake::Task['test:teardown'].invoke
end
end
end
task :test do
begin
Rake::Task['test:setup'].invoke
Rake::Task['test:spec'].invoke
ensure
Rake::Task['test:teardown'].invoke
end
end