puppet 5.3.3-x64-mingw32 → 5.3.4-x64-mingw32

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 (291) hide show
  1. data/CONTRIBUTING.md +1 -1
  2. data/Gemfile +3 -0
  3. data/ext/puppet-test +3 -2
  4. data/lib/hiera/puppet_function.rb +5 -2
  5. data/lib/hiera_puppet.rb +3 -3
  6. data/lib/puppet.rb +2 -5
  7. data/lib/puppet/agent.rb +22 -2
  8. data/lib/puppet/agent/locker.rb +6 -5
  9. data/lib/puppet/application.rb +18 -1
  10. data/lib/puppet/application/agent.rb +9 -2
  11. data/lib/puppet/application/apply.rb +1 -1
  12. data/lib/puppet/application/config.rb +1 -0
  13. data/lib/puppet/application/device.rb +1 -2
  14. data/lib/puppet/application/filebucket.rb +22 -5
  15. data/lib/puppet/application/help.rb +1 -0
  16. data/lib/puppet/application/lookup.rb +1 -3
  17. data/lib/puppet/application_support.rb +6 -1
  18. data/lib/puppet/bindings.rb +2 -1
  19. data/lib/puppet/configurer.rb +9 -4
  20. data/lib/puppet/configurer/downloader_factory.rb +10 -0
  21. data/lib/puppet/configurer/plugin_handler.rb +11 -4
  22. data/lib/puppet/daemon.rb +2 -2
  23. data/lib/puppet/defaults.rb +99 -27
  24. data/lib/puppet/environments.rb +2 -0
  25. data/lib/puppet/error.rb +5 -15
  26. data/lib/puppet/external/pson/common.rb +2 -2
  27. data/lib/puppet/face/catalog.rb +1 -1
  28. data/lib/puppet/face/config.rb +14 -1
  29. data/lib/puppet/face/epp.rb +4 -2
  30. data/lib/puppet/face/help.rb +12 -14
  31. data/lib/puppet/face/man.rb +1 -0
  32. data/lib/puppet/face/module/build.rb +1 -1
  33. data/lib/puppet/face/module/list.rb +6 -17
  34. data/lib/puppet/face/module/uninstall.rb +14 -3
  35. data/lib/puppet/face/node.rb +1 -0
  36. data/lib/puppet/face/status.rb +1 -0
  37. data/lib/puppet/file_serving/base.rb +2 -1
  38. data/lib/puppet/file_serving/configuration.rb +3 -0
  39. data/lib/puppet/file_serving/configuration/parser.rb +23 -9
  40. data/lib/puppet/file_serving/mount/locales.rb +35 -0
  41. data/lib/puppet/forge.rb +2 -1
  42. data/lib/puppet/forge/errors.rb +24 -22
  43. data/lib/puppet/functions/binary_file.rb +1 -0
  44. data/lib/puppet/functions/each.rb +10 -4
  45. data/lib/puppet/functions/eyaml_lookup_key.rb +4 -2
  46. data/lib/puppet/functions/lookup.rb +2 -2
  47. data/lib/puppet/functions/map.rb +12 -2
  48. data/lib/puppet/functions/slice.rb +2 -3
  49. data/lib/puppet/functions/unique.rb +1 -1
  50. data/lib/puppet/functions/yaml_data.rb +1 -1
  51. data/lib/puppet/gettext/config.rb +144 -41
  52. data/lib/puppet/gettext/module_translations.rb +42 -0
  53. data/lib/puppet/graph/relationship_graph.rb +1 -1
  54. data/lib/puppet/graph/simple_graph.rb +3 -3
  55. data/lib/puppet/indirector/catalog/compiler.rb +40 -25
  56. data/lib/puppet/indirector/exec.rb +1 -1
  57. data/lib/puppet/indirector/facts/facter.rb +3 -3
  58. data/lib/puppet/indirector/facts/network_device.rb +2 -2
  59. data/lib/puppet/indirector/file_bucket_file/file.rb +4 -1
  60. data/lib/puppet/indirector/indirection.rb +17 -9
  61. data/lib/puppet/indirector/ldap.rb +2 -2
  62. data/lib/puppet/indirector/node/write_only_yaml.rb +3 -1
  63. data/lib/puppet/indirector/rest.rb +8 -5
  64. data/lib/puppet/indirector/ssl_file.rb +2 -2
  65. data/lib/puppet/indirector/terminus.rb +3 -3
  66. data/lib/puppet/interface.rb +2 -1
  67. data/lib/puppet/interface/action.rb +41 -24
  68. data/lib/puppet/interface/action_builder.rb +14 -5
  69. data/lib/puppet/interface/action_manager.rb +1 -1
  70. data/lib/puppet/interface/documentation.rb +21 -10
  71. data/lib/puppet/interface/face_collection.rb +4 -2
  72. data/lib/puppet/interface/option.rb +36 -15
  73. data/lib/puppet/interface/option_builder.rb +23 -9
  74. data/lib/puppet/interface/option_manager.rb +8 -3
  75. data/lib/puppet/metatype/manager.rb +7 -3
  76. data/lib/puppet/module.rb +18 -21
  77. data/lib/puppet/module_tool/errors/installer.rb +18 -20
  78. data/lib/puppet/module_tool/errors/shared.rb +20 -15
  79. data/lib/puppet/module_tool/errors/uninstaller.rb +1 -0
  80. data/lib/puppet/module_tool/errors/upgrader.rb +1 -1
  81. data/lib/puppet/module_tool/tar/mini.rb +57 -4
  82. data/lib/puppet/network/auth_config_parser.rb +18 -13
  83. data/lib/puppet/network/authstore.rb +2 -2
  84. data/lib/puppet/network/client_request.rb +1 -1
  85. data/lib/puppet/network/format.rb +3 -3
  86. data/lib/puppet/network/http/api/indirection_type.rb +1 -1
  87. data/lib/puppet/network/http/api/master/v3/environment.rb +5 -2
  88. data/lib/puppet/network/http/error.rb +7 -7
  89. data/lib/puppet/network/http/factory.rb +9 -0
  90. data/lib/puppet/network/http/rack.rb +2 -2
  91. data/lib/puppet/network/http/webrick.rb +2 -4
  92. data/lib/puppet/node.rb +25 -6
  93. data/lib/puppet/node/environment.rb +14 -0
  94. data/lib/puppet/node/facts.rb +9 -0
  95. data/lib/puppet/parameter.rb +3 -3
  96. data/lib/puppet/parameter/value_collection.rb +9 -9
  97. data/lib/puppet/parser/ast/leaf.rb +1 -1
  98. data/lib/puppet/parser/ast/node.rb +2 -2
  99. data/lib/puppet/parser/ast/pops_bridge.rb +1 -1
  100. data/lib/puppet/parser/compiler.rb +6 -5
  101. data/lib/puppet/parser/functions.rb +1 -1
  102. data/lib/puppet/parser/functions/generate.rb +2 -4
  103. data/lib/puppet/parser/functions/inline_template.rb +1 -2
  104. data/lib/puppet/parser/functions/sprintf.rb +17 -3
  105. data/lib/puppet/parser/functions/template.rb +6 -2
  106. data/lib/puppet/parser/resource.rb +30 -31
  107. data/lib/puppet/parser/scope.rb +20 -11
  108. data/lib/puppet/parser/templatewrapper.rb +4 -3
  109. data/lib/puppet/pops/evaluator/collector_transformer.rb +2 -1
  110. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
  111. data/lib/puppet/pops/evaluator/epp_evaluator.rb +21 -8
  112. data/lib/puppet/pops/evaluator/evaluator_impl.rb +2 -1
  113. data/lib/puppet/pops/evaluator/external_syntax_support.rb +1 -1
  114. data/lib/puppet/pops/evaluator/runtime3_converter.rb +3 -1
  115. data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +1 -1
  116. data/lib/puppet/pops/evaluator/runtime3_support.rb +4 -4
  117. data/lib/puppet/pops/functions/dispatch.rb +1 -1
  118. data/lib/puppet/pops/functions/function.rb +8 -2
  119. data/lib/puppet/pops/issue_reporter.rb +7 -2
  120. data/lib/puppet/pops/issues.rb +10 -4
  121. data/lib/puppet/pops/label_provider.rb +1 -1
  122. data/lib/puppet/pops/loader/module_loaders.rb +5 -2
  123. data/lib/puppet/pops/loader/static_loader.rb +1 -1
  124. data/lib/puppet/pops/loaders.rb +7 -3
  125. data/lib/puppet/pops/lookup/explainer.rb +2 -1
  126. data/lib/puppet/pops/lookup/hiera_config.rb +2 -2
  127. data/lib/puppet/pops/lookup/lookup_adapter.rb +4 -4
  128. data/lib/puppet/pops/merge_strategy.rb +6 -3
  129. data/lib/puppet/pops/migration/migration_checker.rb +8 -8
  130. data/lib/puppet/pops/model/ast_transformer.rb +1 -1
  131. data/lib/puppet/pops/model/factory.rb +4 -2
  132. data/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
  133. data/lib/puppet/pops/serialization/abstract_writer.rb +2 -1
  134. data/lib/puppet/pops/types/iterable.rb +2 -0
  135. data/lib/puppet/pops/types/p_object_type.rb +36 -15
  136. data/lib/puppet/pops/types/type_calculator.rb +2 -1
  137. data/lib/puppet/pops/types/type_factory.rb +3 -1
  138. data/lib/puppet/pops/types/type_mismatch_describer.rb +19 -6
  139. data/lib/puppet/pops/types/type_parser.rb +7 -7
  140. data/lib/puppet/pops/types/types.rb +10 -4
  141. data/lib/puppet/pops/validation.rb +14 -12
  142. data/lib/puppet/property.rb +14 -6
  143. data/lib/puppet/property/ensure.rb +2 -2
  144. data/lib/puppet/provider.rb +4 -4
  145. data/lib/puppet/provider/group/aix.rb +4 -2
  146. data/lib/puppet/provider/ldap.rb +2 -2
  147. data/lib/puppet/provider/naginator.rb +1 -1
  148. data/lib/puppet/provider/nameservice.rb +7 -4
  149. data/lib/puppet/provider/nameservice/directoryservice.rb +4 -3
  150. data/lib/puppet/provider/package/aix.rb +1 -1
  151. data/lib/puppet/provider/package/nim.rb +7 -8
  152. data/lib/puppet/provider/package/opkg.rb +1 -1
  153. data/lib/puppet/provider/package/pkg.rb +9 -6
  154. data/lib/puppet/provider/package/pkgutil.rb +3 -3
  155. data/lib/puppet/provider/package/yum.rb +1 -1
  156. data/lib/puppet/provider/parsedfile.rb +4 -4
  157. data/lib/puppet/provider/selmodule/semodule.rb +5 -3
  158. data/lib/puppet/provider/service/base.rb +1 -1
  159. data/lib/puppet/provider/service/init.rb +1 -1
  160. data/lib/puppet/provider/service/launchd.rb +2 -2
  161. data/lib/puppet/provider/service/runit.rb +2 -1
  162. data/lib/puppet/provider/service/smf.rb +2 -0
  163. data/lib/puppet/provider/service/systemd.rb +1 -0
  164. data/lib/puppet/provider/service/upstart.rb +1 -1
  165. data/lib/puppet/provider/user/aix.rb +13 -6
  166. data/lib/puppet/provider/user/openbsd.rb +2 -1
  167. data/lib/puppet/provider/yumrepo/inifile.rb +2 -1
  168. data/lib/puppet/provider/zone/solaris.rb +2 -2
  169. data/lib/puppet/reference/configuration.rb +4 -2
  170. data/lib/puppet/relationship.rb +2 -1
  171. data/lib/puppet/reports/store.rb +1 -1
  172. data/lib/puppet/resource.rb +7 -5
  173. data/lib/puppet/resource/capability_finder.rb +14 -11
  174. data/lib/puppet/resource/catalog.rb +33 -18
  175. data/lib/puppet/resource/type.rb +5 -5
  176. data/lib/puppet/settings.rb +19 -13
  177. data/lib/puppet/settings/base_setting.rb +23 -8
  178. data/lib/puppet/settings/config_file.rb +14 -4
  179. data/lib/puppet/settings/environment_conf.rb +19 -9
  180. data/lib/puppet/ssl/base.rb +9 -4
  181. data/lib/puppet/ssl/oids.rb +8 -2
  182. data/lib/puppet/syntax_checkers/base64.rb +5 -6
  183. data/lib/puppet/transaction.rb +7 -3
  184. data/lib/puppet/transaction/persistence.rb +16 -1
  185. data/lib/puppet/transaction/report.rb +6 -0
  186. data/lib/puppet/type.rb +27 -35
  187. data/lib/puppet/type/file.rb +2 -1
  188. data/lib/puppet/type/file/data_sync.rb +2 -1
  189. data/lib/puppet/type/file/source.rb +1 -1
  190. data/lib/puppet/type/group.rb +1 -1
  191. data/lib/puppet/type/mount.rb +1 -1
  192. data/lib/puppet/type/resources.rb +1 -1
  193. data/lib/puppet/type/schedule.rb +26 -14
  194. data/lib/puppet/type/user.rb +9 -3
  195. data/lib/puppet/type/zone.rb +1 -1
  196. data/lib/puppet/util.rb +27 -21
  197. data/lib/puppet/util/at_fork/solaris.rb +6 -4
  198. data/lib/puppet/util/command_line.rb +5 -0
  199. data/lib/puppet/util/command_line/trollop.rb +6 -5
  200. data/lib/puppet/util/errors.rb +61 -8
  201. data/lib/puppet/util/fileparsing.rb +3 -5
  202. data/lib/puppet/util/http_proxy.rb +14 -6
  203. data/lib/puppet/util/instance_loader.rb +1 -3
  204. data/lib/puppet/util/ldap/manager.rb +6 -3
  205. data/lib/puppet/util/log.rb +19 -24
  206. data/lib/puppet/util/logging.rb +21 -28
  207. data/lib/puppet/util/methodhelper.rb +1 -1
  208. data/lib/puppet/util/nagios_maker.rb +1 -1
  209. data/lib/puppet/util/network_device/config.rb +21 -13
  210. data/lib/puppet/util/plist.rb +3 -1
  211. data/lib/puppet/util/posix.rb +1 -1
  212. data/lib/puppet/util/provider_features.rb +1 -1
  213. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +1 -1
  214. data/lib/puppet/util/reference.rb +2 -3
  215. data/lib/puppet/util/selinux.rb +1 -1
  216. data/lib/puppet/util/storage.rb +2 -2
  217. data/lib/puppet/util/windows/eventlog.rb +10 -5
  218. data/lib/puppet/util/windows/file.rb +61 -9
  219. data/lib/puppet/util/windows/process.rb +1 -1
  220. data/lib/puppet/util/windows/taskscheduler.rb +2 -2
  221. data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet.rb +5 -1
  222. data/lib/puppet/version.rb +1 -1
  223. data/locales/en/puppet.po +19 -0
  224. data/locales/ja/puppet.po +2739 -809
  225. data/locales/puppet.pot +2367 -734
  226. data/spec/fixtures/unit/application/environments/production/data/common.yaml +2 -0
  227. data/spec/integration/agent/logging_spec.rb +2 -0
  228. data/spec/integration/faces/plugin_spec.rb +1 -0
  229. data/spec/integration/network/authconfig_spec.rb +2 -2
  230. data/spec/integration/parser/collection_spec.rb +2 -2
  231. data/spec/integration/parser/scope_spec.rb +16 -3
  232. data/spec/integration/provider/cron/crontab_spec.rb +1 -0
  233. data/spec/integration/transaction/report_spec.rb +5 -0
  234. data/spec/lib/matchers/json.rb +14 -13
  235. data/spec/unit/agent_spec.rb +33 -0
  236. data/spec/unit/application/config_spec.rb +4 -0
  237. data/spec/unit/application/lookup_spec.rb +30 -0
  238. data/spec/unit/application_spec.rb +18 -0
  239. data/spec/unit/configurer/downloader_factory_spec.rb +33 -0
  240. data/spec/unit/configurer/plugin_handler_spec.rb +71 -16
  241. data/spec/unit/environments_spec.rb +15 -0
  242. data/spec/unit/face/config_spec.rb +8 -9
  243. data/spec/unit/face/epp_face_spec.rb +2 -2
  244. data/spec/unit/face/plugin_spec.rb +50 -4
  245. data/spec/unit/file_serving/configuration/parser_spec.rb +2 -2
  246. data/spec/unit/file_serving/mount/locales_spec.rb +73 -0
  247. data/spec/unit/functions/break_spec.rb +108 -50
  248. data/spec/unit/functions/defined_spec.rb +2 -2
  249. data/spec/unit/functions/hiera_spec.rb +0 -1
  250. data/spec/unit/functions/lookup_spec.rb +85 -19
  251. data/spec/unit/functions/next_spec.rb +1 -1
  252. data/spec/unit/functions/return_spec.rb +2 -2
  253. data/spec/unit/gettext/config_spec.rb +125 -0
  254. data/spec/unit/gettext/module_loading_spec.rb +53 -0
  255. data/spec/unit/indirector/json_spec.rb +0 -11
  256. data/spec/unit/indirector/node/exec_spec.rb +1 -1
  257. data/spec/unit/info_service_spec.rb +1 -1
  258. data/spec/unit/interface_spec.rb +12 -0
  259. data/spec/unit/module_spec.rb +0 -28
  260. data/spec/unit/module_tool/tar/mini_spec.rb +34 -5
  261. data/spec/unit/network/http/factory_spec.rb +22 -0
  262. data/spec/unit/network/http/webrick_spec.rb +30 -29
  263. data/spec/unit/node/environment_spec.rb +16 -0
  264. data/spec/unit/node_spec.rb +102 -16
  265. data/spec/unit/parser/environment_compiler_spec.rb +1 -1
  266. data/spec/unit/parser/functions/sprintf_spec.rb +26 -0
  267. data/spec/unit/parser/resource/param_spec.rb +1 -1
  268. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +9 -9
  269. data/spec/unit/pops/loaders/static_loader_spec.rb +1 -1
  270. data/spec/unit/pops/parser/parse_containers_spec.rb +1 -1
  271. data/spec/unit/pops/types/type_calculator_spec.rb +40 -0
  272. data/spec/unit/pops/types/type_mismatch_describer_spec.rb +9 -0
  273. data/spec/unit/provider/selmodule_spec.rb +6 -0
  274. data/spec/unit/provider/service/init_spec.rb +1 -1
  275. data/spec/unit/provider/service/smf_spec.rb +2 -0
  276. data/spec/unit/provider/service/systemd_spec.rb +14 -0
  277. data/spec/unit/resource/catalog_spec.rb +12 -2
  278. data/spec/unit/settings/config_file_spec.rb +1 -1
  279. data/spec/unit/transaction/persistence_spec.rb +42 -0
  280. data/spec/unit/transaction/report_spec.rb +19 -4
  281. data/spec/unit/transaction_spec.rb +27 -0
  282. data/spec/unit/type/schedule_spec.rb +14 -0
  283. data/spec/unit/type_spec.rb +3 -3
  284. data/spec/unit/util/errors_spec.rb +1 -1
  285. data/spec/unit/util/http_proxy_spec.rb +37 -0
  286. data/spec/unit/util/log_spec.rb +3 -3
  287. data/spec/unit/util/logging_spec.rb +7 -7
  288. data/spec/unit/util/monkey_patches_spec.rb +6 -2
  289. metadata +3445 -3416
  290. checksums.yaml +0 -7
  291. data/spec/unit/gettext_config_spec.rb +0 -57
