controlrepo 2.0.3 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/controlrepo.rb CHANGED
@@ -5,8 +5,8 @@ require 'yaml'
5
5
  require 'find'
6
6
  require 'pathname'
7
7
  require 'controlrepo/beaker'
8
- begin
9
- require 'pry'
8
+ begin
9
+ require 'pry'
10
10
  rescue LoadError
11
11
  # We don't care if i'ts not here, this is just used for
12
12
  # debugging sometimes
@@ -23,6 +23,7 @@ class Controlrepo
23
23
  attr_accessor :spec_dir
24
24
  attr_accessor :temp_modulepath
25
25
  attr_accessor :nodeset_file
26
+ attr_accessor :manifest
26
27
 
27
28
  # Create methods on self so that we can access these basic things without
28
29
  # having to actually instantiate the class, I'm debating how much stuff
@@ -97,6 +98,7 @@ class Controlrepo
97
98
  @temp_environmentpath = nil
98
99
  @tempdir = nil
99
100
  $temp_modulepath = nil
101
+ @manifest = config['manifest'] ? File.expand_path(config['manifest'],@root) : nil
100
102
  end
101
103
 
102
104
  def to_s
@@ -108,7 +110,7 @@ class Controlrepo
108
110
  facts_files: #{@facts_files}
109
111
  nodeset_file: #{@nodeset_file}
110
112
  roles: #{roles}
111
- profiles #{profiles}
113
+ profiles: #{profiles}
112
114
  END
113
115
  end
114
116
 
@@ -285,6 +287,10 @@ class Controlrepo
285
287
  File.write(r10k_config_file,data.to_yaml)
286
288
  end
287
289
 
290
+ def temp_manifest
291
+ config['manifest'] ? File.expand_path(config['manifest'],@tempdir) : nil
292
+ end
293
+
288
294
  private
289
295
 
290
296
  def read_facts(facts_file)
@@ -341,4 +347,4 @@ class Controlrepo
341
347
  end
342
348
  return nil
343
349
  end
344
- end
350
+ end
@@ -24,7 +24,7 @@ class Controlrepo
24
24
  begin
25
25
  if facts['os']['distro']['id'] == 'Debian'
26
26
  os = 'Debian'
27
- version = "#{facts['os']['distro']['release']['major']}.#{facts['os']['distro']['release']['minor']}"
27
+ version = facts['os']['distro']['release']['full']
28
28
  end
29
29
  rescue
30
30
  # Do nothing
@@ -80,8 +80,11 @@ task :controlrepo_autotest_prep do
80
80
  @config = Controlrepo::TestConfig.new("#{@repo.spec_dir}/controlrepo.yaml")
81
81
 
82
82
  # Verify that all the files exist for the tests we have set up
83
- @config.spec_tests.each { |test| @config.verify_spec_test(@repo,test) }
84
- @config.acceptance_tests.each { |test| @config.verify_acceptance_test(@repo,test) }
83
+ if Rake.application.top_level_tasks[0] == "controlrepo_spec"
84
+ @config.spec_tests.each { |test| @config.verify_spec_test(@repo,test) }
85
+ elsif Rake.application.top_level_tasks[0] == "controlrepo_acceptance"
86
+ @config.acceptance_tests.each { |test| @config.verify_acceptance_test(@repo,test) }
87
+ end
85
88
 
86
89
  # Deploy r10k to a temp dir
87
90
  @config.r10k_deploy_local(@repo)
@@ -161,8 +164,3 @@ task :r10k_deploy_local do
161
164
  # Deploy r10k to a temp dir
162
165
  config.r10k_deploy_local(repo)
163
166
  end
164
-
165
- # TODO: We could use rspec's tagging abilities to choose which if the acceptance tests to run.
166
-
167
-
168
-
@@ -113,7 +113,6 @@ class Controlrepo
113
113
  # This should take an array of tests and remove any duplicates from them
114
114
 
115
115
  # this will be an array of arrays, or maybe hashes
116
- # TODO: Rewrite this so that it merges options hashes, or takes one, decide on the right behaviour
117
116
  combinations = []
