kitchen-pester 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2265777e3844674d88d2c9fee716b53e51931370db862b9ae1ab1e0e146a0d3f
4
- data.tar.gz: ea5c52a19e982eb5f762d342a098160723120b4800734b611c1da782a0a49b62
3
+ metadata.gz: 0b6c13739edbe22f0dedd8c258cf3ba1d65232872a5dbb43831e71af00adff8c
4
+ data.tar.gz: c8c94343f5e132fd79d1e5a39848a883d10f8506e6408bdd44a2bb645a0f3f1c
5
5
  SHA512:
6
- metadata.gz: 521b9f823e6e4229dc55753e1a19c809056a70855276a5ab512ebcc4e41f9301396cd05deba5a8fe40528f1df25705f069c73401eeb8d67acd3501d9e7f3e502
7
- data.tar.gz: 1294cc1198df01d440000612209d21b23d4904129d0b9fe2092b37a9186030819c87a145b88ea37526f544ce40e2ede8f616d2ea428f57bd878fc01d6b8902cc
6
+ metadata.gz: 4e40212df8ac8701351185e97429cdfcd8a2c9366c06b2ecd8c198a175b748be682e7a5f2806bf42626ea928940d2383e65d851ca7bb06e860713d92651d70e2
7
+ data.tar.gz: d2cea264f19135c7c9b0660358a71b627e4ac2c28fe765b03e41572ca0113192c5b4ef15ef3fe2808dcf43fba56f29d8fa6e9aeab0d5c4293f3e175433c696e8
data/README.md CHANGED
@@ -105,26 +105,46 @@ the instance is the exact script that ran.
105
105
 
106
106
  ## Pester versions
107
107
 
108
- kitchen-pester supports **Pester 5** (the default) and **Pester 4**.
108
+ kitchen-pester supports **Pester 5 and later** (the default) and **Pester 4**.
109
109
 
110
- It detects the installed version on the instance and adapts: Pester 5 gets a
111
- `PesterConfiguration` object built from your `pester_configuration`, Pester 4
112
- gets loose `Invoke-Pester` parameters. You do not need to tell it which one
113
- you are on.
110
+ It detects the installed version on the instance and adapts: Pester 5 and
111
+ later get a `PesterConfiguration` object built from your
112
+ `pester_configuration`, Pester 4 and earlier get loose `Invoke-Pester`
113
+ parameters. You do not need to tell it which one you are on.
114
114
 