@@ -590,7 +590,7 @@ EOS
590
590
  it "fails if there are non component resources in the site" do
591
591
  expect {
592
592
  catalog = compile_to_env_catalog(MANIFEST_WITH_ILLEGAL_RESOURCE).to_resource
593
- }.to raise_error(/Only application components can appear inside a site - Notify\[fail me\] is not allowed at line 20/)
593
+ }.to raise_error(/Only application components can appear inside a site - Notify\[fail me\] is not allowed \(line: 20\)/)
594
594
  end
595
595
  end
596
596
 
@@ -44,4 +44,30 @@ describe "the sprintf function" do
44
44
  expect(result).to(eql("<overlong: 027 0XBEEF (foo )>"))
45
45
  end
46
46
 
47
+ it 'does not attempt to mutate its arguments' do
48
+ args = ['%d', 1].freeze
49
+ expect { @scope.function_sprintf(args) }.to_not raise_error
50
+ end
51
+
52
+ it 'support named arguments in a hash with string keys' do
53
+ result = @scope.function_sprintf(["%<foo>d : %<bar>f", {'foo' => 1, 'bar' => 2}])
54
+ expect(result).to eq("1 : 2.000000")
55
+ end
56
+
57
+ it 'raises a key error if a key is not present' do
58
+ expect do
59
+ @scope.function_sprintf(["%<foo>d : %<zanzibar>f", {'foo' => 1, 'bar' => 2}])
60
+ end.to raise_error(KeyError, /key<zanzibar> not found/)
61
+ end
62
+
63
+ it 'a hash with string keys that is output formats as strings' do
64
+ result = @scope.function_sprintf(["%s", {'foo' => 1, 'bar' => 2}])
65
+ expect(result).to eq("{\"foo\"=>1, \"bar\"=>2}")
66
+ end
67
+
68
+ it 'named arguments hash with non string keys are tolerated' do
69
+ result = @scope.function_sprintf(["%<foo>d : %<bar>f", {'foo' => 1, 'bar' => 2, 1 => 2, [1] => 2, false => true, {} => {}}])
70
+ expect(result).to eq("1 : 2.000000")
71
+ end
72
+
47
73
  end
