puppet 5.0.0-universal-darwin → 5.0.1-universal-darwin

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (101) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1 -1
  3. data/ext/puppet-test +1 -1
  4. data/lib/puppet.rb +3 -1
  5. data/lib/puppet/application/lookup.rb +2 -2
  6. data/lib/puppet/defaults.rb +1 -1
  7. data/lib/puppet/face/epp.rb +26 -24
  8. data/lib/puppet/face/module/search.rb +1 -1
  9. data/lib/puppet/forge.rb +3 -2
  10. data/lib/puppet/functions/each.rb +1 -1
  11. data/lib/puppet/functions/filter.rb +1 -1
  12. data/lib/puppet/module.rb +28 -1
  13. data/lib/puppet/module_tool.rb +2 -2
  14. data/lib/puppet/module_tool/applications/installer.rb +5 -5
  15. data/lib/puppet/module_tool/applications/uninstaller.rb +1 -1
  16. data/lib/puppet/module_tool/applications/upgrader.rb +5 -5
  17. data/lib/puppet/module_tool/shared_behaviors.rb +2 -2
  18. data/lib/puppet/parser/compiler.rb +4 -0
  19. data/lib/puppet/parser/functions/assert_type.rb +1 -1
  20. data/lib/puppet/parser/functions/binary_file.rb +1 -1
  21. data/lib/puppet/parser/functions/break.rb +1 -1
  22. data/lib/puppet/parser/functions/defined.rb +1 -1
  23. data/lib/puppet/parser/functions/dig.rb +1 -1
  24. data/lib/puppet/parser/functions/each.rb +2 -2
  25. data/lib/puppet/parser/functions/epp.rb +1 -1
  26. data/lib/puppet/parser/functions/filter.rb +2 -2
  27. data/lib/puppet/parser/functions/find_file.rb +1 -1
  28. data/lib/puppet/parser/functions/inline_epp.rb +1 -1
  29. data/lib/puppet/parser/functions/lest.rb +1 -1
  30. data/lib/puppet/parser/functions/map.rb +1 -1
  31. data/lib/puppet/parser/functions/match.rb +1 -1
  32. data/lib/puppet/parser/functions/new.rb +1 -1
  33. data/lib/puppet/parser/functions/next.rb +1 -1
  34. data/lib/puppet/parser/functions/reduce.rb +1 -1
  35. data/lib/puppet/parser/functions/return.rb +1 -1
  36. data/lib/puppet/parser/functions/reverse_each.rb +2 -2
  37. data/lib/puppet/parser/functions/slice.rb +1 -1
  38. data/lib/puppet/parser/functions/step.rb +2 -2
  39. data/lib/puppet/parser/functions/strftime.rb +1 -1
  40. data/lib/puppet/parser/functions/then.rb +1 -1
  41. data/lib/puppet/parser/functions/type.rb +1 -1
  42. data/lib/puppet/parser/functions/with.rb +1 -1
  43. data/lib/puppet/pops/merge_strategy.rb +1 -1
  44. data/lib/puppet/pops/time/timestamp.rb +2 -2
  45. data/lib/puppet/provider/nameservice.rb +4 -2
  46. data/lib/puppet/reference/configuration.rb +1 -1
  47. data/lib/puppet/reports/http.rb +4 -2
  48. data/lib/puppet/resource/capability_finder.rb +1 -1
  49. data/lib/puppet/util/execution.rb +1 -1
  50. data/lib/puppet/util/logging.rb +8 -4
  51. data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/gem_version.rb +1 -1
  52. data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version.rb +1 -1
  53. data/lib/puppet/version.rb +1 -1
  54. data/locales/puppet.pot +66 -58
  55. data/man/man5/puppet.conf.5 +233 -63
  56. data/man/man8/puppet-agent.8 +31 -9
  57. data/man/man8/puppet-apply.8 +20 -5
  58. data/man/man8/puppet-ca.8 +48 -34
  59. data/man/man8/puppet-catalog.8 +12 -15
  60. data/man/man8/puppet-cert.8 +23 -6
  61. data/man/man8/puppet-certificate.8 +52 -36
  62. data/man/man8/puppet-certificate_request.8 +10 -10
  63. data/man/man8/puppet-certificate_revocation_list.8 +9 -9
  64. data/man/man8/puppet-config.8 +5 -5
  65. data/man/man8/puppet-describe.8 +3 -3
  66. data/man/man8/puppet-device.8 +13 -5
  67. data/man/man8/puppet-doc.8 +5 -5
  68. data/man/man8/puppet-epp.8 +16 -10
  69. data/man/man8/puppet-facts.8 +9 -9
  70. data/man/man8/puppet-filebucket.8 +44 -5
  71. data/man/man8/puppet-generate.8 +84 -0
  72. data/man/man8/puppet-help.8 +4 -4
  73. data/man/man8/puppet-key.8 +11 -11
  74. data/man/man8/puppet-lookup.8 +104 -0
  75. data/man/man8/puppet-man.8 +5 -5
  76. data/man/man8/puppet-master.8 +5 -5
  77. data/man/man8/puppet-module.8 +29 -17
  78. data/man/man8/puppet-node.8 +9 -9
  79. data/man/man8/puppet-parser.8 +4 -4
  80. data/man/man8/puppet-plugin.8 +4 -4
  81. data/man/man8/puppet-report.8 +9 -9
  82. data/man/man8/puppet-resource.8 +4 -8
  83. data/man/man8/puppet-status.8 +9 -9
  84. data/man/man8/puppet.8 +12 -3
  85. data/spec/integration/util/execution_spec.rb +8 -0
  86. data/spec/unit/application/lookup_spec.rb +1 -1
  87. data/spec/unit/face/epp_face_spec.rb +9 -0
  88. data/spec/unit/face/module/search_spec.rb +1 -1
  89. data/spec/unit/functions/lookup_spec.rb +26 -0
  90. data/spec/unit/indirector/file_bucket_file/file_spec.rb +3 -3
  91. data/spec/unit/module_spec.rb +64 -0
  92. data/spec/unit/module_tool_spec.rb +22 -0
  93. data/spec/unit/parser/scope_spec.rb +1 -1
  94. data/spec/unit/pops/types/p_timestamp_type_spec.rb +30 -1
  95. data/spec/unit/puppet_spec.rb +33 -0
  96. data/spec/unit/util/logging_spec.rb +18 -9
  97. data/tasks/generate_ast_model.rake +48 -44
  98. data/tasks/manpages.rake +9 -1
  99. data/tasks/parallel.rake +12 -7
  100. metadata +3515 -3526
  101. data/man/man8/puppet-inspect.8 +0 -36
