Class: PuppetCatalogTest::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- PuppetCatalogTest::RakeTask
- Includes:
- Rake::DSL
- Defined in:
- lib/puppet-catalog-test/rake_task.rb
Instance Attribute Summary collapse
-
#config_dir ⇒ Object
Returns the value of attribute config_dir.
-
#exclude_pattern ⇒ Object
Returns the value of attribute exclude_pattern.
-
#facts ⇒ Object
Returns the value of attribute facts.
-
#include_pattern ⇒ Object
Returns the value of attribute include_pattern.
-
#manifest_path ⇒ Object
Returns the value of attribute manifest_path.
-
#module_paths ⇒ Object
Returns the value of attribute module_paths.
-
#parser ⇒ Object
Returns the value of attribute parser.
-
#reporter ⇒ Object
Returns the value of attribute reporter.
-
#scenario_yaml ⇒ Object
Returns the value of attribute scenario_yaml.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize(name, &task_block) ⇒ RakeTask
constructor
A new instance of RakeTask.
- #setup ⇒ Object
Constructor Details
#initialize(name, &task_block) ⇒ RakeTask
Returns a new instance of RakeTask.
19 20 21 22 23 24 25 26 |
# File 'lib/puppet-catalog-test/rake_task.rb', line 19 def initialize(name, &task_block) desc "Compile all puppet catalogs" unless ::Rake.application.last_comment task name do task_block.call(self) if task_block setup end end |
Instance Attribute Details
#config_dir ⇒ Object
Returns the value of attribute config_dir.
8 9 10 |
# File 'lib/puppet-catalog-test/rake_task.rb', line 8 def config_dir @config_dir end |
#exclude_pattern ⇒ Object
Returns the value of attribute exclude_pattern.
9 10 11 |
# File 'lib/puppet-catalog-test/rake_task.rb', line 9 def exclude_pattern @exclude_pattern end |
#facts ⇒ Object
Returns the value of attribute facts.
10 11 12 |
# File 'lib/puppet-catalog-test/rake_task.rb', line 10 def facts @facts end |
#include_pattern ⇒ Object
Returns the value of attribute include_pattern.
11 12 13 |
# File 'lib/puppet-catalog-test/rake_task.rb', line 11 def include_pattern @include_pattern end |
#manifest_path ⇒ Object
Returns the value of attribute manifest_path.
12 13 14 |
# File 'lib/puppet-catalog-test/rake_task.rb', line 12 def manifest_path @manifest_path end |
#module_paths ⇒ Object
Returns the value of attribute module_paths.
13 14 15 |
# File 'lib/puppet-catalog-test/rake_task.rb', line 13 def module_paths @module_paths end |
#parser ⇒ Object
Returns the value of attribute parser.
14 15 16 |
# File 'lib/puppet-catalog-test/rake_task.rb', line 14 def parser @parser end |
#reporter ⇒ Object
Returns the value of attribute reporter.
15 16 17 |
# File 'lib/puppet-catalog-test/rake_task.rb', line 15 def reporter @reporter end |
#scenario_yaml ⇒ Object
Returns the value of attribute scenario_yaml.
16 17 18 |
# File 'lib/puppet-catalog-test/rake_task.rb', line 16 def scenario_yaml @scenario_yaml end |
#verbose ⇒ Object
Returns the value of attribute verbose.
17 18 19 |
# File 'lib/puppet-catalog-test/rake_task.rb', line 17 def verbose @verbose end |
Instance Method Details
#setup ⇒ Object
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 |
# File 'lib/puppet-catalog-test/rake_task.rb', line 28 def setup puppet_config = { :config_dir => @config_dir, :manifest_path => @manifest_path, :module_paths => @module_paths, :parser => @parser, :verbose => @verbose } if @config_dir puppet_config[:hiera_config] = File.join(@config_dir, "hiera.yaml") end pct = TestRunner.new(puppet_config) @filter = Filter.new @filter.include_pattern = @include_pattern if @include_pattern @filter.exclude_pattern = @exclude_pattern if @exclude_pattern if @scenario_yaml pct.load_scenario_yaml(@scenario_yaml, @filter) else nodes = pct.collect_puppet_nodes(@filter) test_facts = @facts || fallback_facts nodes.each do |nodename| facts = test_facts.merge({ 'hostname' => nodename, 'fqdn' => "#{nodename}.localdomain" }) pct.add_test_case(nodename, facts) end end pct.reporter = @reporter if @reporter pct.run_tests! end |