@@ -26,7 +26,7 @@ describe Puppet::Parser::Resource::Param do
26
26
  it "includes file/line context in errors" do
27
27
  expect {
28
28
  Puppet::Parser::Resource::Param.new(:file => 'foo.pp', :line => 42)
29
- }.to raise_error(Puppet::Error, /foo.pp:42/)
29
+ }.to raise_error(Puppet::Error, /\(file: foo.pp, line: 42\)/)
30
30
  end
31
31
  end
32
32
  end
@@ -1017,7 +1017,7 @@ describe 'Puppet::Pops::Evaluator::EvaluatorImpl' do
1017
1017
  end
1018
1018
 
1019
1019
  it "provides location information on error in unparenthesized call logic" do
1020
- expect{parser.evaluate_string(scope, "include non_existing_class", __FILE__)}.to raise_error(Puppet::ParseError, /:1:1/)
1020
+ expect{parser.evaluate_string(scope, "include non_existing_class", __FILE__)}.to raise_error(Puppet::ParseError, /line: 1, column: 1/)
1021
1021
  end
1022
1022
 
1023
1023
  it 'defaults can be given in a lambda and used only when arg is missing' do
@@ -1204,7 +1204,7 @@ describe 'Puppet::Pops::Evaluator::EvaluatorImpl' do
1204
1204
  end