data/man/man8/puppet.8 CHANGED
@@ -1,10 +1,19 @@
1
1
  .\" generated with Ronn/v0.7.3
2
- .\" https://github.com/rtomayko/ronn/tree/0.7.3
2
+ .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "PUPPET" "8" "May 2015" "Puppet Labs, LLC" "Puppet manual"
4
+ .TH "PUPPET" "8" "June 2017" "Puppet Labs, LLC" "Puppet manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBpuppet\fR
8
8
  .
9
9
  .P
10
- [1;31mError: Could not parse application options: invalid option: \-\-help[0m
10
+ Usage: puppet \fIsubcommand\fR [options] \fIaction\fR [options]
11
+ .
12
+ .P
13
+ Available subcommands:
14
+ .
15
+ .P
16
+ agent The puppet agent daemon apply Apply Puppet manifests locally ca Local Puppet Certificate Authority management\. (Deprecated) catalog Compile, save, view, and convert catalogs\. cert Manage certificates and requests certificate Provide access to the CA for certificate management\. certificate_request Manage certificate requests\. (Deprecated) certificate_revocation_list Manage the list of revoked certificates\. (Deprecated) config Interact with Puppet\'s settings\. describe Display help about resource types device Manage remote network devices doc Generate Puppet references epp Interact directly with the EPP template parser/renderer\. facts Retrieve and store facts\. filebucket Store and retrieve files in a filebucket generate Generates Puppet code from Ruby definitions\. help Display Puppet help\. key Create, save, and remove certificate keys\. (Deprecated) lookup Interactive Hiera lookup man Display Puppet manual pages\. master The puppet master daemon module Creates, installs and searches for modules on the Puppet Forge\. node View and manage node definitions\. parser Interact directly with the parser\. plugin Interact with the Puppet plugin system\. report Create, display, and submit reports\. resource The resource abstraction layer shell status View puppet server status\. (Deprecated)
17
+ .
18
+ .P
19
+ See \'puppet help \fIsubcommand\fR \fIaction\fR\' for help on a specific subcommand action\. See \'puppet help \fIsubcommand\fR\' for help on a specific subcommand\. Puppet v5\.0\.0
@@ -15,6 +15,14 @@ describe Puppet::Util::Execution do
15
15
  Puppet::Util::Execution.execpipe('echo $LC_ALL'){ |line| out << line.read.chomp }
16
16
  expect(out).to eq("C")
17
17
  end
18
+
19
+ it "should raise an ExecutionFailure with a missing command and :failonfail set to true" do
20
+ expect {
21
+ failonfail = true
22
+ # NOTE: critical to return l in the block for `output` in method to be #<IO:(closed)>
23
+ Puppet::Util::Execution.execpipe('conan_the_librarion', failonfail) { |l| l }
24
+ }.to raise_error(Puppet::ExecutionFailure)
25
+ end
18
26
  end
19
27
 
20
28
  describe "#execute (non-Windows)", :if => !Puppet.features.microsoft_windows? do
@@ -59,7 +59,7 @@ describe Puppet::Application::Lookup do
59
59
  lookup.command_line.stubs(:args).returns(['atton', 'kreia'])
60
60
  lookup.stubs(:generate_scope).yields('scope')
61
61
 
62
- expected_merge = { "strategy" => "deep", "sort_merge_arrays" => false, "merge_hash_arrays" => true }
62
+ expected_merge = { "strategy" => "deep", "sort_merged_arrays" => false, "merge_hash_arrays" => true }
63
63
 
64
64
  (Puppet::Pops::Lookup).expects(:lookup).with(['atton', 'kreia'], nil, nil, false, expected_merge, anything).returns('rand')
65
65
 
@@ -237,6 +237,15 @@ describe Puppet::Face[:epp, :current] do
237
237
  expect(eppface.render({ :e => 'trusted is hash: <%= $trusted =~ Hash %>' })).to eql("trusted is hash: true")
238
238
  end
239
239
 
240
+ it 'initializes the 4x loader' do
241
+ expect(eppface.render({ :e => <<-EPP.unindent })).to eql("\nString\n\nInteger\n\nBoolean\n")
242
+ <% $data = [type('a',generalized), type(2,generalized), type(true)] -%>
243
+ <% $data.each |$value| { %>
244
+ <%= $value %>
245
+ <% } -%>
246
+ EPP
247
+ end
248
+
240
249
  it "facts can be added to" do
241
250
  expect(eppface.render({
242
251
  :facts => {'the_crux' => 'biscuit'},
@@ -176,7 +176,7 @@ describe "puppet module search" do
176
176
  searcher = mock("Searcher")
177
177
  options[:module_repository] = "http://forge.example.com"
178
178
 
179
- Puppet::Forge.expects(:new).with().returns(forge)
179
+ Puppet::Forge.expects(:new).with("http://forge.example.com", false).returns(forge)
180
180
  Puppet::ModuleTool::Applications::Searcher.expects(:new).with("puppetlabs-apache", forge, has_entries(options)).returns(searcher)
181
181
  searcher.expects(:run)
182
182
 
@@ -951,6 +951,8 @@ describe "The lookup function" do
951
951
  bab: bab (from environment)
952
952
  bc:
953
953
  bca: bca (from environment)
954
+ sa:
955
+ sa1: ['e', 'd', '--f']
954
956
  YAML
955
957
  'second.yaml' => <<-YAML.unindent,
956
958
  a:
@@ -964,6 +966,8 @@ describe "The lookup function" do
964
966
  c:
965
967
  ca:
966
968
  cab: c.ca.cab
969
+ sa:
970
+ sa1: ['b', 'a', 'f', 'c']
967
971
  YAML
968
972
  }
969
973
  end
@@ -1044,6 +1048,28 @@ describe "The lookup function" do
1044
1048
  expect(lookup('a')).to eql({'aa' => { 'aaa' => 'a.aa.aaa', 'aab' => 'a.aa.aab' }})
1045
1049
  end
1046
1050
  end
1051
+
1052
+ context 'and lookup options use a hash' do
1053
+
1054
+ let(:env_lookup_options) { <<-YAML.unindent }
1055
+ lookup_options:
1056
+ 'sa':
1057
+ merge:
1058
+ strategy: deep
1059
+ knockout_prefix: --
1060
+ sort_merged_arrays: true
1061
+ YAML
1062
+
1063
+ it 'applies knockout_prefix and sort_merged_arrays' do
1064
+ expect(lookup('sa')).to eql({ 'sa1' => %w(a b c d e) })
1065
+ end
1066
+
1067
+ it 'overrides knockout_prefix and sort_merged_arrays with explicitly given values' do
1068
+ expect(
1069
+ lookup('sa', 'merge' => { 'strategy' => 'deep', 'knockout_prefix' => '##', 'sort_merged_arrays' => false })).to(
1070
+ eql({ 'sa1' => %w(b a f c e d --f) }))
1071
+ end
1072
+ end
1047
1073
  end
1048
1074
 
1049
1075
  context 'and an environment Hiera v5 configuration using globs' do
@@ -41,16 +41,16 @@ describe Puppet::FileBucketFile::File, :uses_checksums => true do
41
41
  end
42
42
 
43
43
  it "fails if the contents collide with existing contents" do
44
- # This is the shortest known MD5 collision. See https://eprint.iacr.org/2010/643.pdf
44
+ # This is the shortest known MD5 collision (little endian). See https://eprint.iacr.org/2010/643.pdf
45
45
  first_contents = [0x6165300e,0x87a79a55,0xf7c60bd0,0x34febd0b,
46
46
  0x6503cf04,0x854f709e,0xfb0fc034,0x874c9c65,
47
47
  0x2f94cc40,0x15a12deb,0x5c15f4a3,0x490786bb,
48
- 0x6d658673,0xa4341f7d,0x8fd75920,0xefd18d5a].pack("I" * 16)
48
+ 0x6d658673,0xa4341f7d,0x8fd75920,0xefd18d5a].pack("V" * 16)
49
49
 
50
50
  collision_contents = [0x6165300e,0x87a79a55,0xf7c60bd0,0x34febd0b,
51
51
  0x6503cf04,0x854f749e,0xfb0fc034,0x874c9c65,
52
52
  0x2f94cc40,0x15a12deb,0xdc15f4a3,0x490786bb,
53
- 0x6d658673,0xa4341f7d,0x8fd75920,0xefd18d5a].pack("I" * 16)
53
+ 0x6d658673,0xa4341f7d,0x8fd75920,0xefd18d5a].pack("V" * 16)
54
54
 
55
55
  checksum_value = save_bucket_file(first_contents, "/foo/bar")
56
56
 
@@ -819,4 +819,68 @@ describe Puppet::Module do
819
819
  }
820
820
  ])