118
117
  new_tests = []
119
118
  tests.each do |test|
@@ -19,7 +19,9 @@ class Controlrepo
19
19
  def initialize(file, environment = ENV['CONTROLREPO_env'])
20
20
  begin
21
21
  config = YAML.load(File.read(file))
22
- rescue YAML::ParserError
22
+ rescue Errno::ENOENT
23
+ raise "Could not find spec/controlrepo.yaml"
24
+ rescue Psych::SyntaxError
23
25
  raise "Could not parse the YAML file, check that it is valid YAML and that the encoding is correct"
24
26
  end
25
27
 
@@ -96,7 +98,7 @@ class Controlrepo
96
98
  Dir["#{spec_dir}/pre_conditions/*.pp"].each do |condition_file|
97
99
  puppetcode << File.read(condition_file)
98
100
  end
99
- return false if puppetcode.count == 0
101
+ return nil if puppetcode.count == 0
100
102
  puppetcode.join("\n")
101
103
  end
102
104
 
@@ -184,12 +186,5 @@ class Controlrepo
184
186
  end
185
187
  end
186
188
  end
187
-
188
- # TODO: Work out the best way to format the output
189
- # TODO: Look into bundling bundler into the temp dir
190
- # TODO: Write task for beaker tests *brace yourself* Dont forget about the beaker file you have
191
- # TODO: Compare the outlout of the beaker helper that I wrote
192
- # with the output from the templated tests, us ethe better one
193
- # bearing in minf that beaker has logger options that could help
194
189
  end
195
190
  end
@@ -2,6 +2,8 @@ require 'puppetlabs_spec_helper/module_spec_helper'
2
2
 
3
3
  RSpec.configure do |c|
4
4
  c.parser = 'future'
5
+ c.environmentpath = '<%= environmentpath %>'
5
6
  c.module_path = '<%= modulepath %>'
6
7
  c.hiera_config = '<%= environmentpath %>/<%= @environment %>/hiera.yaml'
7
- end
8
+ c.manifest = '<%= repo.temp_manifest %>'
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: controlrepo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Ratcliffe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-20 00:00:00.000000000 Z
11
+ date: 2016-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -150,7 +150,7 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
- description: ''
153
+ description: Testing tools for Puppet controlrepos
154
154
  email:
155
155
  - dylan.ratcliffe@puppetlabs.com
156
156
  executables: []
@@ -163,10 +163,18 @@ files:
163
163
  - README.md
164
164
  - Rakefile
165
165
  - controlrepo.gemspec
166
+ - factsets/CentOS-5.11-32.json
167
+ - factsets/CentOS-5.11-64.json
168
+ - factsets/CentOS-6.6-32.json
166
169
  - factsets/CentOS-6.6-64.json
167
170
  - factsets/CentOS-7.0-64.json
171
+ - factsets/Debian-6.0.10-32.json
172
+ - factsets/Debian-6.0.10-64.json
173
+ - factsets/Debian-7.8-32.json
168
174
  - factsets/Debian-7.8-64.json
169
175
  - factsets/Ubuntu-12.04-32.json
176
+ - factsets/Ubuntu-12.04-64.json
177
+ - factsets/Ubuntu-14.04-32.json
170
178
  - factsets/Ubuntu-14.04-64.json
171
179
  - factsets/Windows_Server-2008r2-64.json
172
180
  - factsets/Windows_Server-2012r2-64.json
@@ -186,7 +194,7 @@ files:
186
194
  - templates/spec_helper.rb.erb
187
195
  - templates/spec_helper_acceptance.rb.erb
188
196
  - templates/test_spec.rb.erb
189
- homepage: ''
197
+ homepage: https://github.com/dylanratcliffe/controlrepo_gem
190
198
  licenses:
191
199
  - Apache-2.0
192
200
  metadata: {}
@@ -209,5 +217,5 @@ rubyforge_project:
209
217
  rubygems_version: 2.4.6
210
218
  signing_key:
211
219
  specification_version: 4
212
- summary: ''
220
+ summary: Testing tools for Puppet controlrepos
213
221
  test_files: []