puppetlabs_spec_helper 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +11 -0
- data/CHANGELOG.md +16 -1
- data/CONTRIBUTING.md +55 -0
- data/Gemfile +11 -4
- data/README.markdown +44 -1
- data/Rakefile +42 -25
- data/lib/puppetlabs_spec_helper/rake_tasks.rb +190 -35
- data/lib/puppetlabs_spec_helper/version.rb +1 -1
- data/puppetlabs_spec_helper.gemspec +81 -18
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/puppetlabs_spec_helper/puppetlabs_spec/puppet_internals_spec.rb +8 -9
- metadata +66 -10
- data/.gitignore +0 -3
- data/spec/unit/spechelper_spec.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 426cd8838d534c5070cb5995d7a985f07870dd68
|
4
|
+
data.tar.gz: a1145c2a54a8c44760bf51d731720587a60deba4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 868efeb2d113293f52366537491a22e29505a7a406332327cae0301734cddd6ca307f7a0217100c271ccac9c1f72348baef6763f5e4132a6e24a645a47c1c500
|
7
|
+
data.tar.gz: 2fa3274a70b1ebe0a8ba9284ee685d579de416ae2db87ce3954275758d49402babbfcc535776fabbf89e9b816ffb84ac48f88f828d39d0550372114eacd9ab87
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,20 @@
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
|
+
## [1.1.0] - 2015-02-25
|
6
|
+
### Summary:
|
7
|
+
This release adds the ability to clone fixtures from git in parallel, speeding
|
8
|
+
up the spec\_prep rake task.
|
9
|
+
|
10
|
+
### Added:
|
11
|
+
- Parallel fixtures cloning
|
12
|
+
- Various rake check tasks for module release preparation
|
13
|
+
|
14
|
+
### Fixed:
|
15
|
+
- Added travis ci
|
16
|
+
- Added contributing doc
|
17
|
+
- Don't validate metadata if metadata-json-lint gem is not present
|
18
|
+
|
5
19
|
## [1.0.1] - 2015-11-06
|
6
20
|
### Summary:
|
7
21
|
This bugfix release fixes the Error vs. Errno bug in 1.0.0
|
@@ -215,7 +229,8 @@ compatible yet.
|
|
215
229
|
### Added
|
216
230
|
* Initial release
|
217
231
|
|
218
|
-
[unreleased]: https://github.com/puppetlabs/puppetlabs_spec_helper/compare/1.0
|
232
|
+
[unreleased]: https://github.com/puppetlabs/puppetlabs_spec_helper/compare/1.1.0...master
|
233
|
+
[1.1.0]: https://github.com/puppetlabs/puppetlabs_spec_helper/compare/1.0.1...1.1.0
|
219
234
|
[1.0.1]: https://github.com/puppetlabs/puppetlabs_spec_helper/compare/1.0.0...1.0.1
|
220
235
|
[1.0.0]: https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.10.3...1.0.0
|
221
236
|
[0.10.3]: https://github.com/puppetlabs/puppetlabs_spec_helper/compare/0.10.2...0.10.3
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# DEVELOPMENT NOTES
|
2
|
+
|
3
|
+
## Building Gemspec
|
4
|
+
The Rakefile includes all the info that the gemspec file will contain. You have to update
|
5
|
+
the Rakefile instead of the gemspec.
|
6
|
+
To regenerate the gemspec just run `rake gemspec` and a new gemspec will be created
|
7
|
+
with everything required.
|
8
|
+
|
9
|
+
Running `rake build` will build out the gemspec according to the Rakefile parameters.
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
Jeweler::Tasks.new do |gem|
|
13
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
14
|
+
gem.name = "puppetlabs_spec_helper"
|
15
|
+
gem.version = "#{PuppetlabsSpecHelper::Version::STRING}"
|
16
|
+
gem.homepage = "http://github.com/puppetlabs/puppetlabs_spec_helper"
|
17
|
+
gem.license = "Apache-2.0"
|
18
|
+
gem.summary = %Q{Standard tasks and configuration for module spec tests}
|
19
|
+
gem.description = %Q{Contains rake tasks and a standard spec_helper for running spec tests on puppet modules}
|
20
|
+
gem.email = ["modules-dept@puppetlabs.com"]
|
21
|
+
gem.authors = ["Puppet Labs"]
|
22
|
+
# dependencies defined in Gemfile
|
23
|
+
end
|
24
|
+
|
25
|
+
```
|
26
|
+
|
27
|
+
## Version file
|
28
|
+
As part of the `rake gemspec` task, the gemspec will reference the version that is
|
29
|
+
defined in the `lib/puppetlabs_spec_helper/version.rb` file.
|
30
|
+
|
31
|
+
|
32
|
+
## Releasing
|
33
|
+
To release the gem just run the following things.
|
34
|
+
|
35
|
+
### 1. Update the version
|
36
|
+
update the version file : `lib/puppetlabs_spec_helper/version.rb`
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
module PuppetlabsSpecHelper
|
40
|
+
module Version
|
41
|
+
STRING = '1.0.1'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
### 2. Generate and push the release to git
|
47
|
+
rake gemspec:release
|
48
|
+
|
49
|
+
### 3. Tag and release to git
|
50
|
+
Since the default behavior of jewler is to use tags like `v1.0.1` we cannot use
|
51
|
+
the `git:release` task and will need to use `git:pl_release` which creates a tag
|
52
|
+
without the `v` and pushes to master.
|
53
|
+
|
54
|
+
### 4. Release to rubygems
|
55
|
+
rake release
|
data/Gemfile
CHANGED
@@ -1,9 +1,16 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
|
3
|
+
gem 'rake'
|
4
|
+
gem 'rspec-puppet'
|
5
|
+
gem 'puppet-lint'
|
6
|
+
gem 'puppet-syntax'
|
7
|
+
gem 'mocha'
|
4
8
|
|
5
|
-
|
6
|
-
|
9
|
+
group :development do
|
10
|
+
gem 'yard'
|
11
|
+
gem 'pry'
|
12
|
+
gem 'jeweler'
|
13
|
+
gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.8.3'
|
7
14
|
end
|
8
15
|
|
9
16
|
# vim:filetype=ruby
|
data/README.markdown
CHANGED
@@ -43,6 +43,24 @@ And run the spec tests:
|
|
43
43
|
$ cd $modulename
|
44
44
|
$ rake spec
|
45
45
|
|
46
|
+
|
47
|
+
### Parallel Fixture Downloads
|
48
|
+
Fixture downloads will now execute in parallel to speed up the testing process. Which can represent >= 600% speed increase (depending on number of threads). You can control the amount of threads by setting the `MAX_FIXTURE_THREAD_COUNT` environment variable
|
49
|
+
to a positive integer, the default is currently 10. We don't suggest going higher than 25 as the gains are marginal due to some repos taking a long time to download. Please be aware that your internal VCS system may not be able to handle a high load in which case the server would fail to clone the repository. Because of this issue, this setting is tunable via `MAX_FIXTURE_THREAD_COUNT`.
|
50
|
+
|
51
|
+
Additionally, you can also speed up cloning when using the ssh protocol by multiplexing ssh sessions. Add something similar to your ssh config.
|
52
|
+
Note: you may need to change the host if your using an internal git server.
|
53
|
+
|
54
|
+
```shell
|
55
|
+
Host github.com
|
56
|
+
ControlMaster auto
|
57
|
+
ControlPath ~/.ssh/ssh-%r@%h:%p
|
58
|
+
ControlPersist yes
|
59
|
+
|
60
|
+
```
|
61
|
+
|
62
|
+
Note: parallel downloads is only available for repositories and not forge modules.
|
63
|
+
|
46
64
|
Issues
|
47
65
|
======
|
48
66
|
|
@@ -142,7 +160,7 @@ Using Fixtures
|
|
142
160
|
`rake spec_prep` is run. To do so, all required modules should be listed in a
|
143
161
|
file named `.fixtures.yml` in the root of the project.
|
144
162
|
|
145
|
-
When specifying the repo source of the fixture you have a few options as to which revision of the codebase you wish to use.
|
163
|
+
When specifying the repo source of the fixture you have a few options as to which revision of the codebase you wish to use.
|
146
164
|
|
147
165
|
* repo - the url to the repo
|
148
166
|
* scm - options include git or hg. This is an optional step as the helper code will figure out which scm is used.
|
@@ -245,4 +263,29 @@ instances in a manner decoupled from the internal behavior of Puppet:
|
|
245
263
|
end
|
246
264
|
end
|
247
265
|
|
266
|
+
Some Notes for Windows Users
|
267
|
+
==============
|
268
|
+
|
269
|
+
A windows users may need to do one of two things to execute 'rake spec'.
|
270
|
+
|
271
|
+
Although things may appear to work, the init.pp may not transfer to the fixtures folder as needed
|
272
|
+
or may transfer as an empty file.
|
273
|
+
|
274
|
+
This is related to a registry security setting requiring elevated privileges to create symbolic links.
|
275
|
+
|
276
|
+
Currently, there are two known approaches to get around this problem.
|
277
|
+
|
278
|
+
- run your windows shell (cmd) as an Administrator
|
279
|
+
or
|
280
|
+
- modify the registry entry settings to allow symbolic links to be created.
|
281
|
+
|
282
|
+
The following links may give you some insight into why...
|
283
|
+
|
284
|
+
[Server Fault Post](http://serverfault.com/questions/582944/puppet-file-link-doesnt-create-target-under-windows)
|
285
|
+
|
286
|
+
[Stack Overflow Post](http://stackoverflow.com/questions/229643/how-do-i-overcome-the-the-symbolic-link-cannot-be-followed-because-its-type-is)
|
287
|
+
|
288
|
+
[Microsoft TechNet](https://technet.microsoft.com/en-us/library/cc754077.aspx)
|
289
|
+
|
290
|
+
|
248
291
|
EOF
|
data/Rakefile
CHANGED
@@ -1,33 +1,50 @@
|
|
1
|
-
|
2
|
-
require 'rake/packagetask'
|
3
|
-
require 'rubygems/package_task'
|
1
|
+
# encoding: utf-8
|
4
2
|
|
5
|
-
|
6
|
-
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
7
11
|
end
|
12
|
+
require 'rake'
|
13
|
+
require_relative 'lib/puppetlabs_spec_helper/version'
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "puppetlabs_spec_helper"
|
18
|
+
gem.version = "#{PuppetlabsSpecHelper::Version::STRING}"
|
19
|
+
gem.homepage = "http://github.com/puppetlabs/puppetlabs_spec_helper"
|
20
|
+
gem.license = "Apache-2.0"
|
21
|
+
gem.summary = %Q{Standard tasks and configuration for module spec tests}
|
22
|
+
gem.description = %Q{Contains rake tasks and a standard spec_helper for running spec tests on puppet modules}
|
23
|
+
gem.email = ["modules-dept@puppetlabs.com"]
|
24
|
+
gem.authors = ["Puppet Labs"]
|
25
|
+
# dependencies defined in Gemfile
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
8
28
|
|
9
|
-
require '
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
PuppetlabsSpecHelper::Version::STRING
|
29
|
+
require 'rspec/core'
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
32
|
+
spec.pattern = FileList['spec/**/*_spec.rb'].exclude('spec/fixtures/**/*_spec.rb')
|
14
33
|
end
|
15
34
|
|
16
|
-
namespace :
|
17
|
-
desc "Create the
|
18
|
-
task :
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
FileUtils.move("puppetlabs_spec_helper-#{version}.gem", "pkg")
|
35
|
+
namespace :git do
|
36
|
+
desc "Create a new tag that uses #{PuppetlabsSpecHelper::Version::STRING} as the tag"
|
37
|
+
task :tag do
|
38
|
+
`git tag -m '#{PuppetlabsSpecHelper::Version::STRING}'`
|
39
|
+
end
|
40
|
+
desc "Tag and push to master"
|
41
|
+
task :pl_release do
|
42
|
+
Rake::Task["git:tag"].invoke
|
43
|
+
`git push origin master --tags`
|
27
44
|
end
|
28
45
|
end
|
29
46
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
47
|
+
task :default => :spec
|
48
|
+
|
49
|
+
require 'yard'
|
50
|
+
YARD::Rake::YardocTask.new
|
@@ -2,6 +2,13 @@ require 'rake'
|
|
2
2
|
require 'rspec/core/rake_task'
|
3
3
|
require 'yaml'
|
4
4
|
|
5
|
+
# optional gems
|
6
|
+
begin
|
7
|
+
require 'metadata-json-lint/rake_task'
|
8
|
+
rescue LoadError
|
9
|
+
# ignore
|
10
|
+
end
|
11
|
+
|
5
12
|
task :default => [:help]
|
6
13
|
|
7
14
|
desc "Run spec tests on an existing fixtures directory"
|
@@ -27,6 +34,20 @@ def source_dir
|
|
27
34
|
Dir.pwd
|
28
35
|
end
|
29
36
|
|
37
|
+
# cache the repositories and retruns and hash object
|
38
|
+
def repositories
|
39
|
+
unless @repositories
|
40
|
+
@repositories = fixtures('repositories')
|
41
|
+
@repositories.each do |remote, opts|
|
42
|
+
if opts.instance_of?(String)
|
43
|
+
@repositories[remote] = {"target" => opts} # inject a hash
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
@repositories
|
48
|
+
end
|
49
|
+
|
50
|
+
|
30
51
|
def fixtures(category)
|
31
52
|
if File.exists?('.fixtures.yml')
|
32
53
|
fixtures_yaml = '.fixtures.yml'
|
@@ -77,9 +98,13 @@ def clone_repo(scm, remote, target, ref=nil, branch=nil, flags = nil)
|
|
77
98
|
args.push(flags) if flags
|
78
99
|
args.push(remote, target)
|
79
100
|
else
|
80
|
-
|
101
|
+
fail "Unfortunately #{scm} is not supported yet"
|
102
|
+
end
|
103
|
+
result = system("#{scm} #{args.flatten.join ' '}")
|
104
|
+
unless File::exists?(target)
|
105
|
+
fail "Failed to clone #{scm} repository #{remote} into #{target}"
|
81
106
|
end
|
82
|
-
|
107
|
+
result
|
83
108
|
end
|
84
109
|
|
85
110
|
def revision(scm, target, ref)
|
@@ -90,11 +115,56 @@ def revision(scm, target, ref)
|
|
90
115
|
when 'git'
|
91
116
|
args.push('reset', '--hard', ref)
|
92
117
|
else
|
93
|
-
|
118
|
+
fail "Unfortunately #{scm} is not supported yet"
|
94
119
|
end
|
95
120
|
system("cd #{target} && #{scm} #{args.flatten.join ' '}")
|
96
121
|
end
|
97
122
|
|
123
|
+
# creates a logger so we can log events with certain levels
|
124
|
+
def logger
|
125
|
+
unless @logger
|
126
|
+
require 'logger'
|
127
|
+
if ENV['ENABLE_LOGGER']
|
128
|
+
level = Logger::DEBUG
|
129
|
+
else
|
130
|
+
level = Logger::INFO
|
131
|
+
end
|
132
|
+
@logger = Logger.new(STDOUT)
|
133
|
+
@logger.level = level
|
134
|
+
end
|
135
|
+
@logger
|
136
|
+
end
|
137
|
+
|
138
|
+
# returns the current thread count that is currently active
|
139
|
+
# a status of false or nil means the thread completed
|
140
|
+
# so when anything else we count that as a active thread
|
141
|
+
def current_thread_count(items)
|
142
|
+
active_threads = items.find_all do |item, opts|
|
143
|
+
if opts[:thread]
|
144
|
+
opts[:thread].status
|
145
|
+
else
|
146
|
+
false
|
147
|
+
end
|
148
|
+
end
|
149
|
+
logger.debug "Current thread count #{active_threads.count}"
|
150
|
+
active_threads.count
|
151
|
+
end
|
152
|
+
|
153
|
+
# returns the max_thread_count
|
154
|
+
# because we may want to limit ssh or https connections
|
155
|
+
def max_thread_limit
|
156
|
+
unless @max_thread_limit
|
157
|
+
# the default thread count is 10 but can be
|
158
|
+
# raised by using environment variable MAX_FIXTURE_THREAD_COUNT
|
159
|
+
if ENV['MAX_FIXTURE_THREAD_COUNT'].to_i > 0
|
160
|
+
@max_thread_limit = ENV['MAX_FIXTURE_THREAD_COUNT'].to_i
|
161
|
+
else
|
162
|
+
@max_thread_limit = 10 # the default
|
163
|
+
end
|
164
|
+
end
|
165
|
+
@max_thread_limit
|
166
|
+
end
|
167
|
+
|
98
168
|
desc "Create the fixtures directory"
|
99
169
|
task :spec_prep do
|
100
170
|
# Ruby only sets File::ALT_SEPARATOR on Windows and Rubys standard library
|
@@ -107,25 +177,35 @@ task :spec_prep do
|
|
107
177
|
rescue
|
108
178
|
end
|
109
179
|
|
110
|
-
|
111
|
-
fixtures("repositories").each do |remote, opts|
|
180
|
+
repositories.each do |remote, opts|
|
112
181
|
scm = 'git'
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
182
|
+
target = opts["target"]
|
183
|
+
ref = opts["ref"]
|
184
|
+
scm = opts["scm"] if opts["scm"]
|
185
|
+
branch = opts["branch"] if opts["branch"]
|
186
|
+
flags = opts["flags"]
|
187
|
+
# get the current active threads that are alive
|
188
|
+
count = current_thread_count(repositories)
|
189
|
+
if count < max_thread_limit
|
190
|
+
logger.debug "New Thread started for #{remote}"
|
191
|
+
# start up a new thread and store it in the opts hash
|
192
|
+
opts[:thread] = Thread.new do
|
193
|
+
clone_repo(scm, remote, target, ref, branch, flags)
|
194
|
+
revision(scm, target, ref) if ref
|
195
|
+
end
|
196
|
+
else
|
197
|
+
# the last thread started should be the longest wait
|
198
|
+
item, item_opts = repositories.find_all {|i,o| o.has_key?(:thread)}.last
|
199
|
+
logger.debug "Waiting on #{item}"
|
200
|
+
item_opts[:thread].join # wait for the thread to finish
|
201
|
+
# now that we waited lets try again
|
202
|
+
redo
|
125
203
|
end
|
126
|
-
revision(scm, target, ref) if ref
|
127
204
|
end
|
128
205
|
|
206
|
+
# wait for all the threads to finish
|
207
|
+
repositories.each {|remote, opts| opts[:thread].join }
|
208
|
+
|
129
209
|
FileUtils::mkdir_p("spec/fixtures/modules")
|
130
210
|
fixtures("symlinks").each do |source, target|
|
131
211
|
if is_windows
|
@@ -149,9 +229,9 @@ task :spec_prep do
|
|
149
229
|
next if File::exists?(target)
|
150
230
|
|
151
231
|
command = "puppet module install" + ref + flags + \
|
152
|
-
|
153
|
-
|
154
|
-
|
232
|
+
" --ignore-dependencies" \
|
233
|
+
" --force" \
|
234
|
+
" --target-dir spec/fixtures/modules #{remote}"
|
155
235
|
|
156
236
|
unless system(command)
|
157
237
|
fail "Failed to install module #{remote} to #{target}"
|
@@ -233,11 +313,11 @@ PuppetLint.configuration.relative = true
|
|
233
313
|
PuppetLint::RakeTask.new(:lint) do |config|
|
234
314
|
config.fail_on_warnings = true
|
235
315
|
config.disable_checks = [
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
316
|
+
'80chars',
|
317
|
+
'class_inherits_from_params_class',
|
318
|
+
'class_parameter_defaults',
|
319
|
+
'documentation',
|
320
|
+
'single_quote_string_with_variables']
|
241
321
|
config.ignore_paths = ["tests/**/*.pp", "vendor/**/*.pp","examples/**/*.pp", "spec/**/*.pp", "pkg/**/*.pp"]
|
242
322
|
end
|
243
323
|
|
@@ -248,23 +328,98 @@ PuppetSyntax.exclude_paths << "pkg/**/*"
|
|
248
328
|
PuppetSyntax.exclude_paths << "vendor/**/*"
|
249
329
|
PuppetSyntax.future_parser = true if ENV['FUTURE_PARSER'] == 'yes'
|
250
330
|
|
251
|
-
desc "Check syntax of Ruby files and call :syntax and :
|
331
|
+
desc "Check syntax of Ruby files and call :syntax and :metadata_lint"
|
252
332
|
task :validate do
|
253
333
|
Dir['lib/**/*.rb'].each do |lib_file|
|
254
334
|
sh "ruby -c #{lib_file}"
|
255
335
|
end
|
256
336
|
|
257
337
|
Rake::Task[:syntax].invoke
|
258
|
-
|
338
|
+
if File.exist?('metadata.json')
|
339
|
+
if Rake::Task.task_defined?(:metadata_lint)
|
340
|
+
Rake::Task[:metadata_lint].invoke
|
341
|
+
else
|
342
|
+
warn "Skipping metadata validation; the metadata-json-lint gem was not found"
|
343
|
+
end
|
344
|
+
end
|
259
345
|
end
|
260
346
|
|
261
|
-
desc "
|
262
|
-
task :
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
347
|
+
desc "Print development version of module"
|
348
|
+
task :compute_dev_version do
|
349
|
+
version = ''
|
350
|
+
if File.exists?( 'metadata.json' )
|
351
|
+
require 'json'
|
352
|
+
|
353
|
+
modinfo = JSON.parse(File.read( 'metadata.json' ))
|
354
|
+
version = modinfo['version']
|
355
|
+
elsif File.exists?( 'Modulefile' )
|
356
|
+
modfile = File.read('Modulefile')
|
357
|
+
version = modfile.match(/\nversion[ ]+['"](.*)['"]/)[1]
|
358
|
+
else
|
359
|
+
fail "Could not find a metadata.json or Modulefile! Cannot compute dev version without one or the other!"
|
360
|
+
end
|
361
|
+
|
362
|
+
sha = `git rev-parse HEAD`[0..7]
|
363
|
+
|
364
|
+
# If we're in a CI environment include our build number
|
365
|
+
if build = ENV['BUILD_NUMBER'] || ENV['TRAVIS_BUILD_NUMBER']
|
366
|
+
new_version = sprintf('%s-%04d-%s', version, build, sha)
|
367
|
+
else
|
368
|
+
new_version = "#{version}-#{sha}"
|
369
|
+
end
|
370
|
+
|
371
|
+
print new_version
|
372
|
+
end
|
373
|
+
|
374
|
+
desc "Runs all nessesary checks on a module in preparation for a release"
|
375
|
+
task :release_checks do
|
376
|
+
Rake::Task[:lint].invoke
|
377
|
+
Rake::Task[:validate].invoke
|
378
|
+
Rake::Task[:spec].invoke
|
379
|
+
Rake::Task["check:symlinks"].invoke
|
380
|
+
Rake::Task["check:test_file"].invoke
|
381
|
+
Rake::Task["check:dot_underscore"].invoke
|
382
|
+
Rake::Task["check:git_ignore"].invoke
|
383
|
+
end
|
384
|
+
|
385
|
+
namespace :check do
|
386
|
+
desc "Fails if symlinks are present in directory"
|
387
|
+
task :symlinks do
|
388
|
+
symlink = `find . -type l -ls`
|
389
|
+
unless symlink == ""
|
390
|
+
puts symlink
|
391
|
+
fail "A symlink exists within this directory"
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
desc "Fails if .pp files present in tests folder"
|
396
|
+
task :test_file do
|
397
|
+
if Dir.exist?("tests")
|
398
|
+
Dir.chdir("tests")
|
399
|
+
ppfiles = Dir["*.pp"]
|
400
|
+
unless ppfiles.empty?
|
401
|
+
puts ppfiles
|
402
|
+
fail ".pp files present in tests folder; Move them to an examples folder following the new convention"
|
403
|
+
end
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
desc "Fails if any ._ files are present in directory"
|
408
|
+
task :dot_underscore do
|
409
|
+
dirs = Dir["._*"]
|
410
|
+
unless dirs.empty?
|
411
|
+
puts dirs
|
412
|
+
fail "._ files are present in the directory"
|
413
|
+
end
|
414
|
+
end
|
415
|
+
|
416
|
+
desc "Fails if directories contain the files specified in .gitignore"
|
417
|
+
task :git_ignore do
|
418
|
+
matched = `git ls-files --ignored --exclude-standard`
|
419
|
+
unless matched == ""
|
420
|
+
puts matched
|
421
|
+
fail "File specified in .gitignore has been committed"
|
422
|
+
end
|
268
423
|
end
|
269
424
|
end
|
270
425
|
|
@@ -1,25 +1,88 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
1
4
|
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require "puppetlabs_spec_helper/version"
|
5
|
+
# stub: puppetlabs_spec_helper 1.1.0 ruby lib
|
4
6
|
|
5
7
|
Gem::Specification.new do |s|
|
6
|
-
s.name
|
7
|
-
s.version
|
8
|
-
|
9
|
-
s.
|
10
|
-
s.
|
11
|
-
s.
|
8
|
+
s.name = "puppetlabs_spec_helper"
|
9
|
+
s.version = "1.1.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["Puppet Labs"]
|
14
|
+
s.date = "2016-02-25"
|
12
15
|
s.description = "Contains rake tasks and a standard spec_helper for running spec tests on puppet modules"
|
13
|
-
s.
|
16
|
+
s.email = ["modules-dept@puppetlabs.com"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.markdown"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".noexec.yaml",
|
23
|
+
".travis.yml",
|
24
|
+
"CHANGELOG.md",
|
25
|
+
"CONTRIBUTING.md",
|
26
|
+
"Gemfile",
|
27
|
+
"LICENSE",
|
28
|
+
"README.markdown",
|
29
|
+
"Rakefile",
|
30
|
+
"lib/puppetlabs_spec_helper/module_spec_helper.rb",
|
31
|
+
"lib/puppetlabs_spec_helper/puppet_spec_helper.rb",
|
32
|
+
"lib/puppetlabs_spec_helper/puppetlabs_spec/files.rb",
|
33
|
+
"lib/puppetlabs_spec_helper/puppetlabs_spec/fixtures.rb",
|
34
|
+
"lib/puppetlabs_spec_helper/puppetlabs_spec/matchers.rb",
|
35
|
+
"lib/puppetlabs_spec_helper/puppetlabs_spec/puppet_internals.rb",
|
36
|
+
"lib/puppetlabs_spec_helper/puppetlabs_spec_helper.rb",
|
37
|
+
"lib/puppetlabs_spec_helper/rake_tasks.rb",
|
38
|
+
"lib/puppetlabs_spec_helper/version.rb",
|
39
|
+
"puppet_spec_helper.rb",
|
40
|
+
"puppetlabs_spec_helper.gemspec",
|
41
|
+
"puppetlabs_spec_helper.rb",
|
42
|
+
"spec/lib/puppet/type/spechelper.rb",
|
43
|
+
"spec/spec_helper.rb",
|
44
|
+
"spec/unit/puppetlabs_spec_helper/puppetlabs_spec/puppet_internals_spec.rb",
|
45
|
+
"spec/watchr.rb"
|
46
|
+
]
|
47
|
+
s.homepage = "http://github.com/puppetlabs/puppetlabs_spec_helper"
|
48
|
+
s.licenses = ["Apache-2.0"]
|
49
|
+
s.rubygems_version = "2.2.3"
|
50
|
+
s.summary = "Standard tasks and configuration for module spec tests"
|
14
51
|
|
15
|
-
s.
|
16
|
-
|
17
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
52
|
+
if s.respond_to? :specification_version then
|
53
|
+
s.specification_version = 4
|
18
54
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
55
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
56
|
+
s.add_runtime_dependency(%q<rake>, [">= 0"])
|
57
|
+
s.add_runtime_dependency(%q<rspec-puppet>, [">= 0"])
|
58
|
+
s.add_runtime_dependency(%q<puppet-lint>, [">= 0"])
|
59
|
+
s.add_runtime_dependency(%q<puppet-syntax>, [">= 0"])
|
60
|
+
s.add_runtime_dependency(%q<mocha>, [">= 0"])
|
61
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
62
|
+
s.add_development_dependency(%q<pry>, [">= 0"])
|
63
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
64
|
+
s.add_development_dependency(%q<puppet>, ["~> 3.8.3"])
|
65
|
+
else
|
66
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
67
|
+
s.add_dependency(%q<rspec-puppet>, [">= 0"])
|
68
|
+
s.add_dependency(%q<puppet-lint>, [">= 0"])
|
69
|
+
s.add_dependency(%q<puppet-syntax>, [">= 0"])
|
70
|
+
s.add_dependency(%q<mocha>, [">= 0"])
|
71
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
72
|
+
s.add_dependency(%q<pry>, [">= 0"])
|
73
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
74
|
+
s.add_dependency(%q<puppet>, ["~> 3.8.3"])
|
75
|
+
end
|
76
|
+
else
|
77
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
78
|
+
s.add_dependency(%q<rspec-puppet>, [">= 0"])
|
79
|
+
s.add_dependency(%q<puppet-lint>, [">= 0"])
|
80
|
+
s.add_dependency(%q<puppet-syntax>, [">= 0"])
|
81
|
+
s.add_dependency(%q<mocha>, [">= 0"])
|
82
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
83
|
+
s.add_dependency(%q<pry>, [">= 0"])
|
84
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
85
|
+
s.add_dependency(%q<puppet>, ["~> 3.8.3"])
|
86
|
+
end
|
25
87
|
end
|
88
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -1,32 +1,31 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'spec_helper'
|
3
2
|
require 'puppetlabs_spec_helper/puppet_spec_helper'
|
4
3
|
require 'puppetlabs_spec_helper/puppetlabs_spec/puppet_internals'
|
5
4
|
|
6
5
|
describe PuppetlabsSpec::PuppetInternals do
|
6
|
+
before(:all) do
|
7
|
+
Puppet.initialize_settings
|
8
|
+
end
|
7
9
|
describe ".scope" do
|
8
10
|
it "should return a Puppet::Parser::Scope instance" do
|
9
11
|
subject.scope.should be_a_kind_of Puppet::Parser::Scope
|
10
12
|
end
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
scope.function_split(["one;two", ";"]).should == [ 'one', 'two' ]
|
14
|
+
xit "should be suitable for function testing" do
|
15
|
+
# split is now a puppet 4x core function
|
16
|
+
subject.scope.function_split(["one;two", ";"]).should == [ 'one', 'two' ]
|
15
17
|
end
|
16
18
|
|
17
19
|
it "should accept a compiler" do
|
18
20
|
compiler = subject.compiler
|
19
|
-
|
20
21
|
scope = subject.scope(:compiler => compiler)
|
21
|
-
|
22
22
|
scope.compiler.should == compiler
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should have a source set" do
|
26
26
|
scope = subject.scope
|
27
|
-
|
28
27
|
scope.source.should_not be_nil
|
29
|
-
scope.source.
|
28
|
+
scope.source.name.should eq('foo')
|
30
29
|
end
|
31
30
|
end
|
32
31
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppetlabs_spec_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet Labs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -80,17 +80,76 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: jeweler
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: puppet
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 3.8.3
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 3.8.3
|
83
139
|
description: Contains rake tasks and a standard spec_helper for running spec tests
|
84
140
|
on puppet modules
|
85
141
|
email:
|
86
142
|
- modules-dept@puppetlabs.com
|
87
143
|
executables: []
|
88
144
|
extensions: []
|
89
|
-
extra_rdoc_files:
|
145
|
+
extra_rdoc_files:
|
146
|
+
- LICENSE
|
147
|
+
- README.markdown
|
90
148
|
files:
|
91
|
-
- ".gitignore"
|
92
149
|
- ".noexec.yaml"
|
150
|
+
- ".travis.yml"
|
93
151
|
- CHANGELOG.md
|
152
|
+
- CONTRIBUTING.md
|
94
153
|
- Gemfile
|
95
154
|
- LICENSE
|
96
155
|
- README.markdown
|
@@ -108,8 +167,8 @@ files:
|
|
108
167
|
- puppetlabs_spec_helper.gemspec
|
109
168
|
- puppetlabs_spec_helper.rb
|
110
169
|
- spec/lib/puppet/type/spechelper.rb
|
170
|
+
- spec/spec_helper.rb
|
111
171
|
- spec/unit/puppetlabs_spec_helper/puppetlabs_spec/puppet_internals_spec.rb
|
112
|
-
- spec/unit/spechelper_spec.rb
|
113
172
|
- spec/watchr.rb
|
114
173
|
homepage: http://github.com/puppetlabs/puppetlabs_spec_helper
|
115
174
|
licenses:
|
@@ -135,8 +194,5 @@ rubygems_version: 2.2.3
|
|
135
194
|
signing_key:
|
136
195
|
specification_version: 4
|
137
196
|
summary: Standard tasks and configuration for module spec tests
|
138
|
-
test_files:
|
139
|
-
|
140
|
-
- spec/unit/puppetlabs_spec_helper/puppetlabs_spec/puppet_internals_spec.rb
|
141
|
-
- spec/unit/spechelper_spec.rb
|
142
|
-
- spec/watchr.rb
|
197
|
+
test_files: []
|
198
|
+
has_rdoc:
|
data/.gitignore
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'puppetlabs_spec_helper/puppet_spec_helper'
|
3
|
-
|
4
|
-
# ensure we can access puppet settings outside of any example group
|
5
|
-
Puppet[:confdir]
|
6
|
-
|
7
|
-
# set modulepath from which to load custom type
|
8
|
-
Puppet[:modulepath] = File.join(File.dirname(__FILE__), '..', '..')
|
9
|
-
|
10
|
-
def should_be_able_to_load_types?
|
11
|
-
return true if Puppet::Test::TestHelper.respond_to?(:initialize)
|
12
|
-
|
13
|
-
case Puppet.version
|
14
|
-
when /^2\.7\.20/
|
15
|
-
false
|
16
|
-
when /^3\.0\./
|
17
|
-
false
|
18
|
-
else
|
19
|
-
true
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
# construct a top-level describe block whose declared_class is a custom type in this module
|
24
|
-
describe Puppet::Type.type(:spechelper) do
|
25
|
-
it "should load the type from the modulepath" do
|
26
|
-
pending("this is only supported on newer versions of puppet", :unless => should_be_able_to_load_types?) do
|
27
|
-
described_class.should be
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should have a doc string" do
|
32
|
-
pending("this is only supported on newer versions of puppet", :unless => should_be_able_to_load_types?) do
|
33
|
-
described_class.doc.should == "This is the spechelper type"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "Setup of settings" do
|
39
|
-
it "sets confdir and vardir to something not meaningful to force tests to make their choice explicit" do
|
40
|
-
Puppet[:confdir].should == "/dev/null"
|
41
|
-
Puppet[:vardir].should == "/dev/null"
|
42
|
-
end
|
43
|
-
end
|