1205
1205
 
1206
1206
  it "a lex error should be raised for '$foo::::bar'" do
1207
- expect { parser.evaluate_string(scope, "$foo::::bar") }.to raise_error(Puppet::ParseErrorWithIssue, /Illegal fully qualified name at line 1:7/)
1207
+ expect { parser.evaluate_string(scope, "$foo::::bar") }.to raise_error(Puppet::ParseErrorWithIssue, /Illegal fully qualified name \(line: 1, column: 7\)/)
1208
1208
  end
1209
1209
 
1210
1210
  { '$a = $0' => nil,
@@ -1394,7 +1394,7 @@ describe 'Puppet::Pops::Evaluator::EvaluatorImpl' do
1394
1394
  source = "\nimport foo"
1395
1395
  # Error references position 5 at the opening '{'
1396
1396
  # Set file to nil to make it easier to match with line number (no file name in output)
1397
- expect { parser.evaluate_string(scope, source) }.to raise_error(/'import' has been discontinued.*line 2:1/)
1397
+ expect { parser.evaluate_string(scope, source) }.to raise_error(/'import' has been discontinued.* \(line: 2, column: 1\)/)
1398
1398
  end
1399
1399
  end
1400
1400
 
@@ -1404,15 +1404,15 @@ describe 'Puppet::Pops::Evaluator::EvaluatorImpl' do
1404
1404
  # Error references position 5 at the opening '{'
1405
1405
  # Set file to nil to make it easier to match with line number (no file name in output)
1406
1406
  expect { parser.evaluate_string(scope, source) }.to raise_error(
1407
- /Illegal Resource Type expression, expected result to be a type name, or untitled Resource.*line 1:2/)
1407
+ /Illegal Resource Type expression, expected result to be a type name, or untitled Resource.* \(line: 1, column: 2\)/)
1408
1408
  end