821
821
  end
822
+
823
+ context 'when parsing VersionRange' do
824
+ let(:logs) { [] }
825
+ let(:notices) { logs.select { |log| log.level == :notice }.map { |log| log.message } }
826
+
827
+ it 'can parse a strict range' do
828
+ expect(Puppet::Module.parse_range('>=1.0.0', true).include?(SemanticPuppet::Version.parse('1.0.1-rc1'))).to be_falsey
829
+ end
830
+
831
+ it 'can parse a non-strict range' do
832
+ expect(Puppet::Module.parse_range('>=1.0.0', false).include?(SemanticPuppet::Version.parse('1.0.1-rc1'))).to be_truthy
833
+ end
834
+
835
+ context 'using parse method with an arity of 1' do
836
+ around(:each) do |example|
837
+ begin
838
+ example.run
839
+ ensure
840
+ Puppet::Module.instance_variable_set(:@semver_gem_version, nil)
841
+ Puppet::Module.instance_variable_set(:@parse_range_method, nil)
842
+ end
843
+ end
844
+
845
+ it 'will notify when non-strict ranges cannot be parsed' do
846
+ Puppet::Module.instance_variable_set(:@semver_gem_version, SemanticPuppet::Version.parse('1.0.0'))
847
+ Puppet::Module.instance_variable_set(:@parse_range_method, Proc.new { |str| SemanticPuppet::VersionRange.parse(str, true) })
848
+
849
+ Puppet::Util::Log.with_destination(Puppet::Test::LogCollector.new(logs)) do
850
+ expect(Puppet::Module.parse_range('>=1.0.0', false).include?(SemanticPuppet::Version.parse('1.0.1-rc1'))).to be_falsey
851
+ end
852
+ expect(notices).to include(/VersionRanges will always be strict when using non-vendored SemanticPuppet gem, version 1\.0\.0/)
853
+ end
854
+
855
+ it 'will notify when strict ranges cannot be parsed' do
856
+ Puppet::Module.instance_variable_set(:@semver_gem_version, SemanticPuppet::Version.parse('0.1.4'))
857
+ Puppet::Module.instance_variable_set(:@parse_range_method, Proc.new { |str| SemanticPuppet::VersionRange.parse(str, false) })
858
+
859
+ Puppet::Util::Log.with_destination(Puppet::Test::LogCollector.new(logs)) do
860
+ expect(Puppet::Module.parse_range('>=1.0.0', true).include?(SemanticPuppet::Version.parse('1.0.1-rc1'))).to be_truthy
861
+ end
862
+ expect(notices).to include(/VersionRanges will never be strict when using non-vendored SemanticPuppet gem, version 0\.1\.4/)
863
+ end
864
+
865
+ it 'will not notify when strict ranges can be parsed' do
866
+ Puppet::Module.instance_variable_set(:@semver_gem_version, SemanticPuppet::Version.parse('1.0.0'))
867
+ Puppet::Module.instance_variable_set(:@parse_range_method, Proc.new { |str| SemanticPuppet::VersionRange.parse(str, true) })
868
+
869
+ Puppet::Util::Log.with_destination(Puppet::Test::LogCollector.new(logs)) do
870
+ expect(Puppet::Module.parse_range('>=1.0.0', true).include?(SemanticPuppet::Version.parse('1.0.1-rc1'))).to be_falsey
871
+ end
872
+ expect(notices).to be_empty
873
+ end
874
+
875
+ it 'will not notify when non-strict ranges can be parsed' do
876
+ Puppet::Module.instance_variable_set(:@semver_gem_version, SemanticPuppet::Version.parse('0.1.4'))
877
+ Puppet::Module.instance_variable_set(:@parse_range_method, Proc.new { |str| SemanticPuppet::VersionRange.parse(str, false) })
878
+
879
+ Puppet::Util::Log.with_destination(Puppet::Test::LogCollector.new(logs)) do
880
+ expect(Puppet::Module.parse_range('>=1.0.0', false).include?(SemanticPuppet::Version.parse('1.0.1-rc1'))).to be_truthy
881
+ end
882
+ expect(notices).to be_empty
883
+ end
884
+ end
885
+ end
822
886
  end
