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
@@ -209,6 +209,20 @@ static_catalogs=false
209
209
  end
210
210
 
211
211
  it "logs a warning, but processes the main settings if there are any extraneous settings" do
212
+ content << "dog=arf\n"
213
+ content << "cat=mew\n"
214
+ loader_from(:filesystem => [envdir, manifestdir, modulepath].flatten,
215
+ :directory => envdir) do |loader|
216
+ expect(loader.get("env1")).to environment(:env1).
217
+ with_manifest(manifestdir.path).
218
+ with_modulepath(modulepath.map(&:path)).
219
+ with_config_version(File.expand_path('/some/script'))
220
+ end
221
+
222
+ expect(@logs.map(&:to_s).join).to match(/Invalid.*at.*\/env1.*unknown setting.*dog, cat/)
223
+ end
224
+
225
+ it "logs a warning, but processes the main settings if there are any ignored sections" do
212
226
  content << "dog=arf\n"
213
227
  content << "cat=mew\n"
214
228
  content << "[ignored]\n"
@@ -221,6 +235,7 @@ static_catalogs=false
221
235
  with_config_version(File.expand_path('/some/script'))
222
236
  end
223
237
 
238
+ expect(@logs.map(&:to_s).join).to match(/Invalid.*at.*\/env1.*The following sections are being ignored: 'ignored'/)
224
239
  expect(@logs.map(&:to_s).join).to match(/Invalid.*at.*\/env1.*unknown setting.*dog, cat/)
225
240
  end
226
241
 
@@ -18,8 +18,8 @@ describe Puppet::Face[:config, '0.0.1'] do
18
18
  Puppet[:syslogfacility] = "file"
19
19
 
20
20
  expect { subject.print("trace", "syslogfacility") }.to have_printed(<<-OUTPUT)
21
- trace = true
22
21
  syslogfacility = file
22
+ trace = true
23
23
  OUTPUT
24
24
  end
25
25
 
@@ -108,11 +108,11 @@ syslogfacility = file
108
108
  ) do
109
109
  args = "environmentpath","manifest","modulepath","environment","basemodulepath"
110
110
  expect { subject.print(*add_section_option(args, section)) }.to have_printed(<<-OUTPUT)
111
+ basemodulepath = #{File.expand_path("/some/base")}
112
+ environment = production
111
113
  environmentpath = #{File.expand_path("/dev/null/environments")}
112
114
  manifest = #{File.expand_path("/dev/null/environments/production/manifests")}
113
115
  modulepath = #{File.expand_path("/dev/null/environments/production/modules")}#{File::PATH_SEPARATOR}#{File.expand_path("/some/base")}
114
- environment = production
115
- basemodulepath = #{File.expand_path("/some/base")}
116
116
  OUTPUT
117
117
  end
118
118
  end
@@ -129,17 +129,16 @@ basemodulepath = #{File.expand_path("/some/base")}
129
129
  ) do
130
130
  args = "environmentpath","manifest","modulepath","environment","basemodulepath"
131
131
  expect { subject.print(*add_section_option(args, section)) }.to have_printed(<<-OUTPUT)
132
+ basemodulepath = #{File.expand_path("/some/base")}
133
+ environment = production
132
134
  environmentpath = #{File.expand_path("/dev/null/environments")}
133
135
  manifest = #{File.expand_path("/dev/null/environments/production/manifests")}
134
136
  modulepath = #{File.expand_path("/custom/modules")}#{File::PATH_SEPARATOR}#{File.expand_path("/some/base")}
135
- environment = production
136
- basemodulepath = #{File.expand_path("/some/base")}
137
137
  OUTPUT
138
138
  end
139
139
  end
140
140
 
141
141
  it "prints the default configured env settings for an env that does not exist" do
142
- pending "This case no longer exists because Application will through an error before we even get here because of the non-existent environment"
143
142
  Puppet[:environment] = 'doesnotexist'
144
143
 
145
144
  FS.overlay(
@@ -149,11 +148,11 @@ basemodulepath = #{File.expand_path("/some/base")}
149
148
  ) do
150
149
  args = "environmentpath","manifest","modulepath","environment","basemodulepath"
151
150
  expect { subject.print(*add_section_option(args, section)) }.to have_printed(<<-OUTPUT)
