test-kitchen 1.23.3 → 1.23.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kitchen/version.rb +1 -1
- data/support/chef-client-zero.rb +1 -1
- metadata +5 -324
- data/.gitattributes +0 -3
- data/.github/ISSUE_TEMPLATE.md +0 -56
- data/.github/lock.yml +0 -1
- data/.gitignore +0 -38
- data/.gitmodules +0 -0
- data/.kitchen.appveyor.yml +0 -25
- data/.kitchen.dokken.yml +0 -31
- data/.kitchen.proxy.yml +0 -27
- data/.rubocop.yml +0 -5
- data/.travis.yml +0 -57
- data/.yardopts +0 -3
- data/Berksfile +0 -3
- data/CHANGELOG.md +0 -1510
- data/CONTRIBUTING.md +0 -14
- data/ECOSYSTEM.md +0 -93
- data/Gemfile +0 -40
- data/Gemfile.proxy_tests +0 -4
- data/Guardfile +0 -42
- data/MAINTAINERS.md +0 -29
- data/README.md +0 -138
- data/RELEASE_NOTES.md +0 -167
- data/Rakefile +0 -77
- data/appveyor.yml +0 -47
- data/docs/CONTRIBUTING.md +0 -8
- data/docs/LICENSE +0 -22
- data/docs/README.md +0 -78
- data/docs/archetypes/default.md +0 -6
- data/docs/config.toml +0 -36
- data/docs/content/docs/_index.md +0 -5
- data/docs/content/docs/drivers/_index.md +0 -27
- data/docs/content/docs/drivers/azurerm.md +0 -44
- data/docs/content/docs/drivers/vagrant.md +0 -39
- data/docs/content/docs/getting-started/00-introduction.md +0 -14
- data/docs/content/docs/getting-started/01-installing.md +0 -64
- data/docs/content/docs/getting-started/02-getting-help.md +0 -59
- data/docs/content/docs/getting-started/03-creating-cookbook.md +0 -46
- data/docs/content/docs/getting-started/04-kitchen-yml.md +0 -56
- data/docs/content/docs/getting-started/05-instances.md +0 -79
- data/docs/content/docs/getting-started/06-writing-recipe.md +0 -21
- data/docs/content/docs/getting-started/07-running-converge.md +0 -134
- data/docs/content/docs/getting-started/08-manually-verifying.md +0 -55
- data/docs/content/docs/getting-started/09-writing-test.md +0 -49
- data/docs/content/docs/getting-started/10-running-verify.md +0 -120
- data/docs/content/docs/getting-started/11-running-test.md +0 -168
- data/docs/content/docs/getting-started/12-adding-platform.md +0 -206
- data/docs/content/docs/getting-started/13-adding-feature.md +0 -30
- data/docs/content/docs/getting-started/14-adding-suite.md +0 -60
- data/docs/content/docs/getting-started/15-adding-test.md +0 -66
- data/docs/content/docs/getting-started/16-adding-recipe.md +0 -53
- data/docs/content/docs/getting-started/17-excluding-platforms.md +0 -101
- data/docs/content/docs/getting-started/18-next-steps.md +0 -23
- data/docs/content/docs/getting-started/_index.md +0 -5
- data/docs/content/docs/provisioners/_index.md +0 -36
- data/docs/content/docs/provisioners/chef.md +0 -69
- data/docs/content/docs/provisioners/shell.md +0 -31
- data/docs/content/docs/reference/_index.md +0 -5
- data/docs/content/docs/reference/configuration.md +0 -53
- data/docs/content/docs/reference/examples.md +0 -97
- data/docs/content/docs/reference/faq.md +0 -58
- data/docs/content/docs/reference/fixtures.md +0 -32
- data/docs/content/docs/reference/glossary.md +0 -34
- data/docs/content/docs/reference/lifecycle-hooks.md +0 -68
- data/docs/content/docs/reference/reboots.md +0 -24
- data/docs/content/docs/verifiers/_index.md +0 -14
- data/docs/content/docs/verifiers/inspec.md +0 -44
- data/docs/content/docs/verifiers/serverspec.md +0 -20
- data/docs/static/images/chef-logo.png +0 -0
- data/docs/static/images/chef-logo.svg +0 -1
- data/docs/static/images/github-banner.png +0 -0
- data/docs/static/images/github-banner.svg +0 -71
- data/docs/static/images/kitchen-logo.png +0 -0
- data/docs/static/images/logo-block.svg +0 -222
- data/docs/static/images/logo.png +0 -0
- data/docs/static/images/logos-group.png +0 -0
- data/docs/static/images/terminal-1.png +0 -0
- data/docs/static/images/terminal-1.svg +0 -589
- data/docs/static/images/terminal-2.png +0 -0
- data/docs/static/images/terminal-2.svg +0 -235
- data/docs/static/images/terminal-3.png +0 -0
- data/docs/static/images/terminal-3.svg +0 -439
- data/docs/static/index.html +0 -59
- data/docs/static/javascripts/all.js +0 -348
- data/docs/static/javascripts/vendor/foundation.min.js +0 -4
- data/docs/static/javascripts/vendor/jquery.min.js +0 -5
- data/docs/static/javascripts/vendor/what-input.js +0 -336
- data/docs/static/stylesheets/site.css +0 -4667
- data/docs/themes/kitchen/layouts/_default/baseof.html +0 -53
- data/docs/themes/kitchen/layouts/_default/list.html +0 -4
- data/docs/themes/kitchen/layouts/_default/redirect.html +0 -10
- data/docs/themes/kitchen/layouts/_default/single.html +0 -6
- data/docs/themes/kitchen/layouts/partials/core/head.html +0 -6
- data/docs/themes/kitchen/layouts/partials/kitchen/footer.html +0 -18
- data/docs/themes/kitchen/layouts/partials/kitchen/head.html +0 -4
- data/docs/themes/kitchen/layouts/partials/kitchen/header.html +0 -26
- data/docs/themes/kitchen/layouts/partials/search-docs.html +0 -3
- data/docs/themes/kitchen/layouts/partials/sidebar.html +0 -33
- data/docs/themes/kitchen/layouts/shortcodes/button.html +0 -1
- data/docs/themes/kitchen/layouts/shortcodes/codeblock.html +0 -8
- data/docs/themes/kitchen/layouts/shortcodes/cta.html +0 -5
- data/docs/themes/kitchen/layouts/shortcodes/danger.html +0 -1
- data/docs/themes/kitchen/layouts/shortcodes/example_fqdn.html +0 -1
- data/docs/themes/kitchen/layouts/shortcodes/info.html +0 -1
- data/docs/themes/kitchen/layouts/shortcodes/ol-styled.html +0 -3
- data/docs/themes/kitchen/layouts/shortcodes/success.html +0 -1
- data/docs/themes/kitchen/layouts/shortcodes/tip.html +0 -1
- data/docs/themes/kitchen/layouts/shortcodes/warning.html +0 -1
- data/docs/themes/kitchen/static/css/kitchen.css +0 -10
- data/docs/themes/kitchen/static/css/kitchen.css.map +0 -7
- data/docs/themes/kitchen/static/fonts/Muli-Bold.ttf +0 -0
- data/docs/themes/kitchen/static/fonts/Muli-Regular.ttf +0 -0
- data/docs/themes/kitchen/static/fonts/Muli-SemiBold.ttf +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.eot +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.svg +0 -1104
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.ttf +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.woff +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-brands-400.woff2 +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.eot +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.svg +0 -372
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.ttf +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.woff +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-regular-400.woff2 +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.eot +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.svg +0 -1896
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.ttf +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.woff +0 -0
- data/docs/themes/kitchen/static/fonts/fontawesome/fa-solid-900.woff2 +0 -0
- data/docs/themes/kitchen/static/images/chef-logo-light.svg +0 -36
- data/docs/themes/kitchen/static/images/chef-logo-white.svg +0 -38
- data/docs/themes/kitchen/static/images/chef-logo.svg +0 -37
- data/docs/themes/kitchen/static/images/favicon.ico +0 -0
- data/docs/themes/kitchen/static/js/scripts-all.js +0 -7
- data/docs/themes/kitchen/static/js/source/chef-hugo.js +0 -116
- data/docs/themes/kitchen/static/js/source/omnitruck.js +0 -82
- data/docs/themes/kitchen/static/js/source/segment.js +0 -52
- data/docs/themes/kitchen/static/sass/_buttons.scss +0 -161
- data/docs/themes/kitchen/static/sass/_core.scss +0 -24
- data/docs/themes/kitchen/static/sass/_forms.scss +0 -14
- data/docs/themes/kitchen/static/sass/_mixins.scss +0 -133
- data/docs/themes/kitchen/static/sass/_typography.scss +0 -34
- data/docs/themes/kitchen/static/sass/_variables.scss +0 -82
- data/docs/themes/kitchen/static/sass/kitchen.scss +0 -7
- data/docs/themes/kitchen/static/sass/kitchen/_footer.scss +0 -50
- data/docs/themes/kitchen/static/sass/kitchen/_header.scss +0 -187
- data/docs/themes/kitchen/static/sass/kitchen/_homepage.scss +0 -27
- data/docs/themes/kitchen/static/sass/kitchen/_utility-bar.scss +0 -173
- data/docs/themes/kitchen/static/sass/partials/_alerts.scss +0 -32
- data/docs/themes/kitchen/static/sass/partials/_bg.scss +0 -19
- data/docs/themes/kitchen/static/sass/partials/_blurbs.scss +0 -25
- data/docs/themes/kitchen/static/sass/partials/_callout.scss +0 -15
- data/docs/themes/kitchen/static/sass/partials/_cards.scss +0 -54
- data/docs/themes/kitchen/static/sass/partials/_dropdown.scss +0 -77
- data/docs/themes/kitchen/static/sass/partials/_grid.scss +0 -87
- data/docs/themes/kitchen/static/sass/partials/_padding.scss +0 -73
- data/docs/themes/kitchen/static/sass/partials/_sidebar.scss +0 -71
- data/docs/themes/kitchen/static/sass/partials/_tabs.scss +0 -125
- data/docs/themes/kitchen/static/sass/typography/_chroma.scss +0 -366
- data/docs/themes/kitchen/static/sass/typography/_code.scss +0 -72
- data/docs/themes/kitchen/static/sass/typography/_headers.scss +0 -90
- data/docs/themes/kitchen/static/sass/typography/_links.scss +0 -127
- data/docs/themes/kitchen/static/sass/typography/_lists.scss +0 -155
- data/docs/themes/kitchen/static/sass/typography/_prose.scss +0 -29
- data/docs/themes/kitchen/static/sass/typography/_text.scss +0 -221
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_animated.scss +0 -20
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_bordered-pulled.scss +0 -20
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_core.scss +0 -16
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_fixed-width.scss +0 -6
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_icons.scss +0 -992
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_larger.scss +0 -23
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_list.scss +0 -18
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_mixins.scss +0 -57
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_rotated-flipped.scss +0 -23
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_screen-reader.scss +0 -5
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_stacked.scss +0 -31
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/_variables.scss +0 -1005
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/fa-brands.scss +0 -21
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/fa-regular.scss +0 -22
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/fa-solid.scss +0 -23
- data/docs/themes/kitchen/static/sass/vendor/fontawesome/fontawesome.scss +0 -16
- data/docs/themes/kitchen/theme.toml +0 -8
- data/features/kitchen_action_commands.feature +0 -164
- data/features/kitchen_command.feature +0 -16
- data/features/kitchen_console_command.feature +0 -35
- data/features/kitchen_defaults.feature +0 -38
- data/features/kitchen_diagnose_command.feature +0 -96
- data/features/kitchen_help_command.feature +0 -16
- data/features/kitchen_init_command.feature +0 -254
- data/features/kitchen_list_command.feature +0 -140
- data/features/kitchen_login_command.feature +0 -62
- data/features/kitchen_sink_command.feature +0 -30
- data/features/kitchen_test_command.feature +0 -88
- data/features/step_definitions/gem_steps.rb +0 -24
- data/features/step_definitions/git_steps.rb +0 -5
- data/features/step_definitions/output_steps.rb +0 -5
- data/features/support/env.rb +0 -74
- data/spec/kitchen/base64_stream_spec.rb +0 -74
- data/spec/kitchen/cli_spec.rb +0 -54
- data/spec/kitchen/collection_spec.rb +0 -76
- data/spec/kitchen/color_spec.rb +0 -51
- data/spec/kitchen/config_spec.rb +0 -434
- data/spec/kitchen/configurable_spec.rb +0 -1113
- data/spec/kitchen/data_munger_spec.rb +0 -2800
- data/spec/kitchen/diagnostic_spec.rb +0 -128
- data/spec/kitchen/driver/base_spec.rb +0 -132
- data/spec/kitchen/driver/dummy_spec.rb +0 -193
- data/spec/kitchen/driver/exec_spec.rb +0 -75
- data/spec/kitchen/driver/proxy_spec.rb +0 -127
- data/spec/kitchen/driver/ssh_base_spec.rb +0 -1136
- data/spec/kitchen/driver_spec.rb +0 -106
- data/spec/kitchen/errors_spec.rb +0 -317
- data/spec/kitchen/instance_spec.rb +0 -1372
- data/spec/kitchen/lazy_hash_spec.rb +0 -113
- data/spec/kitchen/lifecycle_hooks_spec.rb +0 -171
- data/spec/kitchen/loader/yaml_spec.rb +0 -787
- data/spec/kitchen/logger_spec.rb +0 -425
- data/spec/kitchen/logging_spec.rb +0 -56
- data/spec/kitchen/login_command_spec.rb +0 -67
- data/spec/kitchen/metadata_chopper_spec.rb +0 -79
- data/spec/kitchen/platform_spec.rb +0 -88
- data/spec/kitchen/provisioner/base_spec.rb +0 -393
- data/spec/kitchen/provisioner/chef/policyfile_spec.rb +0 -140
- data/spec/kitchen/provisioner/chef_apply_spec.rb +0 -131
- data/spec/kitchen/provisioner/chef_base_spec.rb +0 -1565
- data/spec/kitchen/provisioner/chef_solo_spec.rb +0 -602
- data/spec/kitchen/provisioner/chef_zero_spec.rb +0 -1013
- data/spec/kitchen/provisioner/dummy_spec.rb +0 -96
- data/spec/kitchen/provisioner/shell_spec.rb +0 -623
- data/spec/kitchen/provisioner_spec.rb +0 -101
- data/spec/kitchen/shell_out_spec.rb +0 -146
- data/spec/kitchen/ssh_spec.rb +0 -584
- data/spec/kitchen/state_file_spec.rb +0 -122
- data/spec/kitchen/suite_spec.rb +0 -61
- data/spec/kitchen/transport/base_spec.rb +0 -140
- data/spec/kitchen/transport/exec_spec.rb +0 -79
- data/spec/kitchen/transport/ssh_spec.rb +0 -1317
- data/spec/kitchen/transport/winrm_spec.rb +0 -1320
- data/spec/kitchen/transport_spec.rb +0 -106
- data/spec/kitchen/util_spec.rb +0 -250
- data/spec/kitchen/verifier/base_spec.rb +0 -346
- data/spec/kitchen/verifier/busser_spec.rb +0 -580
- data/spec/kitchen/verifier/dummy_spec.rb +0 -96
- data/spec/kitchen/verifier/shell_spec.rb +0 -157
- data/spec/kitchen/verifier_spec.rb +0 -114
- data/spec/kitchen_spec.rb +0 -112
- data/spec/spec_helper.rb +0 -110
- data/spec/support/powershell_max_size_spec.rb +0 -39
- data/test-kitchen.gemspec +0 -49
- data/test/cookbooks/test_cookbook/metadata.rb +0 -6
- data/test/cookbooks/test_cookbook/recipes/default.rb +0 -1
- data/test/integration/default/default_spec.rb +0 -3
- data/testing_windows.md +0 -38
data/spec/kitchen/logger_spec.rb
DELETED
@@ -1,425 +0,0 @@
|
|
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::Logger do
|
24
|
-
before do
|
25
|
-
@orig_stdout = $stdout
|
26
|
-
$stdout = StringIO.new
|
27
|
-
end
|
28
|
-
|
29
|
-
after do
|
30
|
-
$stdout = @orig_stdout
|
31
|
-
end
|
32
|
-
|
33
|
-
def colorize(*args)
|
34
|
-
Kitchen::Color.colorize(*args)
|
35
|
-
end
|
36
|
-
|
37
|
-
def log_tmpname
|
38
|
-
t = Time.now.strftime("%Y%m%d")
|
39
|
-
"kitchen-#{t}-#{$$}-#{rand(0x100000000).to_s(36)}.log"
|
40
|
-
end
|
41
|
-
|
42
|
-
let(:opts) do
|
43
|
-
{ color: :red, colorize: true }
|
44
|
-
end
|
45
|
-
|
46
|
-
let(:logger) do
|
47
|
-
Kitchen::Logger.new(opts)
|
48
|
-
end
|
49
|
-
|
50
|
-
it "sets the log level to :info by default" do
|
51
|
-
logger.level.must_equal Kitchen::Util.to_logger_level(:info)
|
52
|
-
logger.debug?.must_equal false
|
53
|
-
logger.info?.must_equal true
|
54
|
-
logger.error?.must_equal true
|
55
|
-
logger.warn?.must_equal true
|
56
|
-
logger.fatal?.must_equal true
|
57
|
-
end
|
58
|
-
|
59
|
-
it "sets a level at creation" do
|
60
|
-
opts[:level] = Kitchen::Util.to_logger_level(:warn)
|
61
|
-
|
62
|
-
logger.level.must_equal Kitchen::Util.to_logger_level(:warn)
|
63
|
-
logger.info?.must_equal false
|
64
|
-
logger.warn?.must_equal true
|
65
|
-
logger.fatal?.must_equal true
|
66
|
-
end
|
67
|
-
|
68
|
-
it "sets a level after creation" do
|
69
|
-
logger.level = Kitchen::Util.to_logger_level(:fatal)
|
70
|
-
|
71
|
-
logger.level.must_equal Kitchen::Util.to_logger_level(:fatal)
|
72
|
-
logger.warn?.must_equal false
|
73
|
-
logger.fatal?.must_equal true
|
74
|
-
end
|
75
|
-
|
76
|
-
it "datetime_format is nil by default" do
|
77
|
-
logger.datetime_format.must_be_nil
|
78
|
-
end
|
79
|
-
|
80
|
-
it "sets datetime_format after creation" do
|
81
|
-
logger.datetime_format = "smart?"
|
82
|
-
|
83
|
-
logger.datetime_format.must_equal "smart?"
|
84
|
-
end
|
85
|
-
|
86
|
-
it "sets progname to Kitchen by default" do
|
87
|
-
logger.progname.must_equal "Kitchen"
|
88
|
-
end
|
89
|
-
|
90
|
-
it "sets progname at creation" do
|
91
|
-
opts[:progname] = "Dream Theater"
|
92
|
-
|
93
|
-
logger.progname.must_equal "Dream Theater"
|
94
|
-
end
|
95
|
-
|
96
|
-
it "sets progname after creation" do
|
97
|
-
logger.progname = "MASTA"
|
98
|
-
|
99
|
-
logger.progname.must_equal "MASTA"
|
100
|
-
end
|
101
|
-
|
102
|
-
describe "stdout-based logger" do
|
103
|
-
let(:stdout) { StringIO.new }
|
104
|
-
|
105
|
-
before { opts[:stdout] = stdout }
|
106
|
-
|
107
|
-
it "sets up a simple STDOUT logger by default" do
|
108
|
-
opts.delete(:stdout)
|
109
|
-
logger.info("hello")
|
110
|
-
|
111
|
-
$stdout.string.must_equal colorize(" hello", opts[:color]) + "\n"
|
112
|
-
end
|
113
|
-
|
114
|
-
it "sets up a simple STDOUT logger by default with no color" do
|
115
|
-
opts[:colorize] = false
|
116
|
-
opts.delete(:stdout)
|
117
|
-
logger.info("hello")
|
118
|
-
|
119
|
-
$stdout.string.must_equal " hello\n"
|
120
|
-
end
|
121
|
-
|
122
|
-
it "accepts a :stdout option to redirect output" do
|
123
|
-
logger.info("hello")
|
124
|
-
|
125
|
-
stdout.string.must_equal colorize(" hello", opts[:color]) + "\n"
|
126
|
-
end
|
127
|
-
|
128
|
-
it "accepts a :stdout option to redirect output with no color" do
|
129
|
-
opts[:colorize] = false
|
130
|
-
logger.info("hello")
|
131
|
-
|
132
|
-
stdout.string.must_equal " hello\n"
|
133
|
-
end
|
134
|
-
|
135
|
-
describe "for severity" do
|
136
|
-
before { opts[:level] = Kitchen::Util.to_logger_level(:debug) }
|
137
|
-
|
138
|
-
it "logs to banner" do
|
139
|
-
logger.banner("yo")
|
140
|
-
|
141
|
-
stdout.string.must_equal colorize("-----> yo", opts[:color]) + "\n"
|
142
|
-
end
|
143
|
-
|
144
|
-
it "logs to banner with no color" do
|
145
|
-
opts[:colorize] = false
|
146
|
-
logger.banner("yo")
|
147
|
-
|
148
|
-
stdout.string.must_equal "-----> yo\n"
|
149
|
-
end
|
150
|
-
|
151
|
-
it "logs to debug" do
|
152
|
-
logger.debug("yo")
|
153
|
-
|
154
|
-
stdout.string.must_equal colorize("D yo", opts[:color]) + "\n"
|
155
|
-
end
|
156
|
-
|
157
|
-
it "logs to debug with no color" do
|
158
|
-
opts[:colorize] = false
|
159
|
-
logger.debug("yo")
|
160
|
-
|
161
|
-
stdout.string.must_equal "D yo\n"
|
162
|
-
end
|
163
|
-
|
164
|
-
it "logs to info" do
|
165
|
-
logger.info("yo")
|
166
|
-
|
167
|
-
stdout.string.must_equal colorize(" yo", opts[:color]) + "\n"
|
168
|
-
end
|
169
|
-
|
170
|
-
it "logs to info with no color" do
|
171
|
-
opts[:colorize] = false
|
172
|
-
logger.info("yo")
|
173
|
-
|
174
|
-
stdout.string.must_equal " yo\n"
|
175
|
-
end
|
176
|
-
|
177
|
-
it "logs to error" do
|
178
|
-
logger.error("yo")
|
179
|
-
|
180
|
-
stdout.string.must_equal colorize(">>>>>> yo", opts[:color]) + "\n"
|
181
|
-
end
|
182
|
-
|
183
|
-
it "logs to error with no color" do
|
184
|
-
opts[:colorize] = false
|
185
|
-
logger.error("yo")
|
186
|
-
|
187
|
-
stdout.string.must_equal ">>>>>> yo\n"
|
188
|
-
end
|
189
|
-
|
190
|
-
it "logs to warn" do
|
191
|
-
logger.warn("yo")
|
192
|
-
|
193
|
-
stdout.string.must_equal colorize("$$$$$$ yo", opts[:color]) + "\n"
|
194
|
-
end
|
195
|
-
|
196
|
-
it "logs to warn with no color" do
|
197
|
-
opts[:colorize] = false
|
198
|
-
logger.warn("yo")
|
199
|
-
|
200
|
-
stdout.string.must_equal "$$$$$$ yo\n"
|
201
|
-
end
|
202
|
-
|
203
|
-
it "logs to fatal" do
|
204
|
-
logger.fatal("yo")
|
205
|
-
|
206
|
-
stdout.string.must_equal colorize("!!!!!! yo", opts[:color]) + "\n"
|
207
|
-
end
|
208
|
-
|
209
|
-
it "logs to fatal with no color" do
|
210
|
-
opts[:colorize] = false
|
211
|
-
logger.fatal("yo")
|
212
|
-
|
213
|
-
stdout.string.must_equal "!!!!!! yo\n"
|
214
|
-
end
|
215
|
-
|
216
|
-
it "logs to unknown" do
|
217
|
-
logger.unknown("yo")
|
218
|
-
|
219
|
-
stdout.string.must_equal colorize("?????? yo", opts[:color]) + "\n"
|
220
|
-
end
|
221
|
-
|
222
|
-
it "logs to unknown with no color" do
|
223
|
-
opts[:colorize] = false
|
224
|
-
logger.unknown("yo")
|
225
|
-
|
226
|
-
stdout.string.must_equal "?????? yo\n"
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
describe "#<<" do
|
231
|
-
it "message with a newline are logged on info" do
|
232
|
-
logger << "yo\n"
|
233
|
-
|
234
|
-
stdout.string.must_equal colorize(" yo", opts[:color]) + "\n"
|
235
|
-
end
|
236
|
-
|
237
|
-
it "message with multiple newlines are separately logged on info" do
|
238
|
-
logger << "yo\nheya\n"
|
239
|
-
|
240
|
-
stdout.string.must_equal(
|
241
|
-
colorize(" yo", opts[:color]) + "\n" +
|
242
|
-
colorize(" heya", opts[:color]) + "\n"
|
243
|
-
)
|
244
|
-
end
|
245
|
-
|
246
|
-
it "message with info, error, and banner lines will be preserved" do
|
247
|
-
logger << [
|
248
|
-
"-----> banner",
|
249
|
-
" info",
|
250
|
-
">>>>>> error",
|
251
|
-
"vanilla",
|
252
|
-
].join("\n").concat("\n")
|
253
|
-
|
254
|
-
stdout.string.must_equal(
|
255
|
-
colorize("-----> banner", opts[:color]) + "\n" +
|
256
|
-
colorize(" info", opts[:color]) + "\n" +
|
257
|
-
colorize(">>>>>> error", opts[:color]) + "\n" +
|
258
|
-
colorize(" vanilla", opts[:color]) + "\n"
|
259
|
-
)
|
260
|
-
end
|
261
|
-
|
262
|
-
it "message with line that is not newline terminated will be buffered" do
|
263
|
-
logger << [
|
264
|
-
"-----> banner",
|
265
|
-
" info",
|
266
|
-
"partial",
|
267
|
-
].join("\n")
|
268
|
-
|
269
|
-
stdout.string.must_equal(
|
270
|
-
colorize("-----> banner", opts[:color]) + "\n" +
|
271
|
-
colorize(" info", opts[:color]) + "\n"
|
272
|
-
)
|
273
|
-
end
|
274
|
-
|
275
|
-
it "logger with buffered data will flush on next message with newline" do
|
276
|
-
logger << "partial"
|
277
|
-
logger << "ly\nokay\n"
|
278
|
-
|
279
|
-
stdout.string.must_equal(
|
280
|
-
colorize(" partially", opts[:color]) + "\n" +
|
281
|
-
colorize(" okay", opts[:color]) + "\n"
|
282
|
-
)
|
283
|
-
end
|
284
|
-
|
285
|
-
it "logger that receives mixed first chunk will flush next message with newline" do
|
286
|
-
logger << "partially\no"
|
287
|
-
logger << "kay\n"
|
288
|
-
|
289
|
-
stdout.string.must_equal(
|
290
|
-
colorize(" partially", opts[:color]) + "\n" +
|
291
|
-
colorize(" okay", opts[:color]) + "\n"
|
292
|
-
)
|
293
|
-
end
|
294
|
-
|
295
|
-
it "logger chomps carriage return characters" do
|
296
|
-
logger << [
|
297
|
-
"-----> banner\r",
|
298
|
-
"vanilla\r",
|
299
|
-
].join("\n").concat("\n")
|
300
|
-
|
301
|
-
stdout.string.must_equal(
|
302
|
-
colorize("-----> banner", opts[:color]) + "\n" +
|
303
|
-
colorize(" vanilla", opts[:color]) + "\n"
|
304
|
-
)
|
305
|
-
end
|
306
|
-
end
|
307
|
-
end
|
308
|
-
|
309
|
-
describe "opened IO logdev-based logger" do
|
310
|
-
let(:logdev) { StringIO.new }
|
311
|
-
|
312
|
-
before { opts[:logdev] = logdev }
|
313
|
-
|
314
|
-
describe "for severity" do
|
315
|
-
before { opts[:level] = Kitchen::Util.to_logger_level(:debug) }
|
316
|
-
|
317
|
-
let(:ts) { '\\[[^\\]]+\\]' }
|
318
|
-
|
319
|
-
it "logs to banner" do
|
320
|
-
logger.banner("yo")
|
321
|
-
|
322
|
-
logdev.string.must_match(/^I, #{ts} INFO -- Kitchen: -----> yo$/)
|
323
|
-
end
|
324
|
-
|
325
|
-
it "logs to debug" do
|
326
|
-
logger.debug("yo")
|
327
|
-
|
328
|
-
logdev.string.must_match(/^D, #{ts} DEBUG -- Kitchen: yo$/)
|
329
|
-
end
|
330
|
-
|
331
|
-
it "logs to info" do
|
332
|
-
logger.info("yo")
|
333
|
-
|
334
|
-
logdev.string.must_match(/^I, #{ts} INFO -- Kitchen: yo$/)
|
335
|
-
end
|
336
|
-
|
337
|
-
it "logs to error" do
|
338
|
-
logger.error("yo")
|
339
|
-
|
340
|
-
logdev.string.must_match(/^E, #{ts} ERROR -- Kitchen: yo$/)
|
341
|
-
end
|
342
|
-
|
343
|
-
it "logs to warn" do
|
344
|
-
logger.warn("yo")
|
345
|
-
|
346
|
-
logdev.string.must_match(/^W, #{ts} WARN -- Kitchen: yo$/)
|
347
|
-
end
|
348
|
-
|
349
|
-
it "logs to fatal" do
|
350
|
-
logger.fatal("yo")
|
351
|
-
|
352
|
-
logdev.string.must_match(/^F, #{ts} FATAL -- Kitchen: yo$/)
|
353
|
-
end
|
354
|
-
|
355
|
-
it "logs to unknown" do
|
356
|
-
logger.unknown("yo")
|
357
|
-
|
358
|
-
logdev.string.must_match(/^A, #{ts} ANY -- Kitchen: yo$/)
|
359
|
-
end
|
360
|
-
end
|
361
|
-
end
|
362
|
-
|
363
|
-
describe "file IO logdev-based logger" do
|
364
|
-
let(:logfile) { File.join Dir.tmpdir, log_tmpname }
|
365
|
-
|
366
|
-
before do
|
367
|
-
opts[:logdev] = logfile
|
368
|
-
FakeFS.activate!
|
369
|
-
FileUtils.mkdir_p("/tmp")
|
370
|
-
end
|
371
|
-
|
372
|
-
after do
|
373
|
-
FakeFS.deactivate!
|
374
|
-
FakeFS::FileSystem.clear
|
375
|
-
end
|
376
|
-
|
377
|
-
describe "for severity" do
|
378
|
-
before { opts[:level] = Kitchen::Util.to_logger_level(:debug) }
|
379
|
-
|
380
|
-
let(:ts) { '\\[[^\\]]+\\]' }
|
381
|
-
|
382
|
-
it "logs to banner" do
|
383
|
-
logger.banner("yo")
|
384
|
-
|
385
|
-
IO.read(logfile).must_match(/^I, #{ts} INFO -- Kitchen: -----> yo$/)
|
386
|
-
end
|
387
|
-
|
388
|
-
it "logs to debug" do
|
389
|
-
logger.debug("yo")
|
390
|
-
|
391
|
-
IO.read(logfile).must_match(/^D, #{ts} DEBUG -- Kitchen: yo$/)
|
392
|
-
end
|
393
|
-
|
394
|
-
it "logs to info" do
|
395
|
-
logger.info("yo")
|
396
|
-
|
397
|
-
IO.read(logfile).must_match(/^I, #{ts} INFO -- Kitchen: yo$/)
|
398
|
-
end
|
399
|
-
|
400
|
-
it "logs to error" do
|
401
|
-
logger.error("yo")
|
402
|
-
|
403
|
-
IO.read(logfile).must_match(/^E, #{ts} ERROR -- Kitchen: yo$/)
|
404
|
-
end
|
405
|
-
|
406
|
-
it "logs to warn" do
|
407
|
-
logger.warn("yo")
|
408
|
-
|
409
|
-
IO.read(logfile).must_match(/^W, #{ts} WARN -- Kitchen: yo$/)
|
410
|
-
end
|
411
|
-
|
412
|
-
it "logs to fatal" do
|
413
|
-
logger.fatal("yo")
|
414
|
-
|
415
|
-
IO.read(logfile).must_match(/^F, #{ts} FATAL -- Kitchen: yo$/)
|
416
|
-
end
|
417
|
-
|
418
|
-
it "logs to unknown" do
|
419
|
-
logger.unknown("yo")
|
420
|
-
|
421
|
-
IO.read(logfile).must_match(/^A, #{ts} ANY -- Kitchen: yo$/)
|
422
|
-
end
|
423
|
-
end
|
424
|
-
end
|
425
|
-
end
|
@@ -1,56 +0,0 @@
|
|
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/logging"
|
22
|
-
|
23
|
-
class LoggingDummy
|
24
|
-
include Kitchen::Logging
|
25
|
-
|
26
|
-
attr_reader :logger
|
27
|
-
|
28
|
-
def initialize(logger)
|
29
|
-
@logger = logger
|
30
|
-
end
|
31
|
-
|
32
|
-
class Logger
|
33
|
-
METHODS = [:banner, :debug, :info, :warn, :error, :fatal].freeze
|
34
|
-
|
35
|
-
attr_reader(*(METHODS.map { |m| "#{m}_msg".to_sym }))
|
36
|
-
|
37
|
-
METHODS.each do |meth|
|
38
|
-
define_method(meth) do |*args|
|
39
|
-
instance_variable_set("@#{meth}_msg", args.first)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe Kitchen::Logging do
|
46
|
-
let(:logger) { LoggingDummy::Logger.new }
|
47
|
-
let(:subject) { LoggingDummy.new(logger) }
|
48
|
-
|
49
|
-
LoggingDummy::Logger::METHODS.each do |meth|
|
50
|
-
it "##{meth} calls method on logger" do
|
51
|
-
subject.public_send(meth, "ping")
|
52
|
-
|
53
|
-
logger.public_send("#{meth}_msg").must_equal "ping"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|