@@ -229,6 +229,28 @@ TREE
229
229
  end
230
230
  end
231
231
 
232
+ describe ':strict_semver' do
233
+ context 'when set' do
234
+ let(:options) do
235
+ { :strict_semver => true }
236
+ end
237
+
238
+ it 'is not overridden by default' do
239
+ expect(subject).to include :strict_semver => true
240
+ end
241
+ end
242
+
243
+ context 'when unset' do
244
+ let(:options) do
245
+ { }
246
+ end
247
+
248
+ it 'defaults to false' do
249
+ expect(subject).to include :strict_semver => false
250
+ end
251
+ end
252
+ end
253
+
232
254
  describe ':target_dir' do
233
255
  let(:options) do
234
256
  { :target_dir => 'foo' }
@@ -210,7 +210,7 @@ describe Puppet::Parser::Scope do
210
210
  end
211
211
 
212
212
  it "warns once for a non found variable" do
213
- Puppet.expects(:warning).once
213
+ Puppet.expects(:send_log).with(:warning, is_a(String)).once
214
214
  expect([@scope["santa_claus"],@scope["santa_claus"]]).to eq([nil, nil])
215
215
  end
216
216
 
@@ -51,7 +51,7 @@ describe 'Timestamp type' do
51
51
  end
52
52
 