151
+ basemodulepath = #{File.expand_path("/some/base")}
152
+ environment = doesnotexist
152
153
  environmentpath = #{File.expand_path("/dev/null/environments")}
153
- manifest = no_manifest
154
+ manifest =
154
155
  modulepath =
155
- environment = doesnotexist
156
- basemodulepath = #{File.expand_path("/some/base")}
157
156
  OUTPUT
158
157
  end
159
158
  end
@@ -147,7 +147,7 @@ describe Puppet::Face[:epp, :current] do
147
147
  dir = dir_containing('templates', { template_name => "<% 1 2 3 %>" })
148
148
  template = File.join(dir, template_name)
149
149
  expect(eppface.dump(template, :validate => true)).to eq("")
150
- expect(@logs.join).to match(/This Literal Integer has no effect.*\/template1.epp:1:4/)
150
+ expect(@logs.join).to match(/This Literal Integer has no effect.*\(file: .*\/template1\.epp, line: 1, column: 4\)/)
151
151
  end
152
152
 
153
153
  it "validated content by default" do
@@ -155,7 +155,7 @@ describe Puppet::Face[:epp, :current] do
155
155
  dir = dir_containing('templates', { template_name => "<% 1 2 3 %>" })
156
156
  template = File.join(dir, template_name)
157
157
  expect(eppface.dump(template)).to eq("")
158
- expect(@logs.join).to match(/This Literal Integer has no effect.*\/template1.epp:1:4/)
158
+ expect(@logs.join).to match(/This Literal Integer has no effect.*\(file: .*\/template1\.epp, line: 1, column: 4\)/)
159
159
  end
160
160
 
161
161
  it "informs the user of files that don't exist" do
@@ -12,21 +12,67 @@ describe Puppet::Face[:plugin, :current] do
12
12
  end
13
13
 
14
14
  context "download" do
15
- it "downloads plugins and external facts" do
16
- Puppet::Configurer::Downloader.any_instance.expects(:evaluate).twice.returns([])
15
+ before :each do
16
+ #Server_agent version needs to be at 5.3.4 in order to mount locales
17
+ Puppet.push_context({:server_agent_version => "5.3.4"})
18
+ end
19
+
20
+ it "downloads plugins, external facts, and locales" do
21
+ Puppet::Configurer::Downloader.any_instance.expects(:evaluate).times(3).returns([])
17
22
 
18
23
  pluginface.download
19
24
  end
20
25
 
21
26
  it "renders 'No plugins downloaded' if nothing was downloaded" do
22
- Puppet::Configurer::Downloader.any_instance.expects(:evaluate).twice.returns([])
27
+ Puppet::Configurer::Downloader.any_instance.expects(:evaluate).times(3).returns([])
23
28
 
24
29
  result = pluginface.download
25
30
  expect(render(result)).to eq('No plugins downloaded.')
26
31
  end
27
32
 
28
33
  it "renders comma separate list of downloaded file names" do
29
- Puppet::Configurer::Downloader.any_instance.expects(:evaluate).twice.returns(%w[/a]).then.returns(%w[/b])
34
+ Puppet::Configurer::Downloader.any_instance.expects(:evaluate).times(3).returns(%w[/a]).then.returns(%w[/b]).then.returns(%w[/c])
35
+
36
+ result = pluginface.download
37
+ expect(render(result)).to eq('Downloaded these plugins: /a, /b, /c')
38
+ end
39
+ end
40
+
41
+ context "download when server_agent_version is 5.3.3" do
42
+ before :each do
43
+ #Server_agent version needs to be at 5.3.4 in order to mount locales
44
+ Puppet.push_context({:server_agent_version => "5.3.3"})
45
+ end
46
+
47
+ it "downloads plugins, and external facts, but not locales" do
48
+ Puppet::Configurer::Downloader.any_instance.expects(:evaluate).times(2).returns([])
49
+
50
+ pluginface.download
51
+ end
52
+
53
+ it "renders comma separate list of downloaded file names that does not include locales" do
54
+ Puppet::Configurer::Downloader.any_instance.expects(:evaluate).times(2).returns(%w[/a]).then.returns(%w[/b])
55
+
56
+ result = pluginface.download
57
+ expect(render(result)).to eq('Downloaded these plugins: /a, /b')
58
+ end
59
+ end
60
+
61
+ context "download when server_agent_version is blank" do
62
+ before :each do
63
+ #Server_agent version needs to be at 5.3.4 in order to mount locales
64
+ #A blank version will default to 0.0
65
+ Puppet.push_context({:server_agent_version => ""})
66
+ end
67
+
68
+ it "downloads plugins, and external facts, but not locales" do
69
+ Puppet::Configurer::Downloader.any_instance.expects(:evaluate).times(2).returns([])
70
+
71
+ pluginface.download
72
+ end
73
+
74
+ it "renders comma separate list of downloaded file names that does not include locales" do
75
+ Puppet::Configurer::Downloader.any_instance.expects(:evaluate).times(2).returns(%w[/a]).then.returns(%w[/b])
30
76
 