115
- To stay on Pester 4, cap the install:
115
+ To stay on Pester 4, cap the install. `pester_install` is
116
+ [replaced, not merged](#map-options-are-replaced-not-merged), so repeat the
117
+ defaults you still want — without `SkipPublisherCheck` the install fails
118
+ against the Pester that ships with Windows:
116
119
 
117
120
  ```yaml
118
121
  verifier:
119
122
  name: pester
120
123
  pester_install:
121
124
  MaximumVersion: '4.99.999'
125
+ SkipPublisherCheck: true
126
+ Force: true
127
+ ErrorAction: Stop
122
128
  ```
123
129
 
124
130
  ## Configuration
125
131
 
126
132
  All of these go under `verifier:` in `kitchen.yml`.
127
133
 
134
+ ### Map options are replaced, not merged
135
+
136
+ Every option below whose type is **map** — `pester_install`,
137
+ `pester_configuration`, `bootstrap`, `environment`, `downloads` — replaces its
138
+ default outright. A plugin default applies only when the key is absent
139
+ altogether, so setting one key inside one of these maps discards every other
140
+ key the default supplied. (Merging between the top-level, platform and suite
141
+ `verifier:` blocks is unaffected — that part is a deep merge.)
142
+
143
+ This bites hardest on `pester_install` and `pester_configuration`, where the
144
+ discarded defaults are the ones that produce the results file. Whenever you set
145
+ a map option, write out the whole map, taking the defaults from the tables
146
+ below as your starting point.
147
+
128
148
  ### Common
129
149
 
130
150
  | Option | Type | Default | What it does |
@@ -207,6 +227,22 @@ Output:
207
227
  Verbosity: Detailed
208
228
  ```
209
229
 
230
+ This map is [replaced, not merged](#map-options-are-replaced-not-merged), and
231
+ the defaults it replaces are load-bearing. `New-PesterConfiguration` defaults
232
+ both `TestResult.Enabled` and `Run.PassThru` to `$false`, so this:
233
+
234
+ ```yaml
235
+ verifier:
236
+ name: pester
237
+ pester_configuration:
238
+ Output:
239
+ Verbosity: Diagnostic
240
+ ```
241
+
242
+ turns off the NUnit results file — your `downloads` then have nothing to
243
+ fetch — and leaves the run without a result object to count failures from.
244
+ Copy the whole default map and edit the key you came for.
245
+
210
246
  **On Pester 5**, this becomes a `PesterConfiguration` via
211
247
  `New-PesterConfiguration -Hashtable`. Three keys are filled in for you if you
212
248
  leave them unset:
@@ -276,8 +312,9 @@ verifier:
276
312
  - PowerShellGet
277
313
  ```
278
314
 
279
- > **Note:** this key is replaced wholesale, not merged. If you set `modules`,
280
- > set `repository_url` too.
315
+ > **Note:** this key is
316
+ > [replaced, not merged](#map-options-are-replaced-not-merged). If you set
317
+ > `modules`, set `repository_url` too.
281
318
 
282
319
  ## Examples
283
320
 
@@ -362,6 +399,11 @@ Describe 'configuration' {
362
399
  died before Pester started; check the `cinc kitchen verify` output for the install
363
400
  step.
364
401
 
402
+ **I set one `pester_configuration` key and the results file stopped appearing.**
403
+ Map options replace their default rather than merging into it, and the default
404
+ is what enables the results file. See
405
+ [Map options are replaced, not merged](#map-options-are-replaced-not-merged).
406
+
365
407
  **I want to see the script that ran.** Add `kitchen_cmd.ps1` to `downloads`,
366
408
  or look for it in `$env:TEMP/verifier` on the instance.
367
409
 
@@ -21,10 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.files = %w{LICENSE README.md kitchen-pester.gemspec} + Dir.glob("lib/**/*")
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_development_dependency "rake"
25
- spec.add_development_dependency "minitest", ">= 5.25", "< 7"
26
- spec.add_development_dependency "mocha", ">= 2.0", "< 4"
27
- spec.add_development_dependency "yard", "~> 0.9"
28
24
  # 3.6.0 is the first release to require Ruby >= 3.1, which this gem also
29
25
  # requires, so anything older cannot be installed alongside it in practice.
30
26
  spec.add_dependency "test-kitchen", ">= 3.6", "< 5"
@@ -221,7 +221,13 @@ module Kitchen
221
221
  config[:downloads] = config[:downloads]
222
222
  .map do |source, destination|
223
223
  source = source.to_s
224
- destination = destination.gsub("%{instance_name}", instance.name)
224
+ if destination.nil?
225
+ raise UserError, "The verifier's 'downloads' entry for '#{source}' has no local " \
226
+ "destination. Every entry needs one, for example " \
227
+ "'#{source}: ./testresults/'."
228
+ end
229
+
230
+ destination = destination.to_s.gsub("%{instance_name}", instance.name)
225
231
  info(" resolving remote source's absolute path.")
226
232
  unless source.match?(%r{^/|^[a-zA-Z]:[\\/]}) # is Absolute?
227
233
  info(" '#{source}' is a relative path, resolving to: #{File.join(config[:root_path], source)}")
@@ -373,12 +379,13 @@ module Kitchen
373
379
  gallery_url_param = bootstrap[:repository_url] ? "-GalleryUrl '#{bootstrap[:repository_url]}'" : ""
374
380
 
375
381
  info("Bootstrapping environment without PowerShellGet Provider...")
376
- Array(bootstrap[:modules]).map do |powershell_module|
382
+ config_list("bootstrap.modules", bootstrap[:modules]).map do |powershell_module|
377
383
  if powershell_module.is_a? Hash
384
+ module_name = module_name!("bootstrap.modules", powershell_module)
378
385
  <<-PS1
379
- ${#{powershell_module[:Name]}} = #{ps_hash(powershell_module)}
386
+ ${#{module_name}} = #{ps_hash(powershell_module)}
380
387
 
381
- Install-ModuleFromNuget -Module ${#{powershell_module[:Name]}} #{gallery_url_param}
388
+ Install-ModuleFromNuget -Module ${#{module_name}} #{gallery_url_param}
382
389
  PS1
383
390
  else
384
391
  <<-PS1
@@ -397,13 +404,14 @@ module Kitchen
397
404
  return if config[:register_repository].nil?
398
405
 
399
406
  info("Registering a new PowerShellGet Repository")
400
- Array(config[:register_repository]).map do |psrepo|
407
+ config_list("register_repository", config[:register_repository]).map do |psrepo|
408
+ repo_name = module_name!("register_repository", psrepo)
401
409
  # Using Set-PSRepo from ../../*/*/*/PesterUtil.psm1
402
- debug("Command to set PSRepo #{psrepo[:Name]}.")
410
+ debug("Command to set PSRepo #{repo_name}.")
403
411
  <<-PS1
404
- Write-Host 'Registering psrepo #{psrepo[:Name]}...'
405
- ${#{psrepo[:Name]}} = #{ps_hash(psrepo)}
406
- Set-PSRepo -Repository ${#{psrepo[:Name]}}
412
+ Write-Host 'Registering psrepo #{repo_name}...'
413
+ ${#{repo_name}} = #{ps_hash(psrepo)}
414
+ Set-PSRepo -Repository ${#{repo_name}}
407
415
  PS1
408
416
  end
409
417
  end
@@ -439,10 +447,10 @@ module Kitchen
439
447
  def install_modules_from_gallery
440
448
  return if config[:install_modules].nil?
441
449
 
442
- Array(config[:install_modules]).map do |powershell_module|
450
+ config_list("install_modules", config[:install_modules]).map do |powershell_module|
443
451
  if powershell_module.is_a? Hash
444
452
  # Sanitize variable name so that $powershell-yaml becomes $powershell_yaml
445
- module_name = powershell_module[:Name].gsub(/[\W]/, "_")
453
+ module_name = module_name!("install_modules", powershell_module).gsub(/[\W]/, "_")
446
454
  # so we can splat that variable to install module
447
455
  <<-PS1
448
456
  $#{module_name} = #{ps_hash(powershell_module)}
@@ -785,7 +793,7 @@ module Kitchen
785
793
 
786
794
  info("Preparing to copy specified folders to #{sandbox_module_path}.")
787
795
  kitchen_root_path = config[:kitchen_root]
788
- config[:copy_folders].each do |folder|
796
+ config_list("copy_folders", config[:copy_folders]).each do |folder|
789
797
  debug("copying #{folder}")
790
798
  folder_to_copy = File.join(kitchen_root_path, folder)
791
799
  copy_if_src_exists(folder_to_copy, sandbox_module_path)
@@ -867,6 +875,61 @@ module Kitchen
867
875
  path = (Pathname.new config[:test_folder]).realpath
868
876
  integration_path = File.join(path, "integration")
869
877
  Dir.exist?(integration_path) ? integration_path : path.to_s
878
+ rescue Errno::ENOENT
879
+ raise UserError, "The verifier's 'test_folder' is set to " \
880
+ "'#{config[:test_folder]}', which does not exist. It is resolved " \
881
+ "relative to the directory kitchen runs in, so give it a path that " \
882
+ "exists there or an absolute one."
883
+ end
884
+
885
+ # Returns the entries of a config option that is documented as a list.
886
+ #
887
+ # YAML makes it easy to write a single mapping where a list of mappings
888
+ # was meant -- leaving off the leading `- ` is enough. `Array()` turns
889
+ # such a mapping into a list of `[key, value]` pairs, which then renders
890
+ # as nonsense PowerShell instead of failing, so reject it here where we
891
+ # can still say which option is at fault.
892
+ #
893
+ # @param key [String] the option's name, for the error message
894
+ # @param value [Object] the configured value
895
+ # @return [Array] the entries to iterate over
896
+ # @raise [Kitchen::UserError] when a single mapping was given
897
+ # @api private
898
+ def config_list(key, value)
899
+ if value.is_a?(Hash)
900
+ raise UserError, "The verifier's '#{key}' must be a list, but a single mapping " \
901
+ "was given. Put a '- ' in front of each entry in kitchen.yml."
902
+ end
903
+
904
+ Array(value)
905
+ end
906
+
907
+ # Returns the Name of a mapping-shaped entry in one of the module or
908
+ # repository lists.
909
+ #
910
+ # The name becomes a PowerShell variable that the generated script splats,
911
+ # so a missing one either blows up here or emits an empty `${}` that fails
912
+ # on the instance a long way from its cause.
913
+ #
914
+ # @param key [String] the option's name, for the error message
915
+ # @param entry [Hash] the entry to read the name from
916
+ # @return [String] the entry's Name
917
+ # @raise [Kitchen::UserError] when the entry is not a mapping, or has no
918
+ # usable Name
919
+ # @api private
920
+ def module_name!(key, entry)
921
+ unless entry.is_a?(Hash)
922
+ raise UserError, "Every entry under the verifier's '#{key}' must be a mapping with " \
923
+ "at least a 'Name'; #{entry.inspect} is a #{entry.class}."
924
+ end
925
+
926
+ name = entry[:Name] || entry["Name"]
927
+ if name.to_s.empty?
928
+ raise UserError, "Every mapping under the verifier's '#{key}' needs a 'Name'; " \
929
+ "#{entry.inspect} has none."
930
+ end
931
+
932
+ name.to_s
870
933
  end
871
934
 
872
935
  # Returns the final segment of a path that lives on the SUT.
@@ -30,6 +30,6 @@ module Kitchen
30
30
  # test-kitchen, which is not yet available when the gemspec is evaluated.
31
31
  #
32
32
  # @return [String] the gem version
33
- PESTER_VERSION = "1.2.1"
33
+ PESTER_VERSION = "1.2.2"
34
34
  end
35
35
  end
metadata CHANGED
@@ -1,83 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-pester
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Murawski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-08-23 00:00:00.000000000 Z
11
+ date: 2026-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rake
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: minitest
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '5.25'
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: '7'
37
- type: :development
38
- prerelease: false
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: '5.25'
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: '7'
47
- - !ruby/object:Gem::Dependency
48
- name: mocha
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '2.0'
54
- - - "<"
55
- - !ruby/object:Gem::Version
56
- version: '4'
57
- type: :development
58
- prerelease: false
59
- version_requirements: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: '2.0'
64
- - - "<"
65
- - !ruby/object:Gem::Version
66
- version: '4'
67
- - !ruby/object:Gem::Dependency
68
- name: yard
69
- requirement: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - "~>"
72
- - !ruby/object:Gem::Version
73
- version: '0.9'
74
- type: :development
75
- prerelease: false
76
- version_requirements: !ruby/object:Gem::Requirement
77
- requirements:
78
- - - "~>"
79
- - !ruby/object:Gem::Version
80
- version: '0.9'
81
13
  - !ruby/object:Gem::Dependency
82
14
  name: test-kitchen
83
15
  requirement: !ruby/object:Gem::Requirement