53
53
  context 'a Timestamp instance' do
54
- it 'can be created from a string' do
54
+ it 'can be created from a string with just a date' do
55
55
  code = <<-CODE
56
56
  $o = Timestamp('2015-03-01')
57
57
  notice($o)
@@ -60,6 +60,35 @@ describe 'Timestamp type' do
60
60
  expect(eval_and_collect_notices(code)).to eq(['2015-03-01T00:00:00.000000000 UTC', "Timestamp['2015-03-01T00:00:00.000000000 UTC']"])
61
61
  end
62
62
 
63
+ it 'can be created from a string and time separated by "T"' do
64
+ code = <<-CODE
65
+ notice(Timestamp('2015-03-01T11:12:13'))
66
+ CODE
67
+ expect(eval_and_collect_notices(code)).to eq(['2015-03-01T11:12:13.000000000 UTC'])
68
+ end
69
+
70
+ it 'can be created from a string and time separated by space' do
71
+ code = <<-CODE
72
+ notice(Timestamp('2015-03-01 11:12:13'))
73
+ CODE
74
+ expect(eval_and_collect_notices(code)).to eq(['2015-03-01T11:12:13.000000000 UTC'])
75
+ end
76
+
77
+ it 'should error when none of the default formats can parse the string' do
78
+ code = <<-CODE
79
+ notice(Timestamp('2015#03#01 11:12:13'))
80
+ CODE
81
+ expect { eval_and_collect_notices(code) }.to raise_error(/Unable to parse/)
82
+ end
83
+
84
+ it 'should error when only part of the string is parsed' do
85
+ pending("Requires full rewrite of Timestamp parse since there's no way to detect trailing garbage using DateTime#strptime")
86
+ code = <<-CODE
87
+ notice(Timestamp('2015-03-01T11:12:13 bogus after'))
88
+ CODE
89
+ expect { eval_and_collect_notices(code) }.to raise_error(/Unable to parse/)
90
+ end
91
+
63
92
  it 'can be created from a string and format' do
64
93
  code = <<-CODE
65
94
  $o = Timestamp('Sunday, 28 August, 2016', '%A, %d %B, %Y')
@@ -38,6 +38,39 @@ describe Puppet do
38
38
  expect($LOAD_PATH).to include two
39
39
  end
40
40
 