31
77
  result = pluginface.download
32
78
  expect(render(result)).to eq('Downloaded these plugins: /a, /b')
@@ -78,7 +78,7 @@ describe Puppet::FileServing::Configuration::Parser do
78
78
  it "should return comprehensible error message, if invalid line detected" do
79
79
  write_config_file "[one]\n\n\x01path /etc/puppetlabs/puppet/files\n\x01allow *\n"
80
80
 
81
- expect { @parser.parse }.to raise_error(ArgumentError, /Invalid line.*in.*, line 3/)
81
+ expect { @parser.parse }.to raise_error(ArgumentError, /Invalid entry at \(file: .*, line: 3\): .*/)
82
82
  end
83
83
  end
84
84
 
@@ -130,7 +130,7 @@ describe Puppet::FileServing::Configuration::Parser do
130
130
  it "should return comprehensible error message, if failed on invalid attribute" do
131
131
  write_config_file "[one]\ndo something\n"
132
132
 
133
- expect { @parser.parse }.to raise_error(ArgumentError, /Invalid argument 'do' in .*, line 2/)
133
+ expect { @parser.parse }.to raise_error(ArgumentError, /Invalid argument 'do' at \(file: .*, line: 2\)/)
134
134
  end
135
135
  end
136
136
 
@@ -0,0 +1,73 @@
1
+ #! /usr/bin/env ruby
2
+ require 'spec_helper'
3
+ require 'puppet/file_serving/mount/locales'
4
+
5
+ describe Puppet::FileServing::Mount::Locales do
6
+ before do
7
+ @mount = Puppet::FileServing::Mount::Locales.new("locales")
8
+
9
+ @environment = stub 'environment', :module => nil
10
+ @options = { :recurse => true }
11
+ @request = stub 'request', :environment => @environment, :options => @options
12
+ end
13
+
14
+ describe "when finding files" do
15
+ it "should use the provided environment to find the modules" do
16
+ @environment.expects(:modules).returns []
17
+
18
+ @mount.find("foo", @request)
19
+ end
20
+
21
+ it "should return nil if no module can be found with a matching locale" do
22
+ mod = mock 'module'
23
+ mod.stubs(:locale).with("foo/bar").returns nil
24
+
25
+ @environment.stubs(:modules).returns [mod]
26
+ expect(@mount.find("foo/bar", @request)).to be_nil
27
+ end
28
+
29
+ it "should return the file path from the module" do
30
+ mod = mock 'module'
31
+ mod.stubs(:locale).with("foo/bar").returns "eh"
32
+
33
+ @environment.stubs(:modules).returns [mod]
34
+ expect(@mount.find("foo/bar", @request)).to eq("eh")
35
+ end
36
+ end
37
+
38
+ describe "when searching for files" do
39
+ it "should use the node's environment to find the modules" do
40
+ @environment.expects(:modules).at_least_once.returns []
41
+ @environment.stubs(:modulepath).returns ["/tmp/modules"]
42
+
43
+ @mount.search("foo", @request)
44
+ end
45
+
46
+ it "should return modulepath if no modules can be found that have locales" do
47
+ mod = mock 'module'
48
+ mod.stubs(:locales?).returns false
49
+
50
+ @environment.stubs(:modules).returns []
51
+ @environment.stubs(:modulepath).returns ["/"]
52
+ @options.expects(:[]=).with(:recurse, false)
53
+ expect(@mount.search("foo/bar", @request)).to eq(["/"])
54
+ end
55
+
56
+ it "should return nil if no modules can be found that have locales and modulepath is invalid" do
57
+ mod = mock 'module'
58
+ mod.stubs(:locales?).returns false
59
+
60
+ @environment.stubs(:modules).returns []
61
+ @environment.stubs(:modulepath).returns []
62
+ expect(@mount.search("foo/bar", @request)).to be_nil
63
+ end
64
+
65
+ it "should return the locale paths for each module that has locales" do
66
+ one = stub 'module', :locales? => true, :locale_directory => "/one"
67
+ two = stub 'module', :locales? => true, :locale_directory => "/two"
68
+
69
+ @environment.stubs(:modules).returns [one, two]
70
+ expect(@mount.search("foo/bar", @request)).to eq(%w{/one /two})
71
+ end
72
+ end
73
+ end
@@ -8,7 +8,7 @@ describe 'the break function' do
8
8
  include Matchers::Resource