1409
1409
 
1410
1410
  it 'for non r-value producing <| |>' do
1411
- expect { parser.parse_string("$a = File <| |>", nil) }.to raise_error(/A Virtual Query does not produce a value at line 1:6/)
1411
+ expect { parser.parse_string("$a = File <| |>", nil) }.to raise_error(/A Virtual Query does not produce a value \(line: 1, column: 6\)/)
1412
1412
  end
1413
1413
 
1414
1414
  it 'for non r-value producing <<| |>>' do
1415
- expect { parser.parse_string("$a = File <<| |>>", nil) }.to raise_error(/An Exported Query does not produce a value at line 1:6/)
1415
+ expect { parser.parse_string("$a = File <<| |>>", nil) }.to raise_error(/An Exported Query does not produce a value \(line: 1, column: 6\)/)
1416
1416
  end
1417
1417
 
1418
1418
  it 'for non r-value producing define' do
@@ -1433,7 +1433,7 @@ describe 'Puppet::Pops::Evaluator::EvaluatorImpl' do
1433
1433
  yyy
1434
1434
  SOURCE
1435
1435
  # first char after opening " reported as being in error.
1436
- expect { parser.parse_string(source) }.to raise_error(/Unclosed quote after '"' followed by 'xx\\nyy\.\.\.' at line 1:7/)
1436
+ expect { parser.parse_string(source) }.to raise_error(/Unclosed quote after '"' followed by 'xx\\nyy\.\.\.' \(line: 1, column: 7\)/)
1437
1437
  end
1438
1438
 
1439
1439
  it 'for multiple errors with a summary exception' do
@@ -1445,7 +1445,7 @@ describe 'Puppet::Pops::Evaluator::EvaluatorImpl' do
1445
1445
  it 'for a bad hostname' do
1446
1446
  expect {
1447
1447
  parser.parse_string("node 'macbook+owned+by+name' { }", nil)
1448
- }.to raise_error(/The hostname 'macbook\+owned\+by\+name' contains illegal characters.*at line 1:6/)
1448
+ }.to raise_error(/The hostname 'macbook\+owned\+by\+name' contains illegal characters.* \(line: 1, column: 6\)/)
1449
1449
  end
1450
1450
 
1451
1451
  it 'for a hostname with interpolation' do
@@ -1455,7 +1455,7 @@ describe 'Puppet::Pops::Evaluator::EvaluatorImpl' do
1455
1455
  SOURCE
1456
1456
  expect {
1457
1457
  parser.parse_string(source, nil)
1458
- }.to raise_error(/An interpolated expression is not allowed in a hostname of a node at line 2:23/)
1458
+ }.to raise_error(/An interpolated expression is not allowed in a hostname of a node \(line: 2, column: 23\)/)
1459
1459
  end
1460
1460
 
1461
1461
  end