41
+ it 'should propagate --modulepath to base environment' do
42
+ Puppet::Node::Environment.expects(:create).with(
43
+ is_a(Symbol), ['/my/modules'], Puppet::Node::Environment::NO_MANIFEST)
44
+
45
+ Puppet.base_context({
46
+ :environmentpath => '/envs',
47
+ :basemodulepath => '/base/modules',
48
+ :modulepath => '/my/modules'
49
+ })
50
+ end
51
+
52
+ it 'empty modulepath does not override basemodulepath' do
53
+ Puppet::Node::Environment.expects(:create).with(
54
+ is_a(Symbol), ['/base/modules'], Puppet::Node::Environment::NO_MANIFEST)
55
+
56
+ Puppet.base_context({
57
+ :environmentpath => '/envs',
58
+ :basemodulepath => '/base/modules',
59
+ :modulepath => ''
60
+ })
61
+ end
62
+
63
+ it 'nil modulepath does not override basemodulepath' do
64
+ Puppet::Node::Environment.expects(:create).with(
65
+ is_a(Symbol), ['/base/modules'], Puppet::Node::Environment::NO_MANIFEST)
66
+
67
+ Puppet.base_context({
68
+ :environmentpath => '/envs',
69
+ :basemodulepath => '/base/modules',
70
+ :modulepath => nil
71
+ })
72
+ end
73
+
41
74
  context "Puppet::OLDEST_RECOMMENDED_RUBY_VERSION" do
42
75
  it "should have an oldest recommended ruby version constant" do
43
76
  expect(Puppet::OLDEST_RECOMMENDED_RUBY_VERSION).not_to be_nil
@@ -184,30 +184,39 @@ describe Puppet::Util::Logging do
184
184
  after(:each) {
185
185
  # this is required because of bugs in Mocha whe tearing down expectations for each test
186
186
  # why it works elsewhere is a mystery.
187
- @logger.unstub(:warning)
187
+ @logger.unstub(:send_log)
188
188
  }
189
189
 
190
190
  it "warns with file when only file is given" do
191
- @logger.expects(:warning).with(regexp_matches(/wet paint.*\(in aFile\)/m))
191
+ @logger.expects(:send_log).with(:warning, regexp_matches(/wet paint.*\(in aFile\)/m))
192
192
  @logger.warn_once('kind', 'wp', "wet paint", 'aFile')
193
193
  end
194
194
 
195
195
  it "warns with unknown file and line when only line is given" do
196
- @logger.expects(:warning).with(regexp_matches(/wet paint.*\(in unknown file, line 5\)/m))
196
+ @logger.expects(:send_log).with(:warning, regexp_matches(/wet paint.*\(in unknown file, line 5\)/m))
197
197
  @logger.warn_once('kind', 'wp', "wet paint", nil, 5)
198
198
  end
199
199
 
200
200
  it "warns with file and line when both are given" do
201
- @logger.expects(:warning).with(regexp_matches(/wet paint.*\(at aFile:5\)/m))
201
+ @logger.expects(:send_log).with(:warning, regexp_matches(/wet paint.*\(at aFile:5\)/m))
202
202
  @logger.warn_once('kind', 'wp', "wet paint",'aFile', 5)
203
203
  end
204
204
 
205
205
  it "warns once per key" do
206
- @logger.expects(:warning).with(regexp_matches(/wet paint.*/m)).once
206
+ @logger.expects(:send_log).with(:warning, regexp_matches(/wet paint.*/m)).once
207
207
  5.times do
208
208
  @logger.warn_once('kind', 'wp', "wet paint")
209
209
  end
210
210
  end
211
+
212
+ Puppet::Util::Log.eachlevel do |level|
213
+ it "can use log level #{level}" do
214
+ @logger.expects(:send_log).with(level, regexp_matches(/wet paint.*/m)).once
215
+ 5.times do
216
+ @logger.warn_once('kind', 'wp', "wet paint", nil, nil, level)
217
+ end
218
+ end
219
+ end
211
220
  end
212
221
 
213
222
  describe "does not warn about undefined variables when disabled_warnings says so" do
@@ -219,11 +228,11 @@ describe Puppet::Util::Logging do
219
228
  Puppet[:disable_warnings] = ['undefined_variables']
220
229
  example.run
221
230
  Puppet[:disable_warnings] = []
222
- logger.unstub(:warning)
231
+ logger.unstub(:send_log)
223
232
  end
224
233
 
225
234
  it "does not produce warning if kind is disabled" do
226
- logger.expects(:warning).never
235
+ logger.expects(:send_log).never
227
236
  logger.warn_once('undefined_variables', 'wp', "wet paint")
228
237
  end
229
238
  end
@@ -237,11 +246,11 @@ describe Puppet::Util::Logging do
237
246
  Puppet[:disable_warnings] = ['deprecations']
238
247
  example.run
239
248
  Puppet[:disable_warnings] = []