9
9
 
10
10
  context do
11
- it 'breaks iteration as if at end of input in a map' do
11
+ it 'breaks iteration as if at end of input in a map for an array' do
12
12
  expect(compile_to_catalog(<<-CODE)).to have_resource('Notify[[1, 2]]')
13
13
  function please_break() {
14
14
  [1,2,3].map |$x| { if $x == 3 { break() } $x }
@@ -44,24 +44,81 @@ describe 'the break function' do
44
44
  CODE
45
45
  end
46
46
 
47
- end
47
+ it 'breaks iteration as if at end of input in a map for a hash' do
48
+ expect(compile_to_catalog(<<-CODE)).to have_resource('Notify[[1, 2]]')
49
+ function please_break() {
50
+ {'a' => 1, 'b' => 2, 'c' => 3}.map |$x, $y| { if $y == 3 { break() } $y }
51
+ }
52
+ notify { String(please_break()): }
53
+ CODE
54
+ end
48
55
 
49
- it 'does not provide early exit from a class' do
50
- # A break would semantically mean that the class should not be included - as if the
51
- # iteration over class names should stop. That is too magic and should
52
- # be done differently by the user.
53
- #
54
- expect do
55
- compile_to_catalog(<<-CODE)
56
- class does_break {
57
- notice 'a'
58
- if 1 == 1 { break() } # avoid making next line statically unreachable
59
- notice 'b'
60
- }
61
- include(does_break)
62
- CODE
63
- end.to raise_error(/break\(\) from context where this is illegal at unknown:3 on node.*/)
64
- end
56
+ it 'breaks iteration as if at end of input in a reduce for an array' do
57
+ expect(compile_to_catalog(<<-CODE)).to have_resource('Notify[6]')
58
+ function please_break() {
59
+ [1,2,3,4].reduce |$memo, $x| { if $x == 4 { break() } $memo + $x }
60
+ }
61
+ notify { String(please_break()): }
62
+ CODE
63
+ end
64
+
65
+ it 'breaks iteration as if at end of input in a reduce for a hash' do
66
+ expect(compile_to_catalog(<<-CODE)).to have_resource("Notify[['abc', 6]]")
67
+ function please_break() {
68
+ {'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4}.reduce |$memo, $x| {
69
+ if $x[1] == 4 { break() }
70
+ $string = "${memo[0]}${x[0]}"
71
+ $number = $memo[1] + $x[1]
72
+ [$string, $number]
73
+ }
74
+ }
75
+ notify { String(please_break()): }
76
+ CODE
77
+ end
78
+
79
+ it 'breaks iteration as if at end of input in an each for an array' do
80
+ expect(compile_to_catalog(<<-CODE)).to_not have_resource('Notify[3]')
81
+ function please_break() {
82
+ [1,2,3].each |$x| { if $x == 3 { break() } notify { "$x": } }
83
+ }
84
+ please_break()
85
+ CODE
86
+ end
87
+
88
+ it 'breaks iteration as if at end of input in an each for a hash' do
89
+ expect(compile_to_catalog(<<-CODE)).to_not have_resource('Notify[3]')
90
+ function please_break() {
91
+ {'a' => 1, 'b' => 2, 'c' => 3}.each |$x, $y| { if $y == 3 { break() } notify { "$y": } }
92
+ }
93
+ please_break()
94
+ CODE
95
+ end
96
+
97
+ it 'breaks iteration as if at end of input in a reverse_each' do
98
+ expect(compile_to_catalog(<<-CODE)).to have_resource('Notify[2]')
99
+ function please_break() {
100
+ [1,2,3].reverse_each |$x| { if $x == 1 { break() } notify { "$x": } }
101
+ }
102
+ please_break()
103
+ CODE
104
+ end
105
+
106
+ it 'does not provide early exit from a class' do
107
+ # A break would semantically mean that the class should not be included - as if the
108
+ # iteration over class names should stop. That is too magic and should
109
+ # be done differently by the user.
110
+ #
111
+ expect do
112
+ compile_to_catalog(<<-CODE)
113
+ class does_break {
114
+ notice 'a'
115
+ if 1 == 1 { break() } # avoid making next line statically unreachable
116
+ notice 'b'
117
+ }
118
+ include(does_break)
119
+ CODE
120
+ end.to raise_error(/break\(\) from context where this is illegal \(file: unknown, line: 3\) on node.*/)
121
+ end
65
122
 
66
123
  it 'does not provide early exit from a define' do
67
124
  # A break would semantically mean that the resource should not be created - as if the
@@ -77,41 +134,42 @@ describe 'the break function' do
77
134
  }