@@ -24,7 +24,7 @@ describe 'the static loader' do
24
24
  let(:loader) { loader = Puppet::Pops::Loader::StaticLoader.new() }
25
25
 
26
26
  %w{
27
- Auegas
27
+ Augeas
28
28
  Component
29
29
  Computer
30
30
  Cron
@@ -88,7 +88,7 @@ describe "egrammar parsing containers" do
88
88
  it "class 'foo' {} # a string as class name" do
89
89
  # A common error is to put quotes around the class name, the parser should provide the error message at the right location
90
90
  # See PUP-7471
91
- expect { parse("class 'foo' {}") }.to raise_error(/A quoted string is not valid as a name here at line 1:7/)
91
+ expect { parse("class 'foo' {}") }.to raise_error(/A quoted string is not valid as a name here \(line: 1, column: 7\)/)
92
92
  end
93
93
 
94
94
 
@@ -124,6 +124,10 @@ describe 'The type calculator' do
124
124
  TypeFactory.object(hash)
125
125
  end
126
126
 
127
+ def iterable_t(t = nil)
128
+ TypeFactory.iterable(t)
129
+ end
130
+
127
131
  def types
128
132
  Types
129
133
  end
@@ -971,6 +975,11 @@ describe 'The type calculator' do
971
975
  types_to_test.each {|t2| expect(t).not_to be_assignable_to(t2::DEFAULT) }
972
976
  end
973
977
 
978
+ it 'Numeric does not consider ruby Rational to be an instance' do
979
+ t = PNumericType::DEFAULT
980
+ expect(t).not_to be_instance(Rational(2,3))
981
+ end
982
+
974
983
  it 'Numeric is not assignable to any disjunct type' do
975
984
  tested_types = all_types - [
976
985
  PAnyType,
@@ -1737,6 +1746,13 @@ describe 'The type calculator' do
1737
1746
  t2 = parser.parse('Type[PositiveIntegerType]', scope)
1738
1747
  expect(calculator.assignable?(t2, t1)).to be_truthy
1739
1748
  end
1749
+
1750
+ it 'An alias for a Type that describes an Iterable instance is assignable to Iterable' do
1751
+ t = type_alias_t('MyType', 'Enum[a,b]').resolve(nil)
1752
+
1753
+ # True because String is iterable and an instance of Enum is a String
1754
+ expect(calculator.assignable?(iterable_t, t)).to be_truthy
1755
+ end
1740
1756
  end
1741
1757
  end
1742
1758
 
@@ -2028,6 +2044,11 @@ describe 'The type calculator' do
2028
2044
  expect(calculator.instance?(t, 15)).to be_truthy
2029
2045
  end
2030
2046
 
2047
+ it 'should consider t an instance of Iterable when aliased type is Iterable' do
2048
+ t = type_alias_t('Alias', 'Enum[a, b]').resolve(nil)
2049
+ expect(calculator.instance?(iterable_t, t)).to be_truthy
2050
+ end
2051
+
2031
2052
  it 'should consider x an instance of the aliased type that uses self recursion' do
2032
2053
  t = type_alias_t('Tree', 'Hash[String,Variant[String,Tree]]')
2033
2054
  loader = Object.new
@@ -2101,6 +2122,20 @@ describe 'The type calculator' do
2101
2122
  expect(t.key_type.class).to eq(PAnyType)
2102
2123
  expect(t.value_type.class).to eq(PAnyType)
2103
2124
  end
2125
+
2126
+ it 'type should yield \'PRuntimeType[ruby,Rational]\' for Rational' do
2127
+ t = calculator.type(Rational)
2128
+ expect(t.class).to eq(PRuntimeType)
2129
+ expect(t.runtime).to eq(:ruby)
2130
+ expect(t.runtime_type_name).to eq('Rational')
2131
+ end
2132
+
2133
+ it 'infer should yield \'PRuntimeType[ruby,Rational]\' for Rational instance' do
2134
+ t = calculator.infer(Rational(2, 3))
2135
+ expect(t.class).to eq(PRuntimeType)
2136
+ expect(t.runtime).to eq(:ruby)
2137
+ expect(t.runtime_type_name).to eq('Rational')
2138
+ end
2104
2139
  end
2105
2140
 
2106
2141
  context 'when processing meta type' do
@@ -2221,6 +2256,11 @@ describe 'The type calculator' do
2221
2256
  expect(calculator.iterable(calculator.type(t))).to eq(nil)
2222
2257
  end
2223
2258
  end
2259
+
2260
+ it 'should produce an iterable for a type alias of an Iterable type' do
2261
+ t = PTypeAliasType.new('MyAlias', nil, PIntegerType.new(1, 10))
2262
+ expect(calculator.iterable(t).respond_to?(:each)).to eq(true)
2263
+ end
2224
2264
  end
2225
2265
 
2226
2266
  context 'when dealing with different types of inference' do
@@ -168,6 +168,15 @@ describe 'the type mismatch describer' do
168
168
  /parameter 'arg' expects a match for Enum\['a', 'b'\], got Sensitive/))
169
169
  end
170
170
 
171
+ it "will report the parameter of Type[<type alias>] using the alias name" do
172
+ code = <<-CODE
173
+ type Custom = String[1]
174
+ Custom.each |$x| { notice($x) }
175
+ CODE
176
+ expect { eval_and_collect_notices(code) }.to(raise_error(Puppet::Error,
177
+ /expects an Iterable value, got Type\[Custom\]/))
178
+ end
179
+
171
180
  context 'when reporting a mismatch between' do
172
181
  let(:parser) { TypeParser.singleton }
173
182
  let(:subject) { TypeMismatchDescriber.singleton }