240
- logger.unstub(:warning)
249
+ logger.unstub(:send_log)
241
250
  end
242
251
 
243
252
  it "produces warning even if deprecation warnings are disabled " do
244
- logger.expects(:warning).once
253
+ logger.expects(:send_log).with(:warning, regexp_matches(/wet paint/)).once
245
254
  logger.warn_once('undefined_variables', 'wp', "wet paint")
246
255
  end
247
256
  end
@@ -1,53 +1,56 @@
1
- require 'puppet'
2
-
3
- desc "Generate the Pcore model that represents the AST for the Puppet Language"
4
- task :gen_pcore_ast do
5
- Puppet::Pops.generate_ast
6
- end
1
+ begin
2
+ require 'puppet'
3
+ rescue LoadError
4
+ #nothing to see here
5
+ else
6
+ desc "Generate the Pcore model that represents the AST for the Puppet Language"
7
+ task :gen_pcore_ast do
8
+ Puppet::Pops.generate_ast
9
+ end
7
10
 
8
- module Puppet::Pops
9
- def self.generate_ast
10
- Puppet.initialize_settings
11
- env = Puppet.lookup(:environments).get(Puppet[:environment])
12
- loaders = Loaders.new(env)
13
- ast_pp = Pathname(__FILE__).parent.parent + 'lib/puppet/pops/model/ast.pp'
14
- Puppet.override(:current_environment => env, :loaders => loaders) do
15
- ast_factory = Parser::Parser.new.parse_file(ast_pp.expand_path.to_s)
16
- ast_model = Types::TypeParser.singleton.interpret(
17
- ast_factory.model.body, Loader::PredefinedLoader.new(loaders.find_loader(nil), 'TypeSet loader'))
11
+ module Puppet::Pops
12
+ def self.generate_ast
13
+ Puppet.initialize_settings
14
+ env = Puppet.lookup(:environments).get(Puppet[:environment])
15
+ loaders = Loaders.new(env)
16
+ ast_pp = Pathname(__FILE__).parent.parent + 'lib/puppet/pops/model/ast.pp'
17
+ Puppet.override(:current_environment => env, :loaders => loaders) do
18
+ ast_factory = Parser::Parser.new.parse_file(ast_pp.expand_path.to_s)
19
+ ast_model = Types::TypeParser.singleton.interpret(
20
+ ast_factory.model.body, Loader::PredefinedLoader.new(loaders.find_loader(nil), 'TypeSet loader'))
18
21
 
19
- ruby = Types::RubyGenerator.new.module_definition_from_typeset(ast_model)
22
+ ruby = Types::RubyGenerator.new.module_definition_from_typeset(ast_model)
20
23
 
21
- # Replace ref() constructs to known Pcore types with directly initialized types. ref() cannot be used
22
- # since it requires a parser (hen and egg problem)
23
- ruby.gsub!(/^module Parser\nmodule Locator\n.*\nend\nend\nmodule Model\n/m, "module Model\n")
24
+ # Replace ref() constructs to known Pcore types with directly initialized types. ref() cannot be used
25
+ # since it requires a parser (hen and egg problem)
26
+ ruby.gsub!(/^module Parser\nmodule Locator\n.*\nend\nend\nmodule Model\n/m, "module Model\n")
24
27
 
25
- # Remove generated RubyMethod annotations. The ruby methods are there now, no need to also have
26
- # the annotations present.
27
- ruby.gsub!(/^\s+'annotations' => \{\n\s+ref\('RubyMethod'\) => \{\n.*\n\s+\}\n\s+\},\n/, '')
28
+ # Remove generated RubyMethod annotations. The ruby methods are there now, no need to also have
29
+ # the annotations present.
30
+ ruby.gsub!(/^\s+'annotations' => \{\n\s+ref\('RubyMethod'\) => \{\n.*\n\s+\}\n\s+\},\n/, '')
28
31
 
