beaker 4.38.1 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/release.yml +2 -2
- data/.github/workflows/test.yml +36 -11
- data/.rubocop.yml +75 -0
- data/.rubocop_todo.yml +239 -0
- data/CHANGELOG.md +88 -33
- data/Gemfile +16 -4
- data/HISTORY.md +103 -0
- data/Rakefile +101 -112
- data/acceptance/config/acceptance-options.rb +1 -1
- data/acceptance/config/base/acceptance-options.rb +2 -2
- data/acceptance/config/hypervisor/acceptance-options.rb +2 -2
- data/acceptance/config/subcommands/acceptance-options.rb +2 -2
- data/acceptance/fixtures/module/Gemfile +1 -1
- data/acceptance/fixtures/module/Rakefile +3 -3
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +16 -23
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +1 -2
- data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
- data/acceptance/lib/helpers/test_helper.rb +7 -6
- data/acceptance/pre_suite/subcommands/05_install_ruby.rb +2 -3
- data/acceptance/pre_suite/subcommands/08_install_beaker.rb +1 -2
- data/acceptance/tests/base/dsl/helpers/configuration_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +7 -8
- data/acceptance/tests/base/dsl/helpers/host_helpers/add_system32_hosts_entry_test.rb +0 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +9 -7
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +15 -21
- data/acceptance/tests/base/dsl/helpers/host_helpers/check_for_package_test.rb +0 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +23 -30
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb +0 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +21 -16
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +7 -7
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +30 -38
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +14 -18
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +8 -14
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +7 -11
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +5 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +4 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +8 -8
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +4 -6
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
- data/acceptance/tests/base/dsl/structure_test.rb +9 -21
- data/acceptance/tests/base/host/file_test.rb +8 -8
- data/acceptance/tests/base/host/group_test.rb +2 -3
- data/acceptance/tests/base/host/host_test.rb +69 -66
- data/acceptance/tests/base/host/packages.rb +27 -30
- data/acceptance/tests/base/host/packages_unix.rb +0 -55
- data/acceptance/tests/base/host/user_test.rb +2 -3
- data/acceptance/tests/base/host_prebuilt_steps/ssh_environment_test.rb +1 -2
- data/acceptance/tests/base/test_suite/export.rb +6 -9
- data/acceptance/tests/install/from_file.rb +3 -5
- data/acceptance/tests/load_path_bootstrap.rb +1 -1
- data/acceptance/tests/subcommands/destroy.rb +19 -21
- data/acceptance/tests/subcommands/exec.rb +0 -1
- data/acceptance/tests/subcommands/init.rb +2 -3
- data/acceptance/tests/subcommands/provision.rb +0 -1
- data/beaker.gemspec +10 -14
- data/docs/concepts/argument_processing_and_precedence.md +1 -10
- data/docs/concepts/style_guide.md +1 -1
- data/docs/how_to/debug_beaker_tests.md +13 -13
- data/docs/how_to/hosts/eos.md +2 -12
- data/docs/how_to/install_puppet.md +0 -18
- data/docs/how_to/test_arbitrary_beaker_versions.md +2 -2
- data/docs/how_to/the_beaker_dsl.md +0 -2
- data/lib/beaker/cli.rb +63 -74
- data/lib/beaker/command.rb +22 -30
- data/lib/beaker/command_factory.rb +4 -3
- data/lib/beaker/dsl/assertions.rb +7 -19
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +5 -9
- data/lib/beaker/dsl/helpers/host_helpers.rb +72 -133
- data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
- data/lib/beaker/dsl/helpers/web_helpers.rb +20 -28
- data/lib/beaker/dsl/helpers.rb +2 -4
- data/lib/beaker/dsl/outcomes.rb +17 -19
- data/lib/beaker/dsl/patterns.rb +1 -3
- data/lib/beaker/dsl/roles.rb +18 -21
- data/lib/beaker/dsl/structure.rb +55 -67
- data/lib/beaker/dsl/test_tagging.rb +7 -10
- data/lib/beaker/dsl/wrappers.rb +15 -16
- data/lib/beaker/dsl.rb +2 -3
- data/lib/beaker/host/aix/exec.rb +1 -1
- data/lib/beaker/host/aix/file.rb +0 -1
- data/lib/beaker/host/aix/group.rb +3 -3
- data/lib/beaker/host/aix/user.rb +3 -3
- data/lib/beaker/host/aix.rb +3 -4
- data/lib/beaker/host/cisco.rb +36 -48
- data/lib/beaker/host/eos.rb +4 -30
- data/lib/beaker/host/freebsd/exec.rb +1 -1
- data/lib/beaker/host/freebsd/pkg.rb +3 -3
- data/lib/beaker/host/freebsd.rb +9 -12
- data/lib/beaker/host/mac/exec.rb +5 -5
- data/lib/beaker/host/mac/group.rb +13 -13
- data/lib/beaker/host/mac/pkg.rb +6 -109
- data/lib/beaker/host/mac/user.rb +7 -7
- data/lib/beaker/host/mac.rb +8 -9
- data/lib/beaker/host/pswindows/exec.rb +70 -74
- data/lib/beaker/host/pswindows/file.rb +4 -6
- data/lib/beaker/host/pswindows/group.rb +5 -5
- data/lib/beaker/host/pswindows/pkg.rb +17 -17
- data/lib/beaker/host/pswindows/user.rb +4 -4
- data/lib/beaker/host/pswindows.rb +4 -3
- data/lib/beaker/host/unix/exec.rb +86 -88
- data/lib/beaker/host/unix/file.rb +41 -47
- data/lib/beaker/host/unix/group.rb +3 -3
- data/lib/beaker/host/unix/pkg.rb +158 -421
- data/lib/beaker/host/unix/user.rb +4 -4
- data/lib/beaker/host/unix.rb +18 -20
- data/lib/beaker/host/windows/exec.rb +20 -20
- data/lib/beaker/host/windows/file.rb +5 -5
- data/lib/beaker/host/windows/group.rb +5 -5
- data/lib/beaker/host/windows/pkg.rb +6 -57
- data/lib/beaker/host/windows/user.rb +4 -4
- data/lib/beaker/host/windows.rb +13 -13
- data/lib/beaker/host.rb +82 -139
- data/lib/beaker/host_prebuilt_steps.rb +121 -233
- data/lib/beaker/hypervisor/noop.rb +2 -4
- data/lib/beaker/hypervisor.rb +46 -63
- data/lib/beaker/local_connection.rb +4 -6
- data/lib/beaker/logger.rb +71 -85
- data/lib/beaker/logger_junit.rb +22 -26
- data/lib/beaker/network_manager.rb +40 -43
- data/lib/beaker/options/command_line_parser.rb +12 -23
- data/lib/beaker/options/hosts_file_parser.rb +34 -25
- data/lib/beaker/options/options_file_parser.rb +3 -6
- data/lib/beaker/options/options_hash.rb +3 -10
- data/lib/beaker/options/parser.rb +89 -105
- data/lib/beaker/options/presets.rb +114 -123
- data/lib/beaker/options/subcommand_options_file_parser.rb +3 -6
- data/lib/beaker/options/validator.rb +26 -31
- data/lib/beaker/perf.rb +29 -34
- data/lib/beaker/platform.rb +38 -46
- data/lib/beaker/result.rb +7 -6
- data/lib/beaker/shared/error_handler.rb +8 -10
- data/lib/beaker/shared/fog_credentials.rb +5 -9
- data/lib/beaker/shared/host_manager.rb +40 -46
- data/lib/beaker/shared/options_resolver.rb +3 -7
- data/lib/beaker/shared/repetition.rb +6 -8
- data/lib/beaker/shared/semvar.rb +39 -43
- data/lib/beaker/shared/timed.rb +2 -5
- data/lib/beaker/shared.rb +1 -1
- data/lib/beaker/ssh_connection.rb +46 -55
- data/lib/beaker/subcommand.rb +23 -30
- data/lib/beaker/subcommands/subcommand_util.rb +4 -4
- data/lib/beaker/tasks/quick_start.rb +5 -10
- data/lib/beaker/tasks/rake_task.rb +26 -28
- data/lib/beaker/tasks/test.rb +4 -4
- data/lib/beaker/test_case.rb +15 -27
- data/lib/beaker/test_suite.rb +35 -39
- data/lib/beaker/test_suite_result.rb +52 -57
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +5 -6
- data/spec/beaker/cli_spec.rb +135 -153
- data/spec/beaker/command_spec.rb +64 -58
- data/spec/beaker/dsl/assertions_spec.rb +38 -47
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +114 -135
- data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +30 -36
- data/spec/beaker/dsl/outcomes_spec.rb +15 -14
- data/spec/beaker/dsl/roles_spec.rb +170 -132
- data/spec/beaker/dsl/structure_spec.rb +181 -163
- data/spec/beaker/dsl/test_tagging_spec.rb +94 -95
- data/spec/beaker/dsl/wrappers_spec.rb +39 -40
- data/spec/beaker/host/aix_spec.rb +14 -14
- data/spec/beaker/host/cisco_spec.rb +92 -102
- data/spec/beaker/host/eos_spec.rb +15 -36
- data/spec/beaker/host/freebsd/exec_spec.rb +5 -8
- data/spec/beaker/host/freebsd/pkg_spec.rb +29 -29
- data/spec/beaker/host/mac/exec_spec.rb +4 -5
- data/spec/beaker/host/mac/group_spec.rb +47 -56
- data/spec/beaker/host/mac/user_spec.rb +53 -62
- data/spec/beaker/host/pswindows/exec_spec.rb +36 -35
- data/spec/beaker/host/pswindows/file_spec.rb +21 -18
- data/spec/beaker/host/pswindows/user_spec.rb +17 -23
- data/spec/beaker/host/pswindows_spec.rb +14 -14
- data/spec/beaker/host/unix/exec_spec.rb +87 -92
- data/spec/beaker/host/unix/file_spec.rb +76 -82
- data/spec/beaker/host/unix/pkg_spec.rb +165 -407
- data/spec/beaker/host/unix_spec.rb +11 -207
- data/spec/beaker/host/windows/exec_spec.rb +32 -34
- data/spec/beaker/host/windows/file_spec.rb +22 -23
- data/spec/beaker/host/windows/group_spec.rb +17 -19
- data/spec/beaker/host/windows/pkg_spec.rb +10 -13
- data/spec/beaker/host/windows/user_spec.rb +17 -23
- data/spec/beaker/host/windows_spec.rb +39 -39
- data/spec/beaker/host_prebuilt_steps_spec.rb +193 -341
- data/spec/beaker/host_spec.rb +241 -312
- data/spec/beaker/hypervisor/hypervisor_spec.rb +38 -63
- data/spec/beaker/localhost_connection_spec.rb +14 -13
- data/spec/beaker/logger_junit_spec.rb +22 -34
- data/spec/beaker/logger_spec.rb +174 -155
- data/spec/beaker/network_manager_spec.rb +27 -27
- data/spec/beaker/options/command_line_parser_spec.rb +20 -23
- data/spec/beaker/options/data/hosts_preserved.yml +395 -0
- data/spec/beaker/options/hosts_file_parser_spec.rb +36 -31
- data/spec/beaker/options/options_file_parser_spec.rb +4 -7
- data/spec/beaker/options/options_hash_spec.rb +7 -9
- data/spec/beaker/options/parser_spec.rb +187 -187
- data/spec/beaker/options/presets_spec.rb +8 -10
- data/spec/beaker/options/subcommand_options_parser_spec.rb +15 -15
- data/spec/beaker/options/validator_spec.rb +27 -28
- data/spec/beaker/perf_spec.rb +32 -34
- data/spec/beaker/platform_spec.rb +27 -37
- data/spec/beaker/shared/error_handler_spec.rb +8 -17
- data/spec/beaker/shared/fog_credentials_spec.rb +30 -30
- data/spec/beaker/shared/host_manager_spec.rb +55 -89
- data/spec/beaker/shared/options_resolver_spec.rb +9 -12
- data/spec/beaker/shared/repetition_spec.rb +24 -31
- data/spec/beaker/shared/semvar_spec.rb +21 -26
- data/spec/beaker/ssh_connection_spec.rb +85 -90
- data/spec/beaker/subcommand/subcommand_util_spec.rb +40 -37
- data/spec/beaker/subcommand_spec.rb +89 -89
- data/spec/beaker/test_case_spec.rb +33 -62
- data/spec/beaker/test_suite_spec.rb +153 -160
- data/spec/helpers.rb +48 -53
- data/spec/matchers.rb +9 -8
- data/spec/mocks.rb +6 -11
- data/spec/spec_helper.rb +0 -4
- metadata +60 -85
- data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +0 -142
- data/acceptance/tests/base/external_resources_test.rb +0 -31
- data/spec/beaker/host/mac_spec.rb +0 -113
- data/spec/mock_fission.rb +0 -60
- data/spec/mock_vsphere.rb +0 -314
- data/spec/mock_vsphere_helper.rb +0 -183
data/spec/beaker/logger_spec.rb
CHANGED
@@ -1,52 +1,51 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
require 'spec_helper'
|
3
2
|
|
4
3
|
module Beaker
|
5
4
|
describe Logger do
|
6
5
|
let(:my_io) { StringIO.new }
|
7
|
-
let(:logger) {
|
8
|
-
let(:basic_logger)
|
9
|
-
let(:test_dir)
|
6
|
+
let(:logger) { described_class.new(my_io, :quiet => true) }
|
7
|
+
let(:basic_logger) { described_class.new(:quiet => true) }
|
8
|
+
let(:test_dir) { 'tmp/tests' }
|
10
9
|
let(:dummy_prefix) { 'dummy' }
|
11
10
|
|
12
|
-
|
11
|
+
describe '#convert' do
|
13
12
|
let(:valid_utf8) { "/etc/puppet/modules\n├── jimmy-appleseed (\e[0;36mv1.1.0\e[0m)\n├── jimmy-crakorn (\e[0;36mv0.4.0\e[0m)\n└── jimmy-thelock (\e[0;36mv1.0.0\e[0m)\n" }
|
14
|
-
let(:invalid_utf8) {"/etc/puppet/modules\n├── jimmy-appleseed (\e[0;36mv1.1.0\e[0m)\n├── jimmy-crakorn (\e[0;36mv0.4.0\e[0m)\n└── jimmy-thelock (\e[0;36mv1.0.0\e[0m)\xAD\n"}
|
13
|
+
let(:invalid_utf8) { "/etc/puppet/modules\n├── jimmy-appleseed (\e[0;36mv1.1.0\e[0m)\n├── jimmy-crakorn (\e[0;36mv0.4.0\e[0m)\n└── jimmy-thelock (\e[0;36mv1.0.0\e[0m)\xAD\n" }
|
15
14
|
|
16
15
|
it 'preserves valid utf-8 strings' do
|
17
|
-
expect(
|
16
|
+
expect(logger.convert(valid_utf8)).to be === valid_utf8
|
18
17
|
end
|
18
|
+
|
19
19
|
it 'strips out invalid utf-8 characters' do
|
20
|
-
expect(
|
20
|
+
expect(logger.convert(invalid_utf8)).to be === valid_utf8
|
21
21
|
end
|
22
|
+
|
22
23
|
it 'supports frozen strings' do
|
23
24
|
valid_utf8.freeze
|
24
|
-
expect(
|
25
|
+
expect(logger.convert(valid_utf8)).to be === valid_utf8
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
|
-
|
29
|
-
|
29
|
+
describe '#generate_dated_log_folder' do
|
30
30
|
it 'generates path for a given timestamp' do
|
31
31
|
input_time = Time.new(2014, 6, 2, 16, 31, 22, '-07:00')
|
32
|
-
expect(
|
32
|
+
expect(described_class.generate_dated_log_folder(test_dir, dummy_prefix, input_time)).to be === File.join(test_dir, dummy_prefix, '2014-06-02_16_31_22')
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'generates directory for a given timestamp' do
|
36
36
|
input_time = Time.new(2011, 6, 10, 13, 7, 55, '-09:00')
|
37
|
-
expect(
|
37
|
+
expect(File).to be_directory described_class.generate_dated_log_folder(test_dir, dummy_prefix, input_time)
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'generates nested directories if given as a log_prefix' do
|
41
41
|
input_time = Time.new(2011, 6, 10, 13, 7, 55, '-09:00')
|
42
42
|
prefix = 'a/man/a/plan/a/canal/panama'
|
43
|
-
expect(
|
43
|
+
expect(File).to be_directory described_class.generate_dated_log_folder(test_dir, prefix, input_time)
|
44
44
|
end
|
45
|
-
|
46
45
|
end
|
47
46
|
|
48
|
-
|
49
|
-
around
|
47
|
+
describe '#prefix_log_line' do
|
48
|
+
around do |example|
|
50
49
|
logger.line_prefix = ''
|
51
50
|
begin
|
52
51
|
example.run
|
@@ -57,7 +56,7 @@ module Beaker
|
|
57
56
|
|
58
57
|
def prefix_log_line_test_compare_helper(in_test, out_answer)
|
59
58
|
logger.with_indent do
|
60
|
-
expect(
|
59
|
+
expect(logger.prefix_log_line(in_test)).to be === out_answer
|
61
60
|
end
|
62
61
|
end
|
63
62
|
|
@@ -91,7 +90,7 @@ module Beaker
|
|
91
90
|
logger.with_indent do
|
92
91
|
logger.with_indent do
|
93
92
|
logger.with_indent do
|
94
|
-
expect(
|
93
|
+
expect(logger.prefix_log_line(line_arg)).to be === answer
|
95
94
|
end
|
96
95
|
end
|
97
96
|
end
|
@@ -99,7 +98,7 @@ module Beaker
|
|
99
98
|
end
|
100
99
|
|
101
100
|
context 'when indenting' do
|
102
|
-
around
|
101
|
+
around do |example|
|
103
102
|
logger.line_prefix = ''
|
104
103
|
begin
|
105
104
|
example.run
|
@@ -110,30 +109,30 @@ module Beaker
|
|
110
109
|
|
111
110
|
it 'steps in correctly (simple case)' do
|
112
111
|
logger.with_indent do
|
113
|
-
expect(
|
112
|
+
expect(logger.line_prefix).to be === ' '
|
114
113
|
end
|
115
114
|
end
|
116
115
|
|
117
|
-
it 'sets length correctly in mixed scenario
|
116
|
+
it 'sets length correctly in mixed scenario' do
|
118
117
|
logger.with_indent do
|
119
118
|
logger.with_indent {}
|
120
119
|
logger.with_indent do
|
121
120
|
logger.with_indent {}
|
122
|
-
expect(
|
121
|
+
expect(logger.line_prefix).to be === ' '
|
123
122
|
end
|
124
123
|
end
|
125
124
|
end
|
126
125
|
|
127
126
|
it 'can handle arbitrary strings as prefixes' do
|
128
127
|
logger.line_prefix = 'Some string:'
|
129
|
-
expect(
|
128
|
+
expect(logger.line_prefix).to be === 'Some string:'
|
130
129
|
end
|
131
130
|
|
132
131
|
it 'can handle stepping in with arbitrary strings' do
|
133
132
|
logger.line_prefix = 'Some string:'
|
134
133
|
logger.with_indent do
|
135
134
|
logger.with_indent do
|
136
|
-
expect(
|
135
|
+
expect(logger.line_prefix).to be === 'Some string: '
|
137
136
|
end
|
138
137
|
end
|
139
138
|
end
|
@@ -141,7 +140,7 @@ module Beaker
|
|
141
140
|
it 'can handle stepping in and out with arbitrary strings' do
|
142
141
|
logger.line_prefix = 'Some string:'
|
143
142
|
10.times { logger.with_indent {} }
|
144
|
-
expect(
|
143
|
+
expect(logger.line_prefix).to be === 'Some string:'
|
145
144
|
end
|
146
145
|
|
147
146
|
it 'restores the original prefix if an argument is raised' do
|
@@ -157,93 +156,96 @@ module Beaker
|
|
157
156
|
|
158
157
|
context 'new' do
|
159
158
|
it 'does not duplicate STDOUT when directly passed to it' do
|
160
|
-
stdout_logger =
|
161
|
-
expect(
|
159
|
+
stdout_logger = described_class.new STDOUT
|
160
|
+
expect(stdout_logger.destinations.size).to be === 1
|
162
161
|
end
|
163
162
|
|
164
163
|
context 'default for' do
|
165
|
-
|
166
|
-
|
167
|
-
|
164
|
+
it do
|
165
|
+
expect(subject).to have_attributes(
|
166
|
+
destinations: include(STDOUT),
|
167
|
+
color: be_nil,
|
168
|
+
log_level: :verbose,
|
169
|
+
)
|
170
|
+
end
|
168
171
|
end
|
169
172
|
|
170
173
|
context 'log_colors' do
|
171
|
-
original_build_number = ENV
|
174
|
+
original_build_number = ENV.fetch('BUILD_NUMBER', nil)
|
172
175
|
|
173
|
-
before
|
176
|
+
before do
|
174
177
|
ENV['BUILD_NUMBER'] = nil
|
175
178
|
end
|
176
179
|
|
177
|
-
after
|
180
|
+
after do
|
178
181
|
ENV['BUILD_NUMER'] = original_build_number
|
179
182
|
end
|
180
183
|
|
181
|
-
|
182
|
-
it 'should have the default log_colors' do
|
184
|
+
it 'has the default log_colors' do
|
183
185
|
expect(logger.log_colors).to be == {
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
186
|
+
:error => Beaker::Logger::RED,
|
187
|
+
:warn => Beaker::Logger::BRIGHT_RED,
|
188
|
+
:success => Beaker::Logger::MAGENTA,
|
189
|
+
:notify => Beaker::Logger::BLUE,
|
190
|
+
:info => Beaker::Logger::GREEN,
|
191
|
+
:debug => Beaker::Logger::WHITE,
|
192
|
+
:trace => Beaker::Logger::BRIGHT_YELLOW,
|
193
|
+
:perf => Beaker::Logger::BRIGHT_MAGENTA,
|
194
|
+
:host => Beaker::Logger::YELLOW,
|
193
195
|
}
|
194
196
|
end
|
195
197
|
|
196
198
|
context 'when passing in log_color options' do
|
197
|
-
let(:log_colors)
|
199
|
+
let(:log_colors) do
|
198
200
|
{
|
199
|
-
|
201
|
+
:error => "\e[00;30m",
|
200
202
|
}
|
201
|
-
|
203
|
+
end
|
202
204
|
|
203
|
-
let(:logger)
|
205
|
+
let(:logger) { described_class.new(my_io, :quiet => true, :log_colors => log_colors) }
|
204
206
|
|
205
|
-
it '
|
207
|
+
it 'overrides the specified log colors' do
|
206
208
|
expect(logger.log_colors[:error]).to be == Beaker::Logger::BLACK
|
207
209
|
end
|
208
210
|
|
209
|
-
it '
|
211
|
+
it 'leaves other colors as the default' do
|
210
212
|
expect(logger.log_colors[:warn]).to be == Beaker::Logger::BRIGHT_RED
|
211
213
|
end
|
212
214
|
end
|
213
215
|
|
214
216
|
context 'with CI detected' do
|
215
|
-
before
|
217
|
+
before do
|
216
218
|
ENV['BUILD_NUMBER'] = 'bob'
|
217
219
|
end
|
218
220
|
|
219
221
|
context 'when using the default log colors' do
|
220
|
-
it '
|
222
|
+
it 'overrides notify with NORMAL' do
|
221
223
|
expect(logger.log_colors[:notify]).to be == Beaker::Logger::NORMAL
|
222
224
|
end
|
223
225
|
|
224
|
-
it '
|
226
|
+
it 'overrides info with NORMAL' do
|
225
227
|
expect(logger.log_colors[:info]).to be == Beaker::Logger::NORMAL
|
226
228
|
end
|
227
229
|
end
|
228
230
|
|
229
231
|
context 'when overriding default log colors' do
|
230
|
-
let(:log_colors)
|
232
|
+
let(:log_colors) do
|
231
233
|
{
|
232
|
-
|
234
|
+
:error => "\e[00;30m",
|
233
235
|
}
|
234
|
-
|
236
|
+
end
|
235
237
|
|
236
|
-
let(:logger)
|
238
|
+
let(:logger) { described_class.new(my_io, :quiet => true, :log_colors => log_colors) }
|
237
239
|
|
238
|
-
it '
|
240
|
+
it 'overrides the specified log colors' do
|
239
241
|
expect(logger.log_colors[:error]).to be == Beaker::Logger::BLACK
|
240
242
|
end
|
241
243
|
|
242
|
-
it '
|
244
|
+
it 'does not override notify with NORMAL' do
|
243
245
|
expect(logger.log_colors[:notify]).not_to be == Beaker::Logger::NORMAL
|
244
246
|
end
|
245
247
|
|
246
|
-
it '
|
248
|
+
it 'does not override info with NORMAL' do
|
247
249
|
expect(logger.log_colors[:notify]).not_to be == Beaker::Logger::NORMAL
|
248
250
|
end
|
249
251
|
end
|
@@ -254,10 +256,10 @@ module Beaker
|
|
254
256
|
context 'it can' do
|
255
257
|
it 'open/create a file when a string is given to add_destination' do
|
256
258
|
logger.add_destination 'my_tmp_file'
|
257
|
-
expect(
|
259
|
+
expect(File).to exist('my_tmp_file')
|
258
260
|
|
259
|
-
io = logger.destinations.
|
260
|
-
expect(
|
261
|
+
io = logger.destinations.find { |d| d.respond_to? :path }
|
262
|
+
expect(io.path).to match(/my_tmp_file/)
|
261
263
|
end
|
262
264
|
|
263
265
|
it 'remove destinations with the remove_destinations method' do
|
@@ -266,174 +268,191 @@ module Beaker
|
|
266
268
|
logger.remove_destination my_io
|
267
269
|
logger.remove_destination 'my_file'
|
268
270
|
|
269
|
-
expect(
|
271
|
+
expect(logger.destinations).to be_empty
|
270
272
|
end
|
271
273
|
|
272
274
|
it 'strip colors from arrays of input' do
|
273
|
-
stripped = logger.strip_colors_from [
|
274
|
-
expect(
|
275
|
+
stripped = logger.strip_colors_from ["\e[00;30m text! \e[00;00m"]
|
276
|
+
expect(stripped).to be === [' text! ']
|
275
277
|
end
|
276
278
|
|
277
279
|
it 'colors strings if @color is set' do
|
278
|
-
colorized_logger =
|
280
|
+
colorized_logger = described_class.new my_io, :color => true, :quiet => true
|
279
281
|
|
280
|
-
expect(
|
281
|
-
expect(
|
282
|
-
expect(
|
282
|
+
expect(my_io).to receive(:print).with "\e[00;30m"
|
283
|
+
expect(my_io).to receive(:print)
|
284
|
+
expect(my_io).to receive(:puts).with 'my string'
|
283
285
|
|
284
286
|
colorized_logger.optionally_color "\e[00;30m", 'my string'
|
285
287
|
end
|
286
288
|
|
287
289
|
context 'at trace log_level' do
|
288
|
-
subject(
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
290
|
+
subject(:trace_logger) do
|
291
|
+
described_class.new(my_io,
|
292
|
+
:log_level => 'trace',
|
293
|
+
:quiet => true,
|
294
|
+
:color => true)
|
295
|
+
end
|
293
296
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
+
it do
|
298
|
+
expect(subject).to have_attributes(
|
299
|
+
:is_debug? => be_truthy,
|
300
|
+
:is_trace? => be_truthy,
|
301
|
+
:is_warn? => be_truthy,
|
302
|
+
)
|
303
|
+
end
|
297
304
|
|
298
305
|
context 'but print' do
|
299
306
|
before do
|
300
|
-
allow(
|
301
|
-
expect(
|
307
|
+
allow(my_io).to receive :puts
|
308
|
+
expect(my_io).to receive(:print).at_least :twice
|
302
309
|
end
|
303
310
|
|
304
|
-
it(
|
305
|
-
it(
|
306
|
-
it(
|
307
|
-
it(
|
308
|
-
it(
|
309
|
-
it(
|
311
|
+
it('warnings') { trace_logger.warn 'IMA WARNING!' }
|
312
|
+
it('successes') { trace_logger.success 'SUCCESS!' }
|
313
|
+
it('errors') { trace_logger.error 'ERROR!' }
|
314
|
+
it('host_output') { trace_logger.host_output 'ERROR!' }
|
315
|
+
it('debugs') { trace_logger.debug 'DEBUGGING!' }
|
316
|
+
it('traces') { trace_logger.trace 'TRACING!' }
|
310
317
|
end
|
311
318
|
end
|
312
319
|
|
313
320
|
context 'at verbose log_level' do
|
314
|
-
subject(
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
321
|
+
subject(:verbose_logger) do
|
322
|
+
described_class.new(my_io,
|
323
|
+
:log_level => 'verbose',
|
324
|
+
:quiet => true,
|
325
|
+
:color => true)
|
326
|
+
end
|
319
327
|
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
328
|
+
it do
|
329
|
+
expect(subject).to have_attributes(
|
330
|
+
:is_trace? => be_falsy,
|
331
|
+
:is_debug? => be_falsy,
|
332
|
+
:is_verbose? => be_truthy,
|
333
|
+
:is_warn? => be_truthy,
|
334
|
+
)
|
335
|
+
end
|
324
336
|
|
325
337
|
context 'but print' do
|
326
338
|
before do
|
327
|
-
allow(
|
328
|
-
expect(
|
339
|
+
allow(my_io).to receive :puts
|
340
|
+
expect(my_io).to receive(:print).at_least :twice
|
329
341
|
end
|
330
342
|
|
331
|
-
it(
|
332
|
-
it(
|
333
|
-
it(
|
334
|
-
it(
|
335
|
-
it(
|
343
|
+
it('warnings') { verbose_logger.warn 'IMA WARNING!' }
|
344
|
+
it('successes') { verbose_logger.success 'SUCCESS!' }
|
345
|
+
it('errors') { verbose_logger.error 'ERROR!' }
|
346
|
+
it('host_output') { verbose_logger.host_output 'ERROR!' }
|
347
|
+
it('debugs') { verbose_logger.debug 'NOT DEBUGGING!' }
|
336
348
|
end
|
337
349
|
end
|
338
350
|
|
339
351
|
context 'at debug log_level' do
|
340
|
-
subject(
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
352
|
+
subject(:debug_logger) do
|
353
|
+
described_class.new(my_io,
|
354
|
+
:log_level => 'debug',
|
355
|
+
:quiet => true,
|
356
|
+
:color => true)
|
357
|
+
end
|
345
358
|
|
346
|
-
|
347
|
-
|
348
|
-
|
359
|
+
it do
|
360
|
+
expect(subject).to have_attributes(
|
361
|
+
:is_trace? => be_falsy,
|
362
|
+
:is_debug? => be_truthy,
|
363
|
+
:is_warn? => be_truthy,
|
364
|
+
)
|
365
|
+
end
|
349
366
|
|
350
367
|
context 'successfully print' do
|
351
368
|
before do
|
352
|
-
allow(
|
353
|
-
expect(
|
369
|
+
allow(my_io).to receive :puts
|
370
|
+
expect(my_io).to receive(:print).at_least :twice
|
354
371
|
end
|
355
372
|
|
356
|
-
it(
|
357
|
-
it(
|
358
|
-
it(
|
359
|
-
it(
|
360
|
-
it(
|
373
|
+
it('warnings') { debug_logger.warn 'IMA WARNING!' }
|
374
|
+
it('debugs') { debug_logger.debug 'IMA DEBUGGING!' }
|
375
|
+
it('successes') { debug_logger.success 'SUCCESS!' }
|
376
|
+
it('errors') { debug_logger.error 'ERROR!' }
|
377
|
+
it('host_output') { debug_logger.host_output 'ERROR!' }
|
361
378
|
end
|
362
379
|
end
|
363
380
|
|
364
381
|
context 'at info log_level' do
|
365
|
-
subject(
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
its( :is_debug? ) { should be_falsy }
|
372
|
-
its( :is_trace? ) { should be_falsy }
|
382
|
+
subject(:info_logger) do
|
383
|
+
described_class.new(my_io,
|
384
|
+
:log_level => :info,
|
385
|
+
:quiet => true,
|
386
|
+
:color => true)
|
387
|
+
end
|
373
388
|
|
389
|
+
it do
|
390
|
+
expect(subject).to have_attributes(
|
391
|
+
:is_debug? => be_falsy,
|
392
|
+
:is_trace? => be_falsy,
|
393
|
+
)
|
394
|
+
end
|
374
395
|
|
375
396
|
context 'skip' do
|
376
397
|
before do
|
377
|
-
expect(
|
378
|
-
expect(
|
398
|
+
expect(my_io).not_to receive :puts
|
399
|
+
expect(my_io).not_to receive :print
|
379
400
|
end
|
380
401
|
|
381
|
-
it(
|
382
|
-
it(
|
402
|
+
it('debugs') { info_logger.debug 'NOT DEBUGGING!' }
|
403
|
+
it('traces') { info_logger.debug 'NOT TRACING!' }
|
383
404
|
end
|
384
405
|
|
385
|
-
|
386
406
|
context 'but print' do
|
387
407
|
before do
|
388
|
-
expect(
|
389
|
-
expect(
|
408
|
+
expect(my_io).to receive :puts
|
409
|
+
expect(my_io).to receive(:print).twice
|
390
410
|
end
|
391
411
|
|
392
|
-
it(
|
393
|
-
it(
|
394
|
-
it(
|
412
|
+
it('successes') { info_logger.success 'SUCCESS!' }
|
413
|
+
it('notifications') { info_logger.notify 'NOTFIY!' }
|
414
|
+
it('errors') { info_logger.error 'ERROR!' }
|
395
415
|
end
|
396
416
|
end
|
397
417
|
|
398
418
|
context 'SUT output logging' do
|
399
|
-
|
400
419
|
context 'host output logging' do
|
401
|
-
subject(
|
402
|
-
|
403
|
-
|
404
|
-
|
420
|
+
subject(:host_output) do
|
421
|
+
described_class.new(my_io,
|
422
|
+
:log_level => :verbose,
|
423
|
+
:quiet => true,
|
424
|
+
:color => true)
|
425
|
+
end
|
405
426
|
|
406
|
-
it '
|
427
|
+
it 'outputs GREY when @color is set to true' do
|
407
428
|
colorized_logger = host_output
|
408
429
|
|
409
|
-
expect(
|
410
|
-
expect(
|
411
|
-
expect(
|
430
|
+
expect(my_io).to receive(:print).with "\e[01;30m"
|
431
|
+
expect(my_io).to receive(:print)
|
432
|
+
expect(my_io).to receive(:puts).with 'my string'
|
412
433
|
|
413
434
|
colorized_logger.optionally_color "\e[01;30m", 'my string'
|
414
435
|
end
|
415
|
-
|
416
436
|
end
|
417
437
|
|
418
438
|
context 'color host output' do
|
419
|
-
subject(
|
420
|
-
|
421
|
-
|
422
|
-
|
439
|
+
subject(:color_host_output) do
|
440
|
+
described_class.new(my_io,
|
441
|
+
:log_level => :verbose,
|
442
|
+
:quiet => true,
|
443
|
+
:color => true)
|
444
|
+
end
|
423
445
|
|
424
446
|
it 'colors host_output' do
|
425
447
|
colorized_logger = color_host_output
|
426
448
|
|
427
|
-
expect(
|
428
|
-
expect(
|
449
|
+
expect(my_io).to receive(:print).with ""
|
450
|
+
expect(my_io).to receive(:puts).with 'my string'
|
429
451
|
|
430
452
|
colorized_logger.optionally_color "", 'my string'
|
431
453
|
end
|
432
|
-
|
433
454
|
end
|
434
455
|
end
|
435
|
-
|
436
456
|
end
|
437
|
-
|
438
457
|
end
|
439
458
|
end
|