@@ -69,5 +69,11 @@ describe provider_class do
69
69
  @provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields StringIO.new("bar\t1.2.3\nfoo\t4.4.4\nbang\t1.0.0\n")
70
70
  expect(@provider.selmodversion_loaded).to eq("4.4.4")
71
71
  end
72
+
73
+ it 'should return raise an exception when running selmodule raises an exception' do
74
+ @provider.expects(:command).with(:semodule).returns "/usr/sbin/semodule"
75
+ @provider.expects(:execpipe).with("/usr/sbin/semodule --list").yields("this is\nan error").raises(Puppet::ExecutionFailure, 'it failed')
76
+ expect {@provider.selmodversion_loaded}.to raise_error(Puppet::ExecutionFailure, /Could not list policy modules: ".*" failed with "this is an error"/)
77
+ end
72
78
  end
73
79
  end
@@ -240,7 +240,7 @@ describe Puppet::Type.type(:service).provider(:init) do
240
240
  describe "when starting a service on Solaris" do
241
241
  it "should use ctrun" do
242
242
  Facter.stubs(:value).with(:osfamily).returns 'Solaris'
243
- provider.expects(:execute).with('/usr/bin/ctrun -l none /service/path/myservice start', {:failonfail => true, :override_locale => false, :squelch => false, :combine => true}).returns("")
243
+ provider.expects(:execute).with('/usr/bin/ctrun -l child /service/path/myservice start', {:failonfail => true, :override_locale => false, :squelch => false, :combine => true}).returns("")
244
244
  $CHILD_STATUS.stubs(:exitstatus).returns(0)
245
245
  provider.start
246
246
  end
@@ -166,12 +166,14 @@ describe provider_class, :if => Puppet.features.posix? do
166
166
 
167
167
  describe "when stopping" do
168
168
  it "should execute external command 'svcadm disable /system/myservice'" do
169
+ @provider.stubs(:status).returns :running
169
170
  @provider.expects(:texecute).with(:stop, ["/usr/sbin/svcadm", :disable, '-s', "/system/myservice"], true)
170
171
  @provider.expects(:wait).with('offline', 'disabled', 'uninitialized')
171
172
  @provider.stop
172
173
  end
173
174
 
174
175
  it "should error if timeout occurs while stopping the service" do
176
+ @provider.stubs(:status).returns :running
175
177
  @provider.expects(:texecute).with(:stop, ["/usr/sbin/svcadm", :disable, '-s', "/system/myservice"], true)
176
178
  Timeout.expects(:timeout).with(60).raises(Timeout::Error)
177
179
  expect { @provider.stop }.to raise_error Puppet::Error, ('Timed out waiting for /system/myservice to transition states')
@@ -58,6 +58,20 @@ describe Puppet::Type.type(:service).provider(:systemd) do
58
58
  end
59
59
  end
60
60
 
61
+ it "should be the default provider on Amazon Linux 2.0" do
62
+ Facter.stubs(:value).with(:osfamily).returns(:redhat)
63
+ Facter.stubs(:value).with(:operatingsystem).returns(:amazon)
64
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("2")
65
+ expect(described_class).to be_default
66
+ end
67
+
68
+ it "should not be the default provider on Amazon Linux 2017.09" do
69
+ Facter.stubs(:value).with(:osfamily).returns(:redhat)
70
+ Facter.stubs(:value).with(:operatingsystem).returns(:amazon)
71
+ Facter.stubs(:value).with(:operatingsystemmajrelease).returns("2017")
72
+ expect(described_class).not_to be_default
73
+ end
74
+
61
75
  it "should be the default provider on cumulus3" do
62
76
  Facter.stubs(:value).with(:osfamily).returns(:debian)
63
77
  Facter.stubs(:value).with(:operatingsystem).returns('CumulusLinux')
@@ -401,9 +401,9 @@ describe Puppet::Resource::Catalog, "when compiling" do
401
401
  expect(error).to be_a Puppet::Resource::Catalog::DuplicateResourceError
402
402
 
403
403
  expect(error.message).to match %r[Duplicate declaration: Notify\[duplicate-title\] is already declared]
404
- expect(error.message).to match %r[in file /path/to/orig/file:42]
404
+ expect(error.message).to match %r[at \(file: /path/to/orig/file, line: 42\)]
405
405
  expect(error.message).to match %r[cannot redeclare]
406
- expect(error.message).to match %r[at /path/to/dupe/file:314]
406
+ expect(error.message).to match %r[\(file: /path/to/dupe/file, line: 314\)]
407
407
  }
408
408
  end
409
409
  end
@@ -658,6 +658,16 @@ describe Puppet::Resource::Catalog, "when compiling" do
658
658
  @catalog.apply(:ignoreschedules => true)
659
659
  end
660
660
 
661
+ it "should detect transaction failure and report it" do
662
+ @transaction.stubs(:evaluate).raises(RuntimeError, 'transaction failed.')
663
+ report = Puppet::Transaction::Report.new('apply')
664
+
665
+ expect { @catalog.apply(:report => report) }.to raise_error(RuntimeError)
666
+ report.finalize_report
667
+
668
+ expect(report.status).to eq('failed')
669
+ end
670
+
661
671
  describe "host catalogs" do
662
672
 
663
673
  # super() doesn't work in the setup method for some reason
@@ -123,7 +123,7 @@ badline
123
123
 
124
124
  expect { config.parse_file(filename, text, [:legal]) }.
125
125
  to raise_error Puppet::Error,