29
- ruby.gsub!(/ref\('([A-Za-z]+)'\)/, 'Types::P\1Type::DEFAULT')
30
- ruby.gsub!(/ref\('Optional\[([0-9A-Za-z_]+)\]'\)/, 'Types::POptionalType.new(Types::P\1Type::DEFAULT)')
31
- ruby.gsub!(/ref\('Array\[([0-9A-Za-z_]+)\]'\)/, 'Types::PArrayType.new(Types::P\1Type::DEFAULT)')
32
- ruby.gsub!(/ref\('Optional\[Array\[([0-9A-Za-z_]+)\]\]'\)/,
33
- 'Types::POptionalType.new(Types::PArrayType.new(Types::P\1Type::DEFAULT))')
34
- ruby.gsub!(/ref\("Enum(\[[^\]]+\])"\)/, 'Types::PEnumType.new(\1)')
32
+ ruby.gsub!(/ref\('([A-Za-z]+)'\)/, 'Types::P\1Type::DEFAULT')
33
+ ruby.gsub!(/ref\('Optional\[([0-9A-Za-z_]+)\]'\)/, 'Types::POptionalType.new(Types::P\1Type::DEFAULT)')
34
+ ruby.gsub!(/ref\('Array\[([0-9A-Za-z_]+)\]'\)/, 'Types::PArrayType.new(Types::P\1Type::DEFAULT)')
35
+ ruby.gsub!(/ref\('Optional\[Array\[([0-9A-Za-z_]+)\]\]'\)/,
36
+ 'Types::POptionalType.new(Types::PArrayType.new(Types::P\1Type::DEFAULT))')
37
+ ruby.gsub!(/ref\("Enum(\[[^\]]+\])"\)/, 'Types::PEnumType.new(\1)')
35
38
 
36
- # Replace ref() constructs with references to _pcore_type of the types in the module namespace
37
- ruby.gsub!(/ref\('Puppet::AST::Locator'\)/, 'Parser::Locator::Locator19._pcore_type')
38
- ruby.gsub!(/ref\('Puppet::AST::([0-9A-Za-z_]+)'\)/, '\1._pcore_type')
39
- ruby.gsub!(/ref\('Optional\[Puppet::AST::([0-9A-Za-z_]+)\]'\)/, 'Types::POptionalType.new(\1._pcore_type)')
40
- ruby.gsub!(/ref\('Array\[Puppet::AST::([0-9A-Za-z_]+)\]'\)/, 'Types::PArrayType.new(\1._pcore_type)')
41
- ruby.gsub!(/ref\('Array\[Puppet::AST::([0-9A-Za-z_]+), 1, default\]'\)/,
42
- 'Types::PArrayType.new(\1._pcore_type, Types::PCollectionType::NOT_EMPTY_SIZE)')
39
+ # Replace ref() constructs with references to _pcore_type of the types in the module namespace
40
+ ruby.gsub!(/ref\('Puppet::AST::Locator'\)/, 'Parser::Locator::Locator19._pcore_type')
41
+ ruby.gsub!(/ref\('Puppet::AST::([0-9A-Za-z_]+)'\)/, '\1._pcore_type')
42
+ ruby.gsub!(/ref\('Optional\[Puppet::AST::([0-9A-Za-z_]+)\]'\)/, 'Types::POptionalType.new(\1._pcore_type)')
43
+ ruby.gsub!(/ref\('Array\[Puppet::AST::([0-9A-Za-z_]+)\]'\)/, 'Types::PArrayType.new(\1._pcore_type)')
44
+ ruby.gsub!(/ref\('Array\[Puppet::AST::([0-9A-Za-z_]+), 1, default\]'\)/,
45
+ 'Types::PArrayType.new(\1._pcore_type, Types::PCollectionType::NOT_EMPTY_SIZE)')
43
46
 
44
- # Remove the generated ref() method. It's not needed by this model
45
- ruby.gsub!(/ def self\.ref\(type_string\)\n.*\n end\n\n/, '')
47
+ # Remove the generated ref() method. It's not needed by this model
48
+ ruby.gsub!(/ def self\.ref\(type_string\)\n.*\n end\n\n/, '')
46
49
 
47
- # Replace the generated registration with a registration that uses the static loader. This will
48
- # become part of the Puppet bootstrap code and there will be no other loader until we have a
49
- # parser.
50
- ruby.gsub!(/^Puppet::Pops::Pcore.register_implementations\((\[[^\]]+\])\)/, <<-RUBY)
50
+ # Replace the generated registration with a registration that uses the static loader. This will
51
+ # become part of the Puppet bootstrap code and there will be no other loader until we have a
52
+ # parser.
53
+ ruby.gsub!(/^Puppet::Pops::Pcore.register_implementations\((\[[^\]]+\])\)/, <<-RUBY)
51
54
  module Model
52
55
  @@pcore_ast_initialized = false
53
56
  def self.register_pcore_types
@@ -71,8 +74,9 @@ def self.register_pcore_types
71
74
  end
72
75
  end
73
76
  RUBY
74
- ast_rb = Pathname(__FILE__).parent.parent + 'lib/puppet/pops/model/ast.rb'
75
- File.open(ast_rb.to_s, 'w') { |f| f.write(ruby) }
77
+ ast_rb = Pathname(__FILE__).parent.parent + 'lib/puppet/pops/model/ast.rb'
78
+ File.open(ast_rb.to_s, 'w') { |f| f.write(ruby) }
79
+ end
76
80
  end
77
81
  end
78
82
  end