test-kitchen 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cane +1 -1
- data/.rubocop.yml +3 -0
- data/.travis.yml +20 -9
- data/CHANGELOG.md +219 -108
- data/Gemfile +10 -6
- data/Guardfile +38 -9
- data/README.md +11 -1
- data/Rakefile +21 -37
- data/bin/kitchen +4 -4
- data/features/kitchen_action_commands.feature +161 -0
- data/features/kitchen_console_command.feature +34 -0
- data/features/kitchen_diagnose_command.feature +64 -0
- data/features/kitchen_init_command.feature +29 -17
- data/features/kitchen_list_command.feature +2 -2
- data/features/kitchen_login_command.feature +56 -0
- data/features/{sink_command.feature → kitchen_sink_command.feature} +0 -0
- data/features/kitchen_test_command.feature +88 -0
- data/features/step_definitions/gem_steps.rb +8 -6
- data/features/step_definitions/git_steps.rb +4 -2
- data/features/step_definitions/output_steps.rb +5 -0
- data/features/support/env.rb +12 -9
- data/lib/kitchen.rb +60 -38
- data/lib/kitchen/base64_stream.rb +55 -0
- data/lib/kitchen/busser.rb +124 -58
- data/lib/kitchen/cli.rb +121 -38
- data/lib/kitchen/collection.rb +3 -3
- data/lib/kitchen/color.rb +4 -4
- data/lib/kitchen/command.rb +78 -11
- data/lib/kitchen/command/action.rb +3 -2
- data/lib/kitchen/command/console.rb +12 -5
- data/lib/kitchen/command/diagnose.rb +17 -3
- data/lib/kitchen/command/driver_discover.rb +26 -7
- data/lib/kitchen/command/exec.rb +41 -0
- data/lib/kitchen/command/list.rb +44 -14
- data/lib/kitchen/command/login.rb +2 -1
- data/lib/kitchen/command/sink.rb +2 -1
- data/lib/kitchen/command/test.rb +5 -4
- data/lib/kitchen/config.rb +146 -14
- data/lib/kitchen/configurable.rb +314 -0
- data/lib/kitchen/data_munger.rb +522 -18
- data/lib/kitchen/diagnostic.rb +43 -4
- data/lib/kitchen/driver.rb +4 -4
- data/lib/kitchen/driver/base.rb +80 -115
- data/lib/kitchen/driver/dummy.rb +34 -6
- data/lib/kitchen/driver/proxy.rb +14 -3
- data/lib/kitchen/driver/ssh_base.rb +61 -7
- data/lib/kitchen/errors.rb +109 -9
- data/lib/kitchen/generator/driver_create.rb +39 -5
- data/lib/kitchen/generator/init.rb +130 -45
- data/lib/kitchen/instance.rb +162 -28
- data/lib/kitchen/lazy_hash.rb +79 -7
- data/lib/kitchen/loader/yaml.rb +159 -27
- data/lib/kitchen/logger.rb +267 -21
- data/lib/kitchen/logging.rb +30 -3
- data/lib/kitchen/login_command.rb +11 -2
- data/lib/kitchen/metadata_chopper.rb +2 -2
- data/lib/kitchen/provisioner.rb +4 -4
- data/lib/kitchen/provisioner/base.rb +107 -103
- data/lib/kitchen/provisioner/chef/berkshelf.rb +36 -8
- data/lib/kitchen/provisioner/chef/librarian.rb +40 -11
- data/lib/kitchen/provisioner/chef_base.rb +206 -167
- data/lib/kitchen/provisioner/chef_solo.rb +25 -7
- data/lib/kitchen/provisioner/chef_zero.rb +105 -29
- data/lib/kitchen/provisioner/dummy.rb +1 -1
- data/lib/kitchen/provisioner/shell.rb +21 -6
- data/lib/kitchen/rake_tasks.rb +8 -3
- data/lib/kitchen/shell_out.rb +15 -18
- data/lib/kitchen/ssh.rb +122 -27
- data/lib/kitchen/state_file.rb +24 -7
- data/lib/kitchen/thor_tasks.rb +9 -4
- data/lib/kitchen/util.rb +43 -118
- data/lib/kitchen/version.rb +1 -1
- data/lib/vendor/hash_recursive_merge.rb +10 -2
- data/spec/kitchen/base64_stream_spec.rb +77 -0
- data/spec/kitchen/busser_spec.rb +490 -0
- data/spec/kitchen/collection_spec.rb +10 -10
- data/spec/kitchen/color_spec.rb +2 -2
- data/spec/kitchen/config_spec.rb +234 -62
- data/spec/kitchen/configurable_spec.rb +490 -0
- data/spec/kitchen/data_munger_spec.rb +1070 -862
- data/spec/kitchen/diagnostic_spec.rb +79 -0
- data/spec/kitchen/driver/base_spec.rb +80 -85
- data/spec/kitchen/driver/dummy_spec.rb +43 -14
- data/spec/kitchen/driver/proxy_spec.rb +134 -0
- data/spec/kitchen/driver/ssh_base_spec.rb +644 -0
- data/spec/kitchen/driver_spec.rb +15 -15
- data/spec/kitchen/errors_spec.rb +309 -0
- data/spec/kitchen/instance_spec.rb +143 -46
- data/spec/kitchen/lazy_hash_spec.rb +36 -9
- data/spec/kitchen/loader/yaml_spec.rb +237 -226
- data/spec/kitchen/logger_spec.rb +419 -0
- data/spec/kitchen/logging_spec.rb +59 -0
- data/spec/kitchen/login_command_spec.rb +49 -0
- data/spec/kitchen/metadata_chopper_spec.rb +82 -0
- data/spec/kitchen/platform_spec.rb +4 -4
- data/spec/kitchen/provisioner/base_spec.rb +65 -125
- data/spec/kitchen/provisioner/chef_base_spec.rb +798 -0
- data/spec/kitchen/provisioner/chef_solo_spec.rb +316 -0
- data/spec/kitchen/provisioner/chef_zero_spec.rb +624 -0
- data/spec/kitchen/provisioner/shell_spec.rb +269 -0
- data/spec/kitchen/provisioner_spec.rb +6 -6
- data/spec/kitchen/shell_out_spec.rb +143 -0
- data/spec/kitchen/ssh_spec.rb +683 -0
- data/spec/kitchen/state_file_spec.rb +28 -21
- data/spec/kitchen/suite_spec.rb +7 -7
- data/spec/kitchen/util_spec.rb +68 -10
- data/spec/kitchen_spec.rb +107 -0
- data/spec/spec_helper.rb +18 -13
- data/support/chef-client-zero.rb +10 -9
- data/support/chef_helpers.sh +16 -0
- data/support/download_helpers.sh +109 -0
- data/test-kitchen.gemspec +42 -33
- metadata +107 -33
@@ -16,11 +16,11 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
|
-
require_relative
|
19
|
+
require_relative "../spec_helper"
|
20
20
|
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
21
|
+
require "kitchen/errors"
|
22
|
+
require "kitchen/state_file"
|
23
|
+
require "kitchen/util"
|
24
24
|
|
25
25
|
class YamledState
|
26
26
|
attr_accessor :yoinks
|
@@ -28,8 +28,8 @@ end
|
|
28
28
|
|
29
29
|
describe Kitchen::StateFile do
|
30
30
|
|
31
|
-
let(:state_file) { Kitchen::StateFile.new(
|
32
|
-
let(:file_name) {
|
31
|
+
let(:state_file) { Kitchen::StateFile.new("/tmp", "oftheunion") }
|
32
|
+
let(:file_name) { "/tmp/.kitchen/oftheunion.yml" }
|
33
33
|
|
34
34
|
before do
|
35
35
|
FakeFS.activate!
|
@@ -47,61 +47,68 @@ describe Kitchen::StateFile do
|
|
47
47
|
state_file.read.must_equal(Hash.new)
|
48
48
|
end
|
49
49
|
|
50
|
+
it "returns and empty hash if the file is zero length" do
|
51
|
+
stub_state_file!("")
|
52
|
+
|
53
|
+
state_file.read.must_equal(Hash.new)
|
54
|
+
end
|
55
|
+
|
50
56
|
it "returns a Hash with symbolized keys from the state file" do
|
51
57
|
stub_state_file!
|
52
58
|
|
53
|
-
state_file.read.must_equal(
|
59
|
+
state_file.read.must_equal(
|
54
60
|
:cloud_id => 42,
|
55
|
-
:flavor =>
|
56
|
-
|
61
|
+
:flavor => "extra_crispy"
|
62
|
+
)
|
57
63
|
end
|
58
64
|
|
59
65
|
it "arbitrary objects aren't deserialized from state file" do
|
60
|
-
stub_state_file! <<-'YAML'.gsub(/^ {8}/,
|
66
|
+
stub_state_file! <<-'YAML'.gsub(/^ {8}/, "")
|
61
67
|
--- !ruby/object:YamledState
|
62
68
|
yoinks: zoinks
|
63
69
|
YAML
|
64
70
|
|
65
71
|
state_file.read.class.wont_equal YamledState
|
66
72
|
state_file.read.class.must_equal Hash
|
67
|
-
state_file.read.must_equal(
|
73
|
+
state_file.read.must_equal(:yoinks => "zoinks")
|
68
74
|
end
|
69
75
|
|
70
76
|
it "raises a StateFileLoadError if the state file cannot be parsed" do
|
71
|
-
stub_state_file!(
|
77
|
+
stub_state_file!("&*%^*")
|
72
78
|
|
73
79
|
proc { state_file.read }.must_raise Kitchen::StateFileLoadError
|
74
80
|
end
|
81
|
+
|
75
82
|
end
|
76
83
|
|
77
84
|
describe "#write" do
|
78
85
|
|
79
86
|
it "creates the directory path to the state file" do
|
80
|
-
File.directory?(
|
87
|
+
File.directory?("/tmp/.kitchen").must_equal false
|
81
88
|
state_file.write({})
|
82
|
-
File.directory?(
|
89
|
+
File.directory?("/tmp/.kitchen").must_equal true
|
83
90
|
end
|
84
91
|
|
85
92
|
it "writes a state file with stringified keys" do
|
86
|
-
state_file.write(
|
93
|
+
state_file.write(:thekey => "thyself")
|
87
94
|
|
88
|
-
IO.read(file_name).split("\n").must_include
|
95
|
+
IO.read(file_name).split("\n").must_include "thekey: thyself"
|
89
96
|
end
|
90
97
|
end
|
91
98
|
|
92
99
|
describe "#destroy" do
|
93
100
|
|
94
101
|
it "executes if no file exists" do
|
95
|
-
File.
|
102
|
+
File.exist?(file_name).must_equal false
|
96
103
|
state_file.destroy
|
97
|
-
File.
|
104
|
+
File.exist?(file_name).must_equal false
|
98
105
|
end
|
99
106
|
|
100
107
|
it "deletes the state file" do
|
101
108
|
stub_state_file!
|
102
109
|
state_file.destroy
|
103
110
|
|
104
|
-
File.
|
111
|
+
File.exist?(file_name).must_equal false
|
105
112
|
end
|
106
113
|
end
|
107
114
|
|
@@ -109,7 +116,7 @@ describe Kitchen::StateFile do
|
|
109
116
|
|
110
117
|
def stub_state_file!(yaml_string = nil)
|
111
118
|
if yaml_string.nil?
|
112
|
-
yaml_string = <<-'YAML'.gsub(/^ {8}/,
|
119
|
+
yaml_string = <<-'YAML'.gsub(/^ {8}/, "")
|
113
120
|
---
|
114
121
|
cloud_id: 42
|
115
122
|
flavor: extra_crispy
|
@@ -117,6 +124,6 @@ describe Kitchen::StateFile do
|
|
117
124
|
end
|
118
125
|
|
119
126
|
FileUtils.mkdir_p(File.dirname(file_name))
|
120
|
-
File.open(file_name,
|
127
|
+
File.open(file_name, "wb") { |f| f.write(yaml_string) }
|
121
128
|
end
|
122
129
|
end
|
data/spec/kitchen/suite_spec.rb
CHANGED
@@ -16,18 +16,18 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
|
-
require_relative
|
19
|
+
require_relative "../spec_helper"
|
20
20
|
|
21
|
-
require
|
22
|
-
require
|
21
|
+
require "kitchen/errors"
|
22
|
+
require "kitchen/suite"
|
23
23
|
|
24
24
|
describe Kitchen::Suite do
|
25
25
|
|
26
26
|
let(:opts) do
|
27
27
|
{
|
28
28
|
:name => "suitezy",
|
29
|
-
:includes => [
|
30
|
-
:excludes => [
|
29
|
+
:includes => %w[testbuntu testcent],
|
30
|
+
:excludes => %w[prodbuntu]
|
31
31
|
}
|
32
32
|
end
|
33
33
|
|
@@ -43,7 +43,7 @@ describe Kitchen::Suite do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it "returns the includes" do
|
46
|
-
suite.includes.must_equal [
|
46
|
+
suite.includes.must_equal %w[testbuntu testcent]
|
47
47
|
end
|
48
48
|
|
49
49
|
it "returns an empty Array when includes not given" do
|
@@ -52,7 +52,7 @@ describe Kitchen::Suite do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
it "returns the excludes" do
|
55
|
-
suite.excludes.must_equal [
|
55
|
+
suite.excludes.must_equal %w[prodbuntu]
|
56
56
|
end
|
57
57
|
|
58
58
|
it "returns an empty Array when excludes not given" do
|
data/spec/kitchen/util_spec.rb
CHANGED
@@ -16,21 +16,21 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
|
-
require_relative
|
19
|
+
require_relative "../spec_helper"
|
20
20
|
|
21
|
-
require
|
21
|
+
require "logger"
|
22
22
|
|
23
|
-
require
|
23
|
+
require "kitchen/util"
|
24
24
|
|
25
25
|
describe Kitchen::Util do
|
26
26
|
|
27
|
-
describe
|
27
|
+
describe ".to_logger_level" do
|
28
28
|
|
29
29
|
it "returns nil for invalid symbols" do
|
30
30
|
Kitchen::Util.to_logger_level(:nope).must_be_nil
|
31
31
|
end
|
32
32
|
|
33
|
-
%w
|
33
|
+
%w[debug info warn error fatal].each do |level|
|
34
34
|
it "returns Logger::#{level.upcase} for :#{level} input" do
|
35
35
|
Kitchen::Util.to_logger_level(level.to_sym).
|
36
36
|
must_equal Logger.const_get(level.upcase)
|
@@ -44,7 +44,7 @@ describe Kitchen::Util do
|
|
44
44
|
Kitchen::Util.from_logger_level("nope").must_equal :fatal
|
45
45
|
end
|
46
46
|
|
47
|
-
%w
|
47
|
+
%w[debug info warn error fatal].each do |level|
|
48
48
|
it "returns :#{level} for Logger::#{level.upcase} input" do
|
49
49
|
Kitchen::Util.from_logger_level(Logger.const_get(level.upcase)).
|
50
50
|
must_equal(level.to_sym)
|
@@ -66,8 +66,8 @@ describe Kitchen::Util do
|
|
66
66
|
|
67
67
|
it "converts string keys into symbols" do
|
68
68
|
Kitchen::Util.
|
69
|
-
symbolized_hash(
|
70
|
-
must_equal(
|
69
|
+
symbolized_hash("one" => [{ "two" => :three, :four => "five" }]).
|
70
|
+
must_equal(:one => [{ :two => :three, :four => "five" }])
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
@@ -85,8 +85,8 @@ describe Kitchen::Util do
|
|
85
85
|
|
86
86
|
it "converts symbol keys into strings" do
|
87
87
|
Kitchen::Util.
|
88
|
-
stringified_hash(
|
89
|
-
must_equal(
|
88
|
+
stringified_hash(:one => [{ :two => :three, "four" => "five" }]).
|
89
|
+
must_equal("one" => [{ "two" => :three, "four" => "five" }])
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
@@ -104,4 +104,62 @@ describe Kitchen::Util do
|
|
104
104
|
Kitchen::Util.duration(48033).must_equal "(800m33.00s)"
|
105
105
|
end
|
106
106
|
end
|
107
|
+
|
108
|
+
describe ".wrap_unix_command" do
|
109
|
+
|
110
|
+
it "returns the wrapped command" do
|
111
|
+
end
|
112
|
+
|
113
|
+
it "returns a false if command is nil" do
|
114
|
+
Kitchen::Util.wrap_command(nil).must_equal("sh -c '\nfalse\n'")
|
115
|
+
end
|
116
|
+
|
117
|
+
it "returns a true if command string is empty" do
|
118
|
+
Kitchen::Util.wrap_command("yoyo").must_equal("sh -c '\nyoyo\n'")
|
119
|
+
end
|
120
|
+
|
121
|
+
it "handles a command string with a trailing newline" do
|
122
|
+
Kitchen::Util.wrap_command("yep\n").must_equal("sh -c '\nyep\n'")
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe ".outdent!" do
|
127
|
+
|
128
|
+
it "modifies the argument string in place, destructively" do
|
129
|
+
string = "yep"
|
130
|
+
|
131
|
+
Kitchen::Util.outdent!(string).object_id.must_equal string.object_id
|
132
|
+
end
|
133
|
+
|
134
|
+
it "returns the same string if no leading whitespace exists" do
|
135
|
+
string = "one\ntwo\nthree"
|
136
|
+
|
137
|
+
Kitchen::Util.outdent!(string).must_equal "one\ntwo\nthree"
|
138
|
+
end
|
139
|
+
|
140
|
+
it "strips same amount of leading whitespace as found on first line" do
|
141
|
+
string = " one\n two\n three\nfour"
|
142
|
+
|
143
|
+
Kitchen::Util.outdent!(string).must_equal "one\n two\n three\nfour"
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
describe ".shell_helpers" do
|
148
|
+
|
149
|
+
%w[
|
150
|
+
exists do_wget do_curl do_fetch do_perl do_python do_download
|
151
|
+
].each do |func|
|
152
|
+
it "contains a #{func} shell function" do
|
153
|
+
Kitchen::Util.shell_helpers.must_match "#{func}() {"
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
it "does not contain bare single quotes" do
|
158
|
+
Kitchen::Util.shell_helpers.wont_match "'"
|
159
|
+
end
|
160
|
+
|
161
|
+
def regexify(str)
|
162
|
+
Regexp.new("^\s+" + Regexp.escape(str) + "$")
|
163
|
+
end
|
164
|
+
end
|
107
165
|
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2014, Fletcher Nichol
|
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_relative "spec_helper"
|
20
|
+
|
21
|
+
require "kitchen"
|
22
|
+
|
23
|
+
describe "Kitchen" do
|
24
|
+
|
25
|
+
let(:stdout) { StringIO.new }
|
26
|
+
|
27
|
+
before do
|
28
|
+
FakeFS.activate!
|
29
|
+
FileUtils.mkdir_p(Dir.pwd)
|
30
|
+
stdout.stubs(:tty?).returns(true)
|
31
|
+
@orig_stdout = $stdout
|
32
|
+
$stdout = stdout
|
33
|
+
end
|
34
|
+
|
35
|
+
after do
|
36
|
+
$stdout = @orig_stdout
|
37
|
+
FakeFS.deactivate!
|
38
|
+
FakeFS::FileSystem.clear
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "defaults" do
|
42
|
+
|
43
|
+
it "sets DEFAULT_LOG_LEVEL to :info" do
|
44
|
+
Kitchen::DEFAULT_LOG_LEVEL.must_equal :info
|
45
|
+
end
|
46
|
+
|
47
|
+
it "sets DEFAULT_TEST_DIR to test/integration, which is frozen" do
|
48
|
+
Kitchen::DEFAULT_TEST_DIR.must_equal "test/integration"
|
49
|
+
Kitchen::DEFAULT_TEST_DIR.frozen?.must_equal true
|
50
|
+
end
|
51
|
+
|
52
|
+
it "sets DEFAULT_LOG_DIR to .kitchen/logs, which is frozen" do
|
53
|
+
Kitchen::DEFAULT_LOG_DIR.must_equal ".kitchen/logs"
|
54
|
+
Kitchen::DEFAULT_LOG_DIR.frozen?.must_equal true
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it ".tty? returns true if $stdout.tty? is true" do
|
59
|
+
Kitchen.tty?.must_equal true
|
60
|
+
end
|
61
|
+
|
62
|
+
it ".tty? returns flse is $stdout.tty? is false" do
|
63
|
+
stdout.stubs(:tty?).returns(false)
|
64
|
+
|
65
|
+
Kitchen.tty?.must_equal false
|
66
|
+
end
|
67
|
+
|
68
|
+
it ".source_root returns the root path of the gem" do
|
69
|
+
Kitchen.source_root.
|
70
|
+
must_equal Pathname.new(File.expand_path("../..", __FILE__))
|
71
|
+
end
|
72
|
+
|
73
|
+
it ".default_logger is a Kitchen::Logger" do
|
74
|
+
Kitchen.default_logger.must_be_instance_of Kitchen::Logger
|
75
|
+
end
|
76
|
+
|
77
|
+
it ".default_logger returns a $stdout logger" do
|
78
|
+
Kitchen.default_logger.warn("uhoh")
|
79
|
+
|
80
|
+
stdout.string.must_match %r{ uhoh$}
|
81
|
+
end
|
82
|
+
|
83
|
+
it ".default_file_logger is a Kitchen::Logger" do
|
84
|
+
Kitchen.default_file_logger.must_be_instance_of Kitchen::Logger
|
85
|
+
end
|
86
|
+
|
87
|
+
it ".default_file_logger returns a logger that uses $stdout" do
|
88
|
+
Kitchen.default_logger.warn("uhoh")
|
89
|
+
|
90
|
+
stdout.string.must_match %r{ uhoh$}
|
91
|
+
end
|
92
|
+
|
93
|
+
it ".default_file_logger returns a logger that uses a file" do
|
94
|
+
Kitchen.default_file_logger.warn("uhoh")
|
95
|
+
|
96
|
+
IO.read(File.join(%w[.kitchen logs kitchen.log])).
|
97
|
+
must_match %r{ -- Kitchen: uhoh$}
|
98
|
+
end
|
99
|
+
|
100
|
+
it "sets Kitchen.logger to a Kitchen::Logger" do
|
101
|
+
Kitchen.default_logger.must_be_instance_of Kitchen::Logger
|
102
|
+
end
|
103
|
+
|
104
|
+
it "sets Kitchen.mutex to a Mutex" do
|
105
|
+
Kitchen.mutex.must_be_instance_of Mutex
|
106
|
+
end
|
107
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -16,24 +16,29 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
|
-
gem
|
19
|
+
gem "minitest"
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
if ENV["CODECLIMATE_REPO_TOKEN"]
|
22
|
+
require "codeclimate-test-reporter"
|
23
|
+
CodeClimate::TestReporter.start
|
24
|
+
elsif ENV["COVERAGE"]
|
25
|
+
require "simplecov"
|
26
|
+
SimpleCov.profiles.define "gem" do
|
27
|
+
command_name "Specs"
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
|
29
|
+
add_filter ".gem/"
|
30
|
+
add_filter "/spec/"
|
31
|
+
add_filter "/lib/vendor/"
|
28
32
|
|
29
|
-
|
33
|
+
add_group "Libraries", "/lib/"
|
34
|
+
end
|
35
|
+
SimpleCov.start "gem"
|
30
36
|
end
|
31
|
-
SimpleCov.start 'gem'
|
32
37
|
|
33
|
-
require
|
34
|
-
require
|
35
|
-
require
|
36
|
-
require
|
38
|
+
require "fakefs/safe"
|
39
|
+
require "minitest/autorun"
|
40
|
+
require "mocha/setup"
|
41
|
+
require "tempfile"
|
37
42
|
|
38
43
|
# Nasty hack to redefine IO.read in terms of File#read for fakefs
|
39
44
|
class IO
|
data/support/chef-client-zero.rb
CHANGED
@@ -17,19 +17,20 @@
|
|
17
17
|
# See the License for the specific language governing permissions and
|
18
18
|
# limitations under the License.
|
19
19
|
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
20
|
+
require "rubygems"
|
21
|
+
require "chef/config"
|
22
|
+
require "chef_zero/server"
|
23
|
+
require "chef/chef_fs/chef_fs_data_store"
|
24
|
+
require "chef/chef_fs/config"
|
25
|
+
require "English"
|
26
|
+
require "fileutils"
|
26
27
|
|
27
28
|
# Bust out of our self-imposed sandbox before running chef-client so
|
28
29
|
# gems installed via gem_package land in Chef's GEM_HOME.
|
29
30
|
#
|
30
31
|
# https://github.com/opscode/test-kitchen/issues/240
|
31
32
|
#
|
32
|
-
ENV[
|
33
|
+
ENV["GEM_HOME"] = ENV["GEM_PATH"] = ENV["GEM_CACHE"] = nil
|
33
34
|
|
34
35
|
class ChefClientZero
|
35
36
|
|
@@ -64,12 +65,12 @@ class ChefClientZero
|
|
64
65
|
end
|
65
66
|
|
66
67
|
def repo_path
|
67
|
-
ENV.fetch(
|
68
|
+
ENV.fetch("CHEF_REPO_PATH", Dir.pwd)
|
68
69
|
end
|
69
70
|
|
70
71
|
def run_chef_client
|
71
72
|
system("chef-client", *ARGV)
|
72
|
-
fail if
|
73
|
+
fail if $CHILD_STATUS != 0
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|