78
135
  does_break { 'no_you_cannot': }
79
136
  CODE
80
- end.to raise_error(/break\(\) from context where this is illegal at unknown:3 on node.*/)
137
+ end.to raise_error(/break\(\) from context where this is illegal \(file: unknown, line: 3\) on node.*/)
81
138
  end
82
139
 
83
- it 'can be called when nested in a function to make that function behave as a break' do
84
- # This allows functions like break_when(...) to be implemented by calling break() conditionally
85
- #
86
- expect(eval_and_collect_notices(<<-CODE)).to eql(['[100]'])
87
- function nested_break($x) {
88
- if $x == 2 { break() } else { $x * 100 }
89
- }
90
- function example() {
91
- [1,2,3].map |$x| { nested_break($x) }
92
- }
93
- notice example()
94
- CODE
95
- end
140
+ it 'can be called when nested in a function to make that function behave as a break' do
141
+ # This allows functions like break_when(...) to be implemented by calling break() conditionally
142
+ #
143
+ expect(eval_and_collect_notices(<<-CODE)).to eql(['[100]'])
144
+ function nested_break($x) {
145
+ if $x == 2 { break() } else { $x * 100 }
146
+ }
147
+ function example() {
148
+ [1,2,3].map |$x| { nested_break($x) }
149
+ }
150
+ notice example()
151
+ CODE
152
+ end
96
153
 
97
- it 'can not be called nested from top scope' do
98
- expect do
99
- compile_to_catalog(<<-CODE)
100
- # line 1
101
- # line 2
102
- $result = with(1) |$x| { with($x) |$x| {break() }}
103
- notice $result
104
- CODE
105
- end.to raise_error(/break\(\) from context where this is illegal at unknown:3 on node.*/)
106
- end
154
+ it 'can not be called nested from top scope' do
155
+ expect do
156
+ compile_to_catalog(<<-CODE)
157
+ # line 1
158
+ # line 2
159
+ $result = with(1) |$x| { with($x) |$x| {break() }}
160
+ notice $result
161
+ CODE
162
+ end.to raise_error(/break\(\) from context where this is illegal \(file: unknown, line: 3\) on node.*/)
163
+ end
107
164
 
108
- it 'can not be called from top scope' do
109
- expect do
110
- compile_to_catalog(<<-CODE)
111
- # line 1
112
- # line 2
113
- break()
114
- CODE
115
- end.to raise_error(/break\(\) from context where this is illegal at unknown:3 on node.*/)
165
+ it 'can not be called from top scope' do
166
+ expect do
167
+ compile_to_catalog(<<-CODE)
168
+ # line 1
169
+ # line 2
170
+ break()
171
+ CODE
172
+ end.to raise_error(/break\(\) from context where this is illegal \(file: unknown, line: 3\) on node.*/)
173
+ end
116
174
  end
117
175
  end