kitchen-pester 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +25 -3
- data/Rakefile +38 -31
- data/kitchen-pester.gemspec +10 -11
- metadata +41 -28
- data/.gitignore +0 -3
- data/.kitchen.appveyor.yml +0 -21
- data/.kitchen.yml +0 -18
- data/README.md +0 -38
- data/appveyor.yml +0 -40
- data/lib/kitchen/verifier/pester.rb +0 -334
- data/lib/kitchen/verifier/pester_version.rb +0 -5
- data/provision.ps1 +0 -1
- data/spec/pester/pester_spec.rb +0 -21
- data/test/integration/default/pester/default.tests.ps1 +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8604ba8a6d0f832c3eeeea3d763051ed16991eb5bac45501b6dc8e734b99c85b
|
4
|
+
data.tar.gz: ee0b7ff38dfce855537e30510bca1f974db227bd0549716f07c6b82ce2574a5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58e9f72997c8c22a5a66a93b53c522951d738de6a85e056386586b08be4fb235333017be25e421c37a3150b07e651ff686605535b7b5e0a7e7048674dadfcd57
|
7
|
+
data.tar.gz: '08a0a52e8df83182bd7376ff4412080a805ba7d0969be706d97f81f2df2d2e9024482c38a9a7d86a623e885f41dc860d8f1c6af885d1f3c39aa762df73f6d068'
|
data/Gemfile
CHANGED
@@ -1,7 +1,29 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in kitchen-pester.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
|
7
|
-
gem
|
6
|
+
group :integration do
|
7
|
+
gem "berkshelf"
|
8
|
+
gem "kitchen-inspec"
|
9
|
+
gem "kitchen-dokken"
|
10
|
+
gem "kitchen-vagrant"
|
11
|
+
end
|
12
|
+
|
13
|
+
group :changelog do
|
14
|
+
gem "github_changelog_generator", "1.11.3"
|
15
|
+
end
|
16
|
+
|
17
|
+
group :debug do
|
18
|
+
gem "pry"
|
19
|
+
gem "pry-byebug"
|
20
|
+
gem "pry-stack_explorer"
|
21
|
+
end
|
22
|
+
|
23
|
+
group :chefstyle do
|
24
|
+
gem "chefstyle"
|
25
|
+
end
|
26
|
+
|
27
|
+
group :docs do
|
28
|
+
gem "yard"
|
29
|
+
end
|
data/Rakefile
CHANGED
@@ -9,44 +9,51 @@ Rake::TestTask.new(:unit) do |t|
|
|
9
9
|
t.verbose = true
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
task :test => [:unit]
|
14
|
-
|
15
|
-
desc "Display LOC stats"
|
16
|
-
task :stats do
|
17
|
-
puts "\n## Production Code Stats"
|
18
|
-
sh "countloc -r lib"
|
19
|
-
puts "\n## Test Code Stats"
|
20
|
-
sh "countloc -r spec"
|
21
|
-
end
|
12
|
+
task test: :unit
|
22
13
|
|
23
|
-
|
24
|
-
require "
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
14
|
+
begin
|
15
|
+
require "chefstyle"
|
16
|
+
require "rubocop/rake_task"
|
17
|
+
RuboCop::RakeTask.new(:style) do |task|
|
18
|
+
task.options += ["--display-cop-names", "--no-color"]
|
19
|
+
end
|
20
|
+
rescue LoadError
|
21
|
+
puts "chefstyle is not available. (sudo) gem install chefstyle to do style checking."
|
30
22
|
end
|
31
23
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
24
|
+
desc "Run all quality tasks"
|
25
|
+
task quality: :style
|
26
|
+
|
27
|
+
begin
|
28
|
+
require "yard"
|
29
|
+
YARD::Rake::YardocTask.new
|
30
|
+
rescue LoadError
|
31
|
+
puts "yard is not available. (sudo) gem install yard to generate yard documentation."
|
36
32
|
end
|
37
33
|
|
38
|
-
|
39
|
-
task :quality => [:cane, :style, :stats]
|
34
|
+
task default: %i{test quality}
|
40
35
|
|
41
|
-
|
42
|
-
|
36
|
+
begin
|
37
|
+
require "github_changelog_generator/task"
|
38
|
+
require "kitchen/verifier/pester_version"
|
43
39
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
40
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
41
|
+
config.future_release = "v#{Kitchen::Verifier::PESTER_VERSION}"
|
42
|
+
config.issues = false
|
43
|
+
config.pulls = true
|
44
|
+
config.user = "test-kitchen"
|
45
|
+
config.project = "kitchen-pester"
|
49
46
|
end
|
47
|
+
rescue LoadError
|
48
|
+
puts "github_changelog_generator is not available." \
|
49
|
+
" (sudo) gem install github_changelog_generator to generate changelogs"
|
50
50
|
end
|
51
51
|
|
52
|
-
|
52
|
+
namespace :docs do
|
53
|
+
desc "Deploy docs"
|
54
|
+
task :deploy do
|
55
|
+
sh "cd docs && hugo"
|
56
|
+
sh "aws --profile chef-cd s3 sync docs/public s3://test-kitchen-legacy.cd.chef.co --delete --acl public-read"
|
57
|
+
sh "aws --profile chef-cd cloudfront create-invalidation --distribution-id EQD8MRW086SRT --paths '/*'"
|
58
|
+
end
|
59
|
+
end
|
data/kitchen-pester.gemspec
CHANGED
@@ -1,27 +1,26 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
|
5
|
-
require
|
5
|
+
require "kitchen/verifier/pester_version"
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
8
|
spec.name = "kitchen-pester"
|
9
9
|
spec.version = Kitchen::Verifier::PESTER_VERSION
|
10
10
|
spec.authors = ["Steven Murawski"]
|
11
11
|
spec.email = ["steven.murawski@gmail.com"]
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
12
|
+
spec.summary = "Test-Kitchen verifier for Pester."
|
13
|
+
spec.description = "Skip all that Busser stuff and jump right into Pester."
|
14
14
|
spec.homepage = "https://github.com/test-kitchen/kitchen-pester"
|
15
15
|
spec.license = "Apache 2"
|
16
16
|
|
17
|
-
spec.files =
|
18
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.files = %w{LICENSE kitchen-pester.gemspec Gemfile Rakefile lib/support/powershell/PesterUtil/PesterUtil.psm1}
|
20
18
|
spec.require_paths = ["lib"]
|
21
19
|
|
22
|
-
spec.add_development_dependency "bundler"
|
23
|
-
spec.add_development_dependency "rake"
|
24
|
-
spec.add_development_dependency "
|
20
|
+
spec.add_development_dependency "bundler"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "minitest", "~> 5.3", "< 5.11"
|
23
|
+
spec.add_development_dependency "mocha", "~> 1.1"
|
25
24
|
|
26
|
-
spec.add_dependency "test-kitchen", "
|
25
|
+
spec.add_dependency "test-kitchen", ">= 1.10", "< 3"
|
27
26
|
end
|
metadata
CHANGED
@@ -1,71 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitchen-pester
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Murawski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '5.3'
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '5.11'
|
34
51
|
type: :development
|
35
52
|
prerelease: false
|
36
53
|
version_requirements: !ruby/object:Gem::Requirement
|
37
54
|
requirements:
|
38
55
|
- - "~>"
|
39
56
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
57
|
+
version: '5.3'
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '5.11'
|
41
61
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
62
|
+
name: mocha
|
43
63
|
requirement: !ruby/object:Gem::Requirement
|
44
64
|
requirements:
|
45
65
|
- - "~>"
|
46
66
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
67
|
+
version: '1.1'
|
48
68
|
type: :development
|
49
69
|
prerelease: false
|
50
70
|
version_requirements: !ruby/object:Gem::Requirement
|
51
71
|
requirements:
|
52
72
|
- - "~>"
|
53
73
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
74
|
+
version: '1.1'
|
55
75
|
- !ruby/object:Gem::Dependency
|
56
76
|
name: test-kitchen
|
57
77
|
requirement: !ruby/object:Gem::Requirement
|
58
78
|
requirements:
|
59
|
-
- - "
|
79
|
+
- - ">="
|
60
80
|
- !ruby/object:Gem::Version
|
61
81
|
version: '1.10'
|
82
|
+
- - "<"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '3'
|
62
85
|
type: :runtime
|
63
86
|
prerelease: false
|
64
87
|
version_requirements: !ruby/object:Gem::Requirement
|
65
88
|
requirements:
|
66
|
-
- - "
|
89
|
+
- - ">="
|
67
90
|
- !ruby/object:Gem::Version
|
68
91
|
version: '1.10'
|
92
|
+
- - "<"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '3'
|
69
95
|
description: Skip all that Busser stuff and jump right into Pester.
|
70
96
|
email:
|
71
97
|
- steven.murawski@gmail.com
|
@@ -73,21 +99,11 @@ executables: []
|
|
73
99
|
extensions: []
|
74
100
|
extra_rdoc_files: []
|
75
101
|
files:
|
76
|
-
- ".gitignore"
|
77
|
-
- ".kitchen.appveyor.yml"
|
78
|
-
- ".kitchen.yml"
|
79
102
|
- Gemfile
|
80
103
|
- LICENSE
|
81
|
-
- README.md
|
82
104
|
- Rakefile
|
83
|
-
- appveyor.yml
|
84
105
|
- kitchen-pester.gemspec
|
85
|
-
- lib/kitchen/verifier/pester.rb
|
86
|
-
- lib/kitchen/verifier/pester_version.rb
|
87
106
|
- lib/support/powershell/PesterUtil/PesterUtil.psm1
|
88
|
-
- provision.ps1
|
89
|
-
- spec/pester/pester_spec.rb
|
90
|
-
- test/integration/default/pester/default.tests.ps1
|
91
107
|
homepage: https://github.com/test-kitchen/kitchen-pester
|
92
108
|
licenses:
|
93
109
|
- Apache 2
|
@@ -107,11 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
123
|
- !ruby/object:Gem::Version
|
108
124
|
version: '0'
|
109
125
|
requirements: []
|
110
|
-
|
111
|
-
rubygems_version: 2.6.11
|
126
|
+
rubygems_version: 3.0.3
|
112
127
|
signing_key:
|
113
128
|
specification_version: 4
|
114
129
|
summary: Test-Kitchen verifier for Pester.
|
115
|
-
test_files:
|
116
|
-
- spec/pester/pester_spec.rb
|
117
|
-
- test/integration/default/pester/default.tests.ps1
|
130
|
+
test_files: []
|
data/.gitignore
DELETED
data/.kitchen.appveyor.yml
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
---
|
2
|
-
driver:
|
3
|
-
name: proxy
|
4
|
-
host: localhost
|
5
|
-
reset_command: "exit 0"
|
6
|
-
port: 5985
|
7
|
-
username: <%= ENV["machine_user"] %>
|
8
|
-
password: <%= ENV["machine_pass"] %>
|
9
|
-
|
10
|
-
provisioner:
|
11
|
-
name: shell
|
12
|
-
script: provision.ps1
|
13
|
-
|
14
|
-
platforms:
|
15
|
-
- name: windows-2012R2
|
16
|
-
|
17
|
-
verifier:
|
18
|
-
name: pester
|
19
|
-
|
20
|
-
suites:
|
21
|
-
- name: default
|
data/.kitchen.yml
DELETED
data/README.md
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
[![Build status](https://ci.appveyor.com/api/projects/status/a63wtd8qpxe5bt4e/branch/master?svg=true)](https://ci.appveyor.com/project/test-kitchen/kitchen-pester/branch/master)
|
2
|
-
[![Gem Version](https://badge.fury.io/rb/kitchen-pester.svg)](http://badge.fury.io/rb/kitchen-pester)
|
3
|
-
|
4
|
-
# Kitchen::Pester
|
5
|
-
|
6
|
-
Execute [Pester](https://github.com/pester/Pester) tests right from Test-Kitchen, without having to transit the Busser layer.
|
7
|
-
|
8
|
-
## Usage
|
9
|
-
|
10
|
-
Either
|
11
|
-
```
|
12
|
-
gem install kitchen-pester
|
13
|
-
```
|
14
|
-
or include
|
15
|
-
```
|
16
|
-
gem 'kitchen-pester'
|
17
|
-
```
|
18
|
-
in your Gemfile.
|
19
|
-
|
20
|
-
In your .kitchen.yml include
|
21
|
-
```
|
22
|
-
verifier:
|
23
|
-
name: pester
|
24
|
-
```
|
25
|
-
This can be a top-level declaration, a per-node declaration, or a per-suite declaration.
|
26
|
-
|
27
|
-
### Options
|
28
|
-
|
29
|
-
* `restart_winrm` - boolean, default is false. This is primarily to support powershell v2 scenarios. If Pester is not being found, enable this option.
|
30
|
-
* `test_folder` - string, default is nil. `test-folder` allows you to specify a custom path (the default is ./test/integration/) for your integration tests. This can be an absolute path or relative to the root of the folder kitchen is running from. This path must exist.
|
31
|
-
|
32
|
-
## Contributing
|
33
|
-
|
34
|
-
1. Fork it ( https://github.com/[my-github-username]/kitchen-pester/fork )
|
35
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
37
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
38
|
-
5. Create a new Pull Request
|
data/appveyor.yml
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
version: "master-{build}"
|
2
|
-
|
3
|
-
os: Windows Server 2012 R2
|
4
|
-
platform:
|
5
|
-
- x64
|
6
|
-
|
7
|
-
environment:
|
8
|
-
machine_user: test_user
|
9
|
-
machine_pass: Pass@word1
|
10
|
-
KITCHEN_YAML: .kitchen.appveyor.yml
|
11
|
-
|
12
|
-
matrix:
|
13
|
-
- ruby_version: "23"
|
14
|
-
|
15
|
-
branches:
|
16
|
-
only:
|
17
|
-
- master
|
18
|
-
|
19
|
-
# Do not build on tags (GitHub only)
|
20
|
-
skip_tags: true
|
21
|
-
|
22
|
-
#faster cloning
|
23
|
-
clone_depth: 1
|
24
|
-
|
25
|
-
# Install the latest nightly of ChefDK
|
26
|
-
install:
|
27
|
-
- ps: net user /add $env:machine_user $env:machine_pass
|
28
|
-
- ps: net localgroup administrators $env:machine_user /add
|
29
|
-
- ps: $env:PATH="C:\Ruby$env:ruby_version\bin;$env:PATH"
|
30
|
-
- ps: Write-Host $env:PATH
|
31
|
-
- ps: ruby --version
|
32
|
-
- ps: gem --version
|
33
|
-
- ps: gem install bundler --quiet --no-ri --no-rdoc
|
34
|
-
- ps: bundler --version
|
35
|
-
|
36
|
-
build_script:
|
37
|
-
- bundle install || bundle install || bundle install
|
38
|
-
|
39
|
-
test_script:
|
40
|
-
- bundle exec kitchen verify
|
@@ -1,334 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Author:: Steven Murawski (<steven.murawski@gmail.com>)
|
4
|
-
#
|
5
|
-
# Copyright (C) 2015, Steven Murawski
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
|
19
|
-
require 'pathname'
|
20
|
-
require 'kitchen/verifier/base'
|
21
|
-
require 'kitchen/verifier/pester_version'
|
22
|
-
|
23
|
-
module Kitchen
|
24
|
-
|
25
|
-
module Verifier
|
26
|
-
|
27
|
-
class Pester < Kitchen::Verifier::Base
|
28
|
-
|
29
|
-
kitchen_verifier_api_version 1
|
30
|
-
|
31
|
-
plugin_version Kitchen::Verifier::PESTER_VERSION
|
32
|
-
|
33
|
-
default_config :restart_winrm, false
|
34
|
-
default_config :test_folder
|
35
|
-
default_config :use_local_pester_module, false
|
36
|
-
|
37
|
-
# Creates a new Verifier object using the provided configuration data
|
38
|
-
# which will be merged with any default configuration.
|
39
|
-
#
|
40
|
-
# @param config [Hash] provided verifier configuration
|
41
|
-
def initialize(config = {})
|
42
|
-
init_config(config)
|
43
|
-
end
|
44
|
-
|
45
|
-
# Creates a temporary directory on the local workstation into which
|
46
|
-
# verifier related files and directories can be copied or created. The
|
47
|
-
# contents of this directory will be copied over to the instance before
|
48
|
-
# invoking the verifier's run command. After this method completes, it
|
49
|
-
# is expected that the contents of the sandbox is complete and ready for
|
50
|
-
# copy to the remote instance.
|
51
|
-
#
|
52
|
-
# **Note:** any subclasses would be well advised to call super first when
|
53
|
-
# overriding this method, for example:
|
54
|
-
#
|
55
|
-
# @example overriding `#create_sandbox`
|
56
|
-
#
|
57
|
-
# class MyVerifier < Kitchen::Verifier::Base
|
58
|
-
# def create_sandbox
|
59
|
-
# super
|
60
|
-
# # any further file copies, preparations, etc.
|
61
|
-
# end
|
62
|
-
# end
|
63
|
-
def create_sandbox
|
64
|
-
super
|
65
|
-
prepare_powershell_modules
|
66
|
-
prepare_pester_tests
|
67
|
-
prepare_helpers
|
68
|
-
end
|
69
|
-
|
70
|
-
# Generates a command string which will install and configure the
|
71
|
-
# verifier software on an instance. If no work is required, then `nil`
|
72
|
-
# will be returned.
|
73
|
-
#
|
74
|
-
# @return [String] a command string
|
75
|
-
def install_command
|
76
|
-
return if local_suite_files.empty?
|
77
|
-
return if config[:use_local_pester_module]
|
78
|
-
|
79
|
-
really_wrap_shell_code(install_command_script)
|
80
|
-
end
|
81
|
-
|
82
|
-
# Generates a command string which will perform any data initialization
|
83
|
-
# or configuration required after the verifier software is installed
|
84
|
-
# but before the sandbox has been transferred to the instance. If no work
|
85
|
-
# is required, then `nil` will be returned.
|
86
|
-
#
|
87
|
-
# @return [String] a command string
|
88
|
-
def init_command
|
89
|
-
restart_winrm_service if config[:restart_winrm]
|
90
|
-
end
|
91
|
-
|
92
|
-
# Generates a command string which will perform any commands or
|
93
|
-
# configuration required just before the main verifier run command but
|
94
|
-
# after the sandbox has been transferred to the instance. If no work is
|
95
|
-
# required, then `nil` will be returned.
|
96
|
-
#
|
97
|
-
# @return [String] a command string
|
98
|
-
def prepare_command
|
99
|
-
end
|
100
|
-
|
101
|
-
# Generates a command string which will invoke the main verifier
|
102
|
-
# command on the prepared instance. If no work is required, then `nil`
|
103
|
-
# will be returned.
|
104
|
-
#
|
105
|
-
# @return [String] a command string
|
106
|
-
def run_command
|
107
|
-
return if local_suite_files.empty?
|
108
|
-
really_wrap_shell_code(run_command_script)
|
109
|
-
end
|
110
|
-
|
111
|
-
#private
|
112
|
-
def run_command_script
|
113
|
-
<<-CMD
|
114
|
-
$TestPath = "#{config[:root_path]}";
|
115
|
-
import-module Pester -force;
|
116
|
-
$result = invoke-pester -path $testpath -passthru ;
|
117
|
-
$result |
|
118
|
-
export-clixml (join-path $testpath 'result.xml');
|
119
|
-
$host.setshouldexit($result.failedcount)
|
120
|
-
CMD
|
121
|
-
end
|
122
|
-
|
123
|
-
def really_wrap_shell_code(code)
|
124
|
-
wrap_shell_code(Util.outdent!(use_local_powershell_modules(code)))
|
125
|
-
end
|
126
|
-
|
127
|
-
def use_local_powershell_modules(script)
|
128
|
-
<<-EOH
|
129
|
-
set-executionpolicy unrestricted -force;
|
130
|
-
$global:ProgressPreference = 'SilentlyContinue'
|
131
|
-
$env:psmodulepath += ";$(join-path (resolve-path $env:temp).path 'verifier/modules')";
|
132
|
-
#{script}
|
133
|
-
EOH
|
134
|
-
end
|
135
|
-
|
136
|
-
def install_command_script
|
137
|
-
<<-EOH
|
138
|
-
function directory($path){
|
139
|
-
if (test-path $path) {(resolve-path $path).providerpath}
|
140
|
-
else {(resolve-path (mkdir $path)).providerpath}
|
141
|
-
}
|
142
|
-
$VerifierModulePath = directory $env:temp/verifier/modules
|
143
|
-
$VerifierTestsPath = directory $env:temp/verifier/pester
|
144
|
-
|
145
|
-
$env:psmodulepath += ";$VerifierModulePath"
|
146
|
-
function test-module($module){
|
147
|
-
(get-module $module -list) -ne $null
|
148
|
-
}
|
149
|
-
if (-not (test-module pester)) {
|
150
|
-
if (test-module PowerShellGet){
|
151
|
-
import-module PowerShellGet -force
|
152
|
-
import-module PackageManagement -force
|
153
|
-
get-packageprovider -name NuGet -force | out-null
|
154
|
-
install-module Pester -force
|
155
|
-
}
|
156
|
-
else {
|
157
|
-
if (-not (test-module PsGet)){
|
158
|
-
$wc = New-Object -TypeName Net.WebClient
|
159
|
-
|
160
|
-
if($env:http_Proxy){
|
161
|
-
if($env:no_proxy){
|
162
|
-
Write-Output "Creating WebProxy with 'http_proxy' and 'no_proxy' environment variables.
|
163
|
-
$webproxy = New-Object System.Net.WebProxy($env:http_Proxy,$true,$env:no_proxy)
|
164
|
-
}else{
|
165
|
-
Write-Output "Creating WebProxy with 'http_proxy' environment variable.
|
166
|
-
$webproxy = New-Object -TypeName System.Net.WebProxy -ArgumentList ($env:http_Proxy)
|
167
|
-
}
|
168
|
-
|
169
|
-
$wc.proxy = $webproxy
|
170
|
-
}
|
171
|
-
|
172
|
-
Invoke-Expression -Command $wc.DownloadString('http://bit.ly/GetPsGet')
|
173
|
-
}
|
174
|
-
try {
|
175
|
-
import-module psget -force -erroraction stop
|
176
|
-
Install-Module Pester
|
177
|
-
}
|
178
|
-
catch {
|
179
|
-
Write-Output "Installing from Github"
|
180
|
-
$zipfile = join-path(resolve-path "$env:temp/verifier") "pester.zip"
|
181
|
-
if (-not (test-path $zipfile)){
|
182
|
-
$source = 'https://github.com/pester/Pester/archive/3.3.14.zip'
|
183
|
-
$wc = New-Object -TypeName Net.WebClient
|
184
|
-
|
185
|
-
if($env:http_Proxy){
|
186
|
-
if($env:no_proxy){
|
187
|
-
Write-Output "Creating WebProxy with 'http_proxy' and 'no_proxy' environment variables."
|
188
|
-
$webproxy = New-Object System.Net.WebProxy($env:http_Proxy,$true,$env:no_proxy)
|
189
|
-
}else{
|
190
|
-
Write-Output "Creating WebProxy with 'http_proxy' environment variable."
|
191
|
-
$webproxy = New-Object -TypeName System.Net.WebProxy -ArgumentList ($env:http_Proxy)
|
192
|
-
}
|
193
|
-
|
194
|
-
$wc.proxy = $webproxy
|
195
|
-
}
|
196
|
-
|
197
|
-
[byte[]]$bytes = $wc.DownloadData($source)
|
198
|
-
[IO.File]::WriteAllBytes($zipfile, $bytes)
|
199
|
-
$bytes = $null
|
200
|
-
[gc]::collect()
|
201
|
-
write-output "Downloaded Pester.zip"
|
202
|
-
}
|
203
|
-
write-output "Creating Shell.Application COM object"
|
204
|
-
$shellcom = new-object -com shell.application
|
205
|
-
Write-Output "Creating COM object for zip file."
|
206
|
-
$zipcomobject = $shellcom.namespace($zipfile)
|
207
|
-
Write-Output "Creating COM object for module destination."
|
208
|
-
$destination = $shellcom.namespace($VerifierModulePath)
|
209
|
-
Write-Output "Unpacking zip file."
|
210
|
-
$destination.CopyHere($zipcomobject.Items(), 0x610)
|
211
|
-
rename-item (join-path $VerifierModulePath "Pester-3.3.14") -newname 'Pester' -force
|
212
|
-
}
|
213
|
-
}
|
214
|
-
}
|
215
|
-
if (-not (test-module Pester)) {
|
216
|
-
throw "Unable to install Pester. Please include Pester in your base image or install during your converge."
|
217
|
-
}
|
218
|
-
EOH
|
219
|
-
end
|
220
|
-
|
221
|
-
def restart_winrm_service
|
222
|
-
|
223
|
-
cmd = 'schtasks /Create /TN restart_winrm /TR ' \
|
224
|
-
'"powershell -command restart-service winrm" ' \
|
225
|
-
'/SC ONCE /ST 00:00 '
|
226
|
-
wrap_shell_code(Util.outdent!(<<-CMD
|
227
|
-
#{cmd}
|
228
|
-
schtasks /RUN /TN restart_winrm
|
229
|
-
CMD
|
230
|
-
))
|
231
|
-
end
|
232
|
-
|
233
|
-
# Returns an Array of test suite filenames for the related suite currently
|
234
|
-
# residing on the local workstation. Any special provisioner-specific
|
235
|
-
# directories (such as a Chef roles/ directory) are excluded.
|
236
|
-
#
|
237
|
-
# @return [Array<String>] array of suite files
|
238
|
-
# @api private
|
239
|
-
|
240
|
-
def suite_test_folder
|
241
|
-
@suite_test_folder ||= File.join(test_folder, config[:suite_name])
|
242
|
-
end
|
243
|
-
|
244
|
-
def suite_level_glob
|
245
|
-
Dir.glob(File.join(suite_test_folder, "*"))
|
246
|
-
end
|
247
|
-
|
248
|
-
def suite_verifier_level_glob
|
249
|
-
Dir.glob(File.join(suite_test_folder, "*/**/*"))
|
250
|
-
end
|
251
|
-
|
252
|
-
def local_suite_files
|
253
|
-
suite = suite_level_glob
|
254
|
-
suite_verifier = suite_verifier_level_glob
|
255
|
-
(suite << suite_verifier).flatten!.reject do |f|
|
256
|
-
File.directory?(f)
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
def sandboxify_path(path)
|
261
|
-
File.join(sandbox_path, path.sub(/#{suite_test_folder}\//i, ""))
|
262
|
-
end
|
263
|
-
|
264
|
-
# Returns an Array of common helper filenames currently residing on the
|
265
|
-
# local workstation.
|
266
|
-
#
|
267
|
-
# @return [Array<String>] array of helper files
|
268
|
-
# @api private
|
269
|
-
def helper_files
|
270
|
-
glob = Dir.glob(File.join(test_folder, "helpers", "*/**/*"))
|
271
|
-
glob.reject { |f| File.directory?(f) }
|
272
|
-
end
|
273
|
-
|
274
|
-
# Copies all common testing helper files into the suites directory in
|
275
|
-
# the sandbox.
|
276
|
-
#
|
277
|
-
# @api private
|
278
|
-
def prepare_helpers
|
279
|
-
base = File.join(test_folder, "helpers")
|
280
|
-
|
281
|
-
helper_files.each do |src|
|
282
|
-
dest = File.join(sandbox_path, src.sub("#{base}/", ""))
|
283
|
-
debug("Copying #{src} to #{dest}")
|
284
|
-
FileUtils.mkdir_p(File.dirname(dest))
|
285
|
-
FileUtils.cp(src, dest, preserve: true)
|
286
|
-
end
|
287
|
-
end
|
288
|
-
|
289
|
-
# Copies all test suite files into the suites directory in the sandbox.
|
290
|
-
#
|
291
|
-
# @api private
|
292
|
-
def prepare_pester_tests
|
293
|
-
info("Preparing to copy files from #{suite_test_folder} to the SUT.")
|
294
|
-
|
295
|
-
local_suite_files.each do |src|
|
296
|
-
dest = sandboxify_path(src)
|
297
|
-
debug("Copying #{src} to #{dest}")
|
298
|
-
FileUtils.mkdir_p(File.dirname(dest))
|
299
|
-
FileUtils.cp(src, dest, preserve: true)
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
def prepare_powershell_module(name)
|
304
|
-
FileUtils.mkdir_p(File.join(sandbox_path, "modules/#{name}"))
|
305
|
-
FileUtils.cp(
|
306
|
-
File.join(File.dirname(__FILE__), "../../support/powershell/#{name}/#{name}.psm1"),
|
307
|
-
File.join(sandbox_path, "modules/#{name}/#{name}.psm1"),
|
308
|
-
preserve: true
|
309
|
-
)
|
310
|
-
end
|
311
|
-
|
312
|
-
def prepare_powershell_modules
|
313
|
-
info("Preparing to copy supporting powershell modules.")
|
314
|
-
%w[PesterUtil].each do |module_name|
|
315
|
-
prepare_powershell_module module_name
|
316
|
-
end
|
317
|
-
|
318
|
-
end
|
319
|
-
|
320
|
-
def test_folder
|
321
|
-
return config[:test_base_path] if config[:test_folder].nil?
|
322
|
-
absolute_test_folder
|
323
|
-
end
|
324
|
-
|
325
|
-
def absolute_test_folder
|
326
|
-
path = (Pathname.new config[:test_folder]).realpath
|
327
|
-
integration_path = File.join(path, 'integration')
|
328
|
-
return path unless Dir.exist?(integration_path)
|
329
|
-
integration_path
|
330
|
-
end
|
331
|
-
|
332
|
-
end
|
333
|
-
end
|
334
|
-
end
|
data/provision.ps1
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Set-Content -Path "$env:Temp\test.txt" -Value 'testing'
|
data/spec/pester/pester_spec.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require_relative '..\..\lib\kitchen\verifier\Pester'
|
2
|
-
|
3
|
-
class MockPester < Kitchen::Verifier::Pester
|
4
|
-
def sandbox_path
|
5
|
-
'C:/users/jdoe/temp/kitchen-temp'
|
6
|
-
end
|
7
|
-
def suite_test_folder
|
8
|
-
'C:/lowercasedpath/Pester/tests'
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe 'when sandboxifying a path' do
|
13
|
-
let(:sandboxifiedPath) {
|
14
|
-
pester = MockPester.new
|
15
|
-
pester.sandboxify_path('C:/LOWERcasedpath/Pester/tests/test')
|
16
|
-
}
|
17
|
-
|
18
|
-
it 'should ignore case' do
|
19
|
-
expect(sandboxifiedPath).to eq 'C:/users/jdoe/temp/kitchen-temp/test'
|
20
|
-
end
|
21
|
-
end
|