126
- /Illegal section 'legal' in config file #{filename} at line 1/
126
+ /Illegal section 'legal' in config file at \(file: #{filename}, line: 1\)/
127
127
  end
128
128
 
129
129
  it "transforms values with the given function" do
@@ -175,4 +175,46 @@ describe Puppet::Transaction::Persistence do
175
175
  expect(persistence.get_system_value(resource, property)).to eq(value)
176
176
  end
177
177
  end
178
+
179
+ describe "when checking if persistence is enabled" do
180
+ let(:mock_catalog) do
181
+ mock
182
+ end
183
+
184
+ let (:persistence) do
185
+ Puppet::Transaction::Persistence.new
186
+ end
187
+
188
+ before :all do
189
+ @preferred_run_mode = Puppet.settings.preferred_run_mode
190
+ end
191
+
192
+ after :all do
193
+ Puppet.settings.preferred_run_mode = @preferred_run_mode
194
+ end
195
+
196
+ it "should not be enabled when not running in agent mode" do
197
+ Puppet.settings.preferred_run_mode = :user
198
+ mock_catalog.stubs(:host_config?).returns(true)
199
+ expect(persistence.enabled?(mock_catalog)).to be false
200
+ end
201
+
202
+ it "should not be enabled when the catalog is not the host catalog" do
203
+ Puppet.settings.preferred_run_mode = :agent
204
+ mock_catalog.stubs(:host_config?).returns(false)
205
+ expect(persistence.enabled?(mock_catalog)).to be false
206
+ end
207
+
208
+ it "should not be enabled outside of agent mode and the catalog is not the host catalog" do
209
+ Puppet.settings.preferred_run_mode = :user
210
+ mock_catalog.stubs(:host_config?).returns(false)
211
+ expect(persistence.enabled?(mock_catalog)).to be false
212
+ end
213
+
214
+ it "should be enabled in agent mode and when the catalog is the host catalog" do
215
+ Puppet.settings.preferred_run_mode = :agent
216
+ mock_catalog.stubs(:host_config?).returns(true)
217
+ expect(persistence.enabled?(mock_catalog)).to be true
218
+ end
219
+ end
178
220
  end
@@ -36,10 +36,6 @@ describe Puppet::Transaction::Report do
36
36
  expect(Puppet::Transaction::Report.new("some configuration version", "some environment", "some transaction uuid").transaction_uuid).to eq("some transaction uuid")
37
37
  end
38
38
 
39
- it "should take a 'transaction_uuid' as an argument" do
40
- expect(Puppet::Transaction::Report.new("some configuration version", "some environment", "some transaction uuid").transaction_uuid).to eq("some transaction uuid")
41
- end
42
-
43
39
  it "should take a 'job_id' as an argument" do
44
40
  expect(Puppet::Transaction::Report.new('cv', 'env', 'tid', 'some job id').job_id).to eq('some job id')
45
41
  end
@@ -262,6 +258,19 @@ describe Puppet::Transaction::Report do
262
258
  end
263
259
  end
264
260
 
261
+ it "should be unchanged if there are no other failures or changes and the transaction completed" do
262
+ @report.transaction_completed = true
263
+ @report.finalize_report
264
+
265
+ expect(@report.status).to eq("unchanged")
266
+ end
267
+
268
+ it "should be failed if there are no other failures or changes and the transaction did not complete" do
269
+ @report.finalize_report
270
+
271
+ expect(@report.status).to eq("failed")
272
+ end
273
+
265
274
  [:time, :resources, :changes, :events].each do |type|
266
275
  it "should add #{type} metrics" do
267
276
  @report.finalize_report
@@ -293,6 +302,7 @@ describe Puppet::Transaction::Report do
293
302
 
294
303
  it "should mark the report as 'failed' if there are failing resources" do
295
304
  add_statuses(1) { |status| status.failed = true }
305
+ @report.transaction_completed = true
296
306
  @report.finalize_report
297
307
  expect(@report.status).to eq('failed')
298
308
  end
@@ -305,6 +315,7 @@ describe Puppet::Transaction::Report do
305
315
 
306
316
  it "should mark the report as 'failed' if resources_failed_to_generate" do
307
317
  @report.resources_failed_to_generate = true
318
+ @report.transaction_completed = true
308
319
  @report.finalize_report
309
320
  expect(@report.status).to eq('failed')
310
321
  end
@@ -313,12 +324,14 @@ describe Puppet::Transaction::Report do
313
324
  describe "for changes" do
314
325
  it "should provide the number of changes from the resource statuses and mark the report as 'changed'" do
315
326
  add_statuses(3) { |status| 3.times { status << Puppet::Transaction::Event.new(:status => 'success') } }
327
+ @report.transaction_completed = true
316
328
  @report.finalize_report
317
329
  expect(metric(:changes, "total")).to eq(9)
318
330
  expect(@report.status).to eq('changed')
319
331
  end
320
332
 
321
333
  it "should provide a total even if there are no changes, and mark the report as 'unchanged'" do
334
+ @report.transaction_completed = true
322
335
  @report.finalize_report
323
336
  expect(metric(:changes, "total")).to eq(0)
324
337
  expect(@report.status).to eq('unchanged')
@@ -638,6 +651,7 @@ describe Puppet::Transaction::Report do
638
651
  report.cached_catalog_status = "not_used"
639
652
  report.master_used = "test:000"
640
653
  report.add_resource_status(status)
654
+ report.transaction_completed = true
641
655
  report.finalize_report
642
656
  report
643
657
  end
@@ -655,6 +669,7 @@ describe Puppet::Transaction::Report do
655
669
  report.cached_catalog_status = "not_used"
656
670
  report.master_used = "test:000"
657
671
  report.add_resource_status(status)
672
+ report.transaction_completed = true
658
673
  report.finalize_report
659
674
  report
660
675
  end