beaker 4.41.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/release.yml +2 -2
- data/.github/workflows/test.yml +26 -13
- data/.rubocop.yml +23 -10
- data/.rubocop_todo.yml +34 -10
- data/CHANGELOG.md +16 -52
- data/Gemfile +12 -7
- data/HISTORY.md +605 -0
- data/Rakefile +99 -111
- 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/Rakefile +1 -1
- data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -12
- data/acceptance/fixtures/module/spec/classes/init_spec.rb +0 -1
- data/acceptance/fixtures/module/spec/spec_helper_acceptance.rb +3 -5
- data/acceptance/lib/helpers/test_helper.rb +6 -5
- 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 +1 -2
- 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 +3 -1
- data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +9 -9
- 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 +19 -26
- data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +2 -2
- 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 +18 -13
- data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +22 -27
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +12 -16
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +3 -3
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +4 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +3 -4
- data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +5 -5
- data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +3 -5
- data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +14 -17
- data/acceptance/tests/base/dsl/structure_test.rb +5 -11
- data/acceptance/tests/base/host/file_test.rb +2 -2
- data/acceptance/tests/base/host/group_test.rb +0 -1
- data/acceptance/tests/base/host/host_test.rb +66 -63
- data/acceptance/tests/base/host/packages.rb +1 -2
- data/acceptance/tests/base/host/packages_unix.rb +0 -55
- data/acceptance/tests/base/host/user_test.rb +0 -1
- 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 +2 -4
- 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 +4 -7
- data/docs/concepts/argument_processing_and_precedence.md +1 -10
- data/docs/how_to/debug_beaker_tests.md +12 -12
- data/docs/how_to/hosts/eos.md +2 -12
- data/docs/how_to/install_puppet.md +0 -18
- data/docs/how_to/the_beaker_dsl.md +0 -2
- data/lib/beaker/cli.rb +59 -68
- data/lib/beaker/command.rb +20 -28
- data/lib/beaker/command_factory.rb +3 -2
- data/lib/beaker/dsl/assertions.rb +6 -18
- data/lib/beaker/dsl/helpers/hocon_helpers.rb +3 -7
- data/lib/beaker/dsl/helpers/host_helpers.rb +62 -123
- data/lib/beaker/dsl/helpers/test_helpers.rb +3 -5
- data/lib/beaker/dsl/helpers/web_helpers.rb +19 -39
- data/lib/beaker/dsl/helpers.rb +2 -4
- data/lib/beaker/dsl/outcomes.rb +13 -15
- data/lib/beaker/dsl/patterns.rb +1 -3
- data/lib/beaker/dsl/roles.rb +17 -20
- data/lib/beaker/dsl/structure.rb +53 -65
- 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 +1 -1
- data/lib/beaker/host/aix/user.rb +1 -1
- data/lib/beaker/host/aix.rb +3 -4
- data/lib/beaker/host/cisco.rb +27 -39
- 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 +4 -4
- data/lib/beaker/host/mac/group.rb +7 -7
- data/lib/beaker/host/mac/pkg.rb +3 -106
- data/lib/beaker/host/mac/user.rb +2 -2
- data/lib/beaker/host/mac.rb +8 -9
- data/lib/beaker/host/pswindows/exec.rb +66 -70
- data/lib/beaker/host/pswindows/file.rb +3 -5
- data/lib/beaker/host/pswindows/group.rb +3 -3
- data/lib/beaker/host/pswindows/pkg.rb +12 -12
- data/lib/beaker/host/pswindows/user.rb +3 -3
- data/lib/beaker/host/pswindows.rb +4 -3
- data/lib/beaker/host/unix/exec.rb +81 -83
- data/lib/beaker/host/unix/file.rb +40 -45
- data/lib/beaker/host/unix/group.rb +1 -1
- data/lib/beaker/host/unix/pkg.rb +138 -401
- data/lib/beaker/host/unix/user.rb +2 -2
- data/lib/beaker/host/unix.rb +8 -11
- data/lib/beaker/host/windows/exec.rb +17 -17
- data/lib/beaker/host/windows/file.rb +3 -3
- data/lib/beaker/host/windows/group.rb +3 -3
- data/lib/beaker/host/windows/pkg.rb +3 -54
- data/lib/beaker/host/windows/user.rb +3 -3
- data/lib/beaker/host/windows.rb +12 -12
- data/lib/beaker/host.rb +76 -133
- data/lib/beaker/host_prebuilt_steps.rb +88 -196
- data/lib/beaker/hypervisor/noop.rb +2 -4
- data/lib/beaker/hypervisor.rb +44 -61
- data/lib/beaker/local_connection.rb +2 -4
- data/lib/beaker/logger.rb +68 -76
- data/lib/beaker/logger_junit.rb +21 -25
- data/lib/beaker/network_manager.rb +39 -42
- data/lib/beaker/options/command_line_parser.rb +12 -23
- data/lib/beaker/options/hosts_file_parser.rb +16 -25
- data/lib/beaker/options/options_file_parser.rb +3 -6
- data/lib/beaker/options/options_hash.rb +2 -7
- data/lib/beaker/options/parser.rb +86 -102
- 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 +25 -30
- data/lib/beaker/platform.rb +26 -37
- 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 +36 -41
- data/lib/beaker/shared/options_resolver.rb +3 -7
- data/lib/beaker/shared/repetition.rb +2 -4
- data/lib/beaker/shared/semvar.rb +37 -41
- data/lib/beaker/shared/timed.rb +0 -3
- data/lib/beaker/shared.rb +1 -1
- data/lib/beaker/ssh_connection.rb +38 -47
- data/lib/beaker/subcommand.rb +17 -24
- data/lib/beaker/subcommands/subcommand_util.rb +4 -4
- data/lib/beaker/tasks/quick_start.rb +4 -9
- data/lib/beaker/tasks/rake_task.rb +25 -27
- data/lib/beaker/tasks/test.rb +4 -4
- data/lib/beaker/test_case.rb +16 -28
- data/lib/beaker/test_suite.rb +35 -39
- data/lib/beaker/test_suite_result.rb +45 -47
- data/lib/beaker/version.rb +1 -1
- data/lib/beaker.rb +6 -7
- data/spec/beaker/cli_spec.rb +121 -142
- data/spec/beaker/command_spec.rb +55 -59
- data/spec/beaker/dsl/assertions_spec.rb +36 -36
- data/spec/beaker/dsl/helpers/host_helpers_spec.rb +110 -131
- data/spec/beaker/dsl/helpers/test_helpers_spec.rb +9 -10
- data/spec/beaker/dsl/helpers/web_helpers_spec.rb +22 -31
- data/spec/beaker/dsl/outcomes_spec.rb +14 -14
- data/spec/beaker/dsl/roles_spec.rb +125 -130
- data/spec/beaker/dsl/structure_spec.rb +172 -161
- data/spec/beaker/dsl/test_tagging_spec.rb +89 -90
- data/spec/beaker/dsl/wrappers_spec.rb +32 -33
- data/spec/beaker/host/aix_spec.rb +14 -14
- data/spec/beaker/host/cisco_spec.rb +84 -94
- data/spec/beaker/host/eos_spec.rb +15 -36
- data/spec/beaker/host/freebsd/exec_spec.rb +3 -6
- data/spec/beaker/host/freebsd/pkg_spec.rb +24 -27
- data/spec/beaker/host/mac/exec_spec.rb +2 -3
- data/spec/beaker/host/mac/group_spec.rb +48 -57
- data/spec/beaker/host/mac/user_spec.rb +54 -63
- data/spec/beaker/host/pswindows/exec_spec.rb +30 -32
- data/spec/beaker/host/pswindows/file_spec.rb +16 -16
- data/spec/beaker/host/pswindows/user_spec.rb +17 -23
- data/spec/beaker/host/pswindows_spec.rb +13 -13
- data/spec/beaker/host/unix/exec_spec.rb +75 -80
- data/spec/beaker/host/unix/file_spec.rb +66 -71
- data/spec/beaker/host/unix/pkg_spec.rb +150 -411
- data/spec/beaker/host/unix_spec.rb +11 -207
- data/spec/beaker/host/windows/exec_spec.rb +30 -32
- data/spec/beaker/host/windows/file_spec.rb +18 -19
- data/spec/beaker/host/windows/group_spec.rb +10 -12
- data/spec/beaker/host/windows/pkg_spec.rb +6 -9
- 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 +168 -349
- data/spec/beaker/host_spec.rb +204 -284
- data/spec/beaker/hypervisor/hypervisor_spec.rb +36 -61
- data/spec/beaker/localhost_connection_spec.rb +10 -11
- data/spec/beaker/logger_junit_spec.rb +19 -30
- data/spec/beaker/logger_spec.rb +153 -136
- data/spec/beaker/network_manager_spec.rb +23 -23
- data/spec/beaker/options/command_line_parser_spec.rb +20 -23
- data/spec/beaker/options/hosts_file_parser_spec.rb +30 -32
- data/spec/beaker/options/options_file_parser_spec.rb +4 -7
- data/spec/beaker/options/options_hash_spec.rb +4 -6
- data/spec/beaker/options/parser_spec.rb +167 -167
- data/spec/beaker/options/presets_spec.rb +7 -9
- data/spec/beaker/options/subcommand_options_parser_spec.rb +13 -14
- data/spec/beaker/options/validator_spec.rb +10 -11
- data/spec/beaker/perf_spec.rb +18 -21
- data/spec/beaker/platform_spec.rb +25 -50
- data/spec/beaker/shared/error_handler_spec.rb +7 -16
- data/spec/beaker/shared/fog_credentials_spec.rb +29 -29
- data/spec/beaker/shared/host_manager_spec.rb +50 -84
- data/spec/beaker/shared/options_resolver_spec.rb +9 -12
- data/spec/beaker/shared/repetition_spec.rb +17 -24
- data/spec/beaker/shared/semvar_spec.rb +21 -26
- data/spec/beaker/ssh_connection_spec.rb +76 -83
- data/spec/beaker/subcommand/subcommand_util_spec.rb +31 -33
- data/spec/beaker/subcommand_spec.rb +75 -77
- data/spec/beaker/test_case_spec.rb +25 -50
- data/spec/beaker/test_suite_spec.rb +147 -154
- data/spec/helpers.rb +39 -45
- data/spec/matchers.rb +8 -7
- data/spec/mocks.rb +1 -6
- data/spec/spec_helper.rb +0 -1
- metadata +8 -24
- 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
|
@@ -3,9 +3,9 @@ require 'spec_helper'
|
|
|
3
3
|
module Beaker
|
|
4
4
|
SubcommandUtil = Beaker::Subcommands::SubcommandUtil
|
|
5
5
|
describe Subcommand do
|
|
6
|
-
let(
|
|
6
|
+
let(:subcommand) do
|
|
7
7
|
described_class.new
|
|
8
|
-
|
|
8
|
+
end
|
|
9
9
|
|
|
10
10
|
describe '#initialize' do
|
|
11
11
|
it 'creates a cli object' do
|
|
@@ -32,51 +32,51 @@ module Beaker
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
context 'ensure that beaker options can be passed through' do
|
|
35
|
+
let(:beaker_options_list) do
|
|
36
|
+
%w[
|
|
37
|
+
options-file
|
|
38
|
+
helper
|
|
39
|
+
load-path
|
|
40
|
+
tests
|
|
41
|
+
pre-suite
|
|
42
|
+
post-suite
|
|
43
|
+
pre-cleanup
|
|
44
|
+
provision
|
|
45
|
+
preserve-hosts
|
|
46
|
+
preserve-state
|
|
47
|
+
root-keys
|
|
48
|
+
keyfile
|
|
49
|
+
timeout
|
|
50
|
+
install
|
|
51
|
+
modules
|
|
52
|
+
quiet
|
|
53
|
+
color
|
|
54
|
+
color-host-output
|
|
55
|
+
log-level
|
|
56
|
+
log-prefix
|
|
57
|
+
dry-run
|
|
58
|
+
fail-mode
|
|
59
|
+
ntp
|
|
60
|
+
repo-proxy
|
|
61
|
+
package-proxy
|
|
62
|
+
validate
|
|
63
|
+
collect-perf-data
|
|
64
|
+
parse-only
|
|
65
|
+
tag
|
|
66
|
+
exclude-tags
|
|
67
|
+
xml-time-order
|
|
68
|
+
debug-errors
|
|
69
|
+
exec_manual_tests
|
|
70
|
+
test-tag-exclude
|
|
71
|
+
test-tag-and
|
|
72
|
+
test-tag-or
|
|
73
|
+
xml
|
|
74
|
+
type
|
|
75
|
+
debug
|
|
76
|
+
]
|
|
77
|
+
end
|
|
35
78
|
|
|
36
|
-
let(:
|
|
37
|
-
'options-file',
|
|
38
|
-
'helper',
|
|
39
|
-
'load-path',
|
|
40
|
-
'tests',
|
|
41
|
-
'pre-suite',
|
|
42
|
-
'post-suite',
|
|
43
|
-
'pre-cleanup',
|
|
44
|
-
'provision',
|
|
45
|
-
'preserve-hosts',
|
|
46
|
-
'preserve-state',
|
|
47
|
-
'root-keys',
|
|
48
|
-
'keyfile',
|
|
49
|
-
'timeout',
|
|
50
|
-
'install',
|
|
51
|
-
'modules',
|
|
52
|
-
'quiet',
|
|
53
|
-
'color',
|
|
54
|
-
'color-host-output',
|
|
55
|
-
'log-level',
|
|
56
|
-
'log-prefix',
|
|
57
|
-
'dry-run',
|
|
58
|
-
'fail-mode',
|
|
59
|
-
'ntp',
|
|
60
|
-
'repo-proxy',
|
|
61
|
-
'add-el-extras',
|
|
62
|
-
'package-proxy',
|
|
63
|
-
'validate',
|
|
64
|
-
'collect-perf-data',
|
|
65
|
-
'parse-only',
|
|
66
|
-
'tag',
|
|
67
|
-
'exclude-tags',
|
|
68
|
-
'xml-time-order',
|
|
69
|
-
'debug-errors',
|
|
70
|
-
'exec_manual_tests',
|
|
71
|
-
'test-tag-exclude',
|
|
72
|
-
'test-tag-and',
|
|
73
|
-
'test-tag-or',
|
|
74
|
-
'xml',
|
|
75
|
-
'type',
|
|
76
|
-
'debug',
|
|
77
|
-
] }
|
|
78
|
-
|
|
79
|
-
let( :yaml_store_mock ) { double('yaml_store_mock') }
|
|
79
|
+
let(:yaml_store_mock) { double('yaml_store_mock') }
|
|
80
80
|
|
|
81
81
|
it 'does not error with valid beaker options' do
|
|
82
82
|
beaker_options_list.each do |option|
|
|
@@ -91,7 +91,7 @@ module Beaker
|
|
|
91
91
|
expect(SubcommandUtil::SUBCOMMAND_OPTIONS).to receive(:exist?).and_return(true)
|
|
92
92
|
expect(SubcommandUtil::SUBCOMMAND_STATE).to receive(:exist?).and_return(true)
|
|
93
93
|
|
|
94
|
-
expect {described_class.start(['init', '--hosts', 'centos', "--#{option}"])}.not_to output(/ERROR/).to_stderr
|
|
94
|
+
expect { described_class.start(['init', '--hosts', 'centos', "--#{option}"]) }.not_to output(/ERROR/).to_stderr
|
|
95
95
|
end
|
|
96
96
|
end
|
|
97
97
|
|
|
@@ -102,14 +102,14 @@ module Beaker
|
|
|
102
102
|
expect(File).not_to receive(:open)
|
|
103
103
|
expect(SubcommandUtil::SUBCOMMAND_OPTIONS).to receive(:exist?).and_return(true)
|
|
104
104
|
expect(SubcommandUtil::SUBCOMMAND_STATE).to receive(:exist?).and_return(true)
|
|
105
|
-
expect {described_class.start(['init', '--hosts', 'centos', '--bad-option'])}.to output(/ERROR/).to_stderr
|
|
105
|
+
expect { described_class.start(['init', '--hosts', 'centos', '--bad-option']) }.to output(/ERROR/).to_stderr
|
|
106
106
|
end
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
describe '#init' do
|
|
110
|
-
let(
|
|
111
|
-
let(
|
|
112
|
-
let(
|
|
110
|
+
let(:cli) { subcommand.cli }
|
|
111
|
+
let(:mock_options) { { :timestamp => 'noon', :other_key => 'cordite' } }
|
|
112
|
+
let(:yaml_store_mock) { double('yaml_store_mock') }
|
|
113
113
|
|
|
114
114
|
before do
|
|
115
115
|
allow(cli).to receive(:parse_options)
|
|
@@ -126,21 +126,21 @@ module Beaker
|
|
|
126
126
|
end
|
|
127
127
|
|
|
128
128
|
it 'requires hosts flag' do
|
|
129
|
-
expect{subcommand.init}.to raise_error(NotImplementedError)
|
|
129
|
+
expect { subcommand.init }.to raise_error(NotImplementedError)
|
|
130
130
|
end
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
describe '#provision' do
|
|
134
|
-
let(
|
|
135
|
-
let(
|
|
136
|
-
let(
|
|
137
|
-
let(
|
|
138
|
-
let(
|
|
139
|
-
let(
|
|
140
|
-
let(
|
|
141
|
-
let(
|
|
142
|
-
let(
|
|
143
|
-
let(:options) {double('options')}
|
|
134
|
+
let(:cli) { subcommand.cli }
|
|
135
|
+
let(:yaml_store_mock) { double('yaml_store_mock') }
|
|
136
|
+
let(:host_hash) { { 'mynode.net' => { :name => 'mynode', :platform => Beaker::Platform.new('centos-6-x86_64') } } }
|
|
137
|
+
let(:cleaned_hosts) { double }
|
|
138
|
+
let(:yielded_host_hash) { double }
|
|
139
|
+
let(:yielded_host_name) { double }
|
|
140
|
+
let(:network_manager) { double('network_manager') }
|
|
141
|
+
let(:hosts) { double('hosts') }
|
|
142
|
+
let(:hypervisors) { double('hypervisors') }
|
|
143
|
+
let(:options) { double('options') }
|
|
144
144
|
|
|
145
145
|
it 'provisions the host and saves the host info' do
|
|
146
146
|
expect(YAML::Store).to receive(:new).with(SubcommandUtil::SUBCOMMAND_STATE).and_return(yaml_store_mock)
|
|
@@ -168,8 +168,8 @@ module Beaker
|
|
|
168
168
|
end
|
|
169
169
|
|
|
170
170
|
it 'does not allow hosts to be passed' do
|
|
171
|
-
subcommand.options = {:hosts => "myhost"}
|
|
172
|
-
expect{subcommand.provision
|
|
171
|
+
subcommand.options = { :hosts => "myhost" }
|
|
172
|
+
expect { subcommand.provision }.to raise_error(NotImplementedError)
|
|
173
173
|
end
|
|
174
174
|
end
|
|
175
175
|
|
|
@@ -180,15 +180,15 @@ module Beaker
|
|
|
180
180
|
allow(subcommand.cli).to receive(:execute!)
|
|
181
181
|
end
|
|
182
182
|
|
|
183
|
-
let(
|
|
184
|
-
let(
|
|
185
|
-
let(
|
|
183
|
+
let(:cleaned_hosts) { double }
|
|
184
|
+
let(:host_hash) { { 'mynode.net' => { :name => 'mynode', :platform => Beaker::Platform.new('centos-6-x86_64') } } }
|
|
185
|
+
let(:yaml_store_mock) { double('yaml_store_mock') }
|
|
186
186
|
|
|
187
187
|
it 'calls execute! when no resource is given' do
|
|
188
188
|
expect_any_instance_of(Pathname).not_to receive(:directory?)
|
|
189
189
|
expect_any_instance_of(Pathname).not_to receive(:exist?)
|
|
190
190
|
expect(subcommand.cli).to receive(:execute!).once
|
|
191
|
-
expect{subcommand.exec}.not_to raise_error
|
|
191
|
+
expect { subcommand.exec }.not_to raise_error
|
|
192
192
|
end
|
|
193
193
|
|
|
194
194
|
it 'allows hard coded suite names to be specified' do
|
|
@@ -205,7 +205,7 @@ module Beaker
|
|
|
205
205
|
|
|
206
206
|
it 'errors when a resource is neither a valid file resource or suite name' do
|
|
207
207
|
allow_any_instance_of(Pathname).to receive(:exist?).and_return(false)
|
|
208
|
-
expect{subcommand.exec('blahblahblah')}.to raise_error(ArgumentError)
|
|
208
|
+
expect { subcommand.exec('blahblahblah') }.to raise_error(ArgumentError)
|
|
209
209
|
end
|
|
210
210
|
|
|
211
211
|
it 'accepts a tests directory, clearing all other suites' do
|
|
@@ -249,13 +249,11 @@ module Beaker
|
|
|
249
249
|
it 'rejects comma-separated file and suite name' do
|
|
250
250
|
allow_any_instance_of(Pathname).to receive(:exist?).and_return(false)
|
|
251
251
|
|
|
252
|
-
expect
|
|
252
|
+
expect do
|
|
253
253
|
subcommand.exec('pre-suite,tests/whoops')
|
|
254
|
-
|
|
254
|
+
end.to raise_error(ArgumentError, %r{Unable to parse pre-suite,tests/whoops})
|
|
255
255
|
end
|
|
256
256
|
|
|
257
|
-
|
|
258
|
-
|
|
259
257
|
it 'updates the subcommand_options file with new host info if `preserve-state` is set' do
|
|
260
258
|
allow(yaml_store_mock).to receive(:[]).and_return(false)
|
|
261
259
|
allow(subcommand).to receive(:options).and_return('preserve-state' => true)
|
|
@@ -280,10 +278,10 @@ module Beaker
|
|
|
280
278
|
end
|
|
281
279
|
|
|
282
280
|
context 'destroy' do
|
|
283
|
-
let(
|
|
284
|
-
let(
|
|
285
|
-
let(
|
|
286
|
-
let(
|
|
281
|
+
let(:cli) { subcommand.cli }
|
|
282
|
+
let(:mock_options) { { :timestamp => 'noon', :other_key => 'cordite' } }
|
|
283
|
+
let(:yaml_store_mock) { double('yaml_store_mock') }
|
|
284
|
+
let(:network_manager) { double('network_manager') }
|
|
287
285
|
|
|
288
286
|
it 'calls destroy and updates the yaml store' do
|
|
289
287
|
allow(cli).to receive(:parse_options)
|
|
@@ -9,116 +9,96 @@ module Beaker
|
|
|
9
9
|
context 'run_test' do
|
|
10
10
|
it 'defaults to test_status :pass on success' do
|
|
11
11
|
path = 'test.rb'
|
|
12
|
-
File.
|
|
13
|
-
f.write ""
|
|
14
|
-
end
|
|
12
|
+
File.write(path, "")
|
|
15
13
|
@path = path
|
|
16
|
-
expect(
|
|
14
|
+
expect(testcase).not_to receive(:log_and_fail_test)
|
|
17
15
|
testcase.run_test
|
|
18
16
|
expect(testcase.test_status).to be === :pass
|
|
19
17
|
end
|
|
20
18
|
|
|
21
19
|
it 'updates test_status to :skip on SkipTest' do
|
|
22
20
|
path = 'test.rb'
|
|
23
|
-
File.
|
|
24
|
-
f.write "raise SkipTest"
|
|
25
|
-
end
|
|
21
|
+
File.write(path, "raise SkipTest")
|
|
26
22
|
@path = path
|
|
27
|
-
expect(
|
|
23
|
+
expect(testcase).not_to receive(:log_and_fail_test)
|
|
28
24
|
testcase.run_test
|
|
29
25
|
expect(testcase.test_status).to be === :skip
|
|
30
26
|
end
|
|
31
27
|
|
|
32
28
|
it 'updates test_status to :pending on PendingTest' do
|
|
33
29
|
path = 'test.rb'
|
|
34
|
-
File.
|
|
35
|
-
f.write "raise PendingTest"
|
|
36
|
-
end
|
|
30
|
+
File.write(path, "raise PendingTest")
|
|
37
31
|
@path = path
|
|
38
|
-
expect(
|
|
32
|
+
expect(testcase).not_to receive(:log_and_fail_test)
|
|
39
33
|
testcase.run_test
|
|
40
34
|
expect(testcase.test_status).to be === :pending
|
|
41
35
|
end
|
|
42
36
|
|
|
43
37
|
it 'updates test_status to :fail on FailTest' do
|
|
44
38
|
path = 'test.rb'
|
|
45
|
-
File.
|
|
46
|
-
f.write "raise FailTest"
|
|
47
|
-
end
|
|
39
|
+
File.write(path, "raise FailTest")
|
|
48
40
|
@path = path
|
|
49
|
-
expect(
|
|
41
|
+
expect(testcase).to receive(:log_and_fail_test).once.with(kind_of(Beaker::DSL::FailTest), :fail).and_call_original
|
|
50
42
|
testcase.run_test
|
|
51
43
|
expect(testcase.test_status).to be === :fail
|
|
52
44
|
end
|
|
53
45
|
|
|
54
46
|
it 'correctly handles RuntimeError' do
|
|
55
47
|
path = 'test.rb'
|
|
56
|
-
File.
|
|
57
|
-
f.write "raise RuntimeError"
|
|
58
|
-
end
|
|
48
|
+
File.write(path, "raise RuntimeError")
|
|
59
49
|
@path = path
|
|
60
|
-
expect(
|
|
50
|
+
expect(testcase).to receive(:log_and_fail_test).once.with(kind_of(RuntimeError))
|
|
61
51
|
testcase.run_test
|
|
62
52
|
end
|
|
63
53
|
|
|
64
54
|
it 'correctly handles ScriptError' do
|
|
65
55
|
path = 'test.rb'
|
|
66
|
-
File.
|
|
67
|
-
f.write "raise ScriptError"
|
|
68
|
-
end
|
|
56
|
+
File.write(path, "raise ScriptError")
|
|
69
57
|
@path = path
|
|
70
|
-
expect(
|
|
58
|
+
expect(testcase).to receive(:log_and_fail_test).once.with(kind_of(ScriptError))
|
|
71
59
|
testcase.run_test
|
|
72
60
|
end
|
|
73
61
|
|
|
74
62
|
it 'correctly handles Timeout::Error' do
|
|
75
63
|
path = 'test.rb'
|
|
76
|
-
File.
|
|
77
|
-
f.write "raise Timeout::Error"
|
|
78
|
-
end
|
|
64
|
+
File.write(path, "raise Timeout::Error")
|
|
79
65
|
@path = path
|
|
80
|
-
expect(
|
|
66
|
+
expect(testcase).to receive(:log_and_fail_test).once.with(kind_of(Timeout::Error))
|
|
81
67
|
testcase.run_test
|
|
82
68
|
end
|
|
83
69
|
|
|
84
70
|
it 'correctly handles CommandFailure' do
|
|
85
71
|
path = 'test.rb'
|
|
86
|
-
File.
|
|
87
|
-
f.write "raise Host::CommandFailure"
|
|
88
|
-
end
|
|
72
|
+
File.write(path, "raise Host::CommandFailure")
|
|
89
73
|
@path = path
|
|
90
|
-
expect(
|
|
74
|
+
expect(testcase).to receive(:log_and_fail_test).once.with(kind_of(Host::CommandFailure))
|
|
91
75
|
testcase.run_test
|
|
92
76
|
end
|
|
93
77
|
|
|
94
78
|
it 'records a test failure if an assertion fails in a teardown block' do
|
|
95
79
|
path = 'test.rb'
|
|
96
|
-
File.
|
|
97
|
-
f.write <<-EOF
|
|
80
|
+
File.write(path, <<-EOF)
|
|
98
81
|
teardown do
|
|
99
82
|
assert_equal(1, 2, 'Oh noes!')
|
|
100
83
|
end
|
|
101
|
-
|
|
102
|
-
end
|
|
84
|
+
EOF
|
|
103
85
|
@path = path
|
|
104
|
-
expect(
|
|
86
|
+
expect(testcase).to receive(:log_and_fail_test).once.with(kind_of(Minitest::Assertion), :teardown_error).and_call_original
|
|
105
87
|
testcase.run_test
|
|
106
88
|
expect(testcase.test_status).to eq(:error)
|
|
107
89
|
end
|
|
108
90
|
|
|
109
91
|
it 'does not overwrite a test failure if an assertion also happens in a teardown block' do
|
|
110
92
|
path = 'test.rb'
|
|
111
|
-
File.
|
|
112
|
-
f.write <<-EOF
|
|
93
|
+
File.write(path, <<-EOF)
|
|
113
94
|
teardown do
|
|
114
95
|
assert_equal(1, 2, 'Oh noes!')
|
|
115
96
|
end
|
|
116
97
|
assert_equal(true, false, 'failed test')
|
|
117
|
-
|
|
118
|
-
end
|
|
98
|
+
EOF
|
|
119
99
|
@path = path
|
|
120
|
-
expect(
|
|
121
|
-
expect(
|
|
100
|
+
expect(testcase).to receive(:log_and_fail_test).once.with(kind_of(Minitest::Assertion), :fail).and_call_original
|
|
101
|
+
expect(testcase).to receive(:log_and_fail_test).once.with(kind_of(Minitest::Assertion), :teardown_error).and_call_original
|
|
122
102
|
testcase.run_test
|
|
123
103
|
expect(testcase.test_status).to eq(:fail)
|
|
124
104
|
end
|
|
@@ -128,9 +108,7 @@ module Beaker
|
|
|
128
108
|
it 'sets the filename correctly from the path' do
|
|
129
109
|
answer = 'jacket'
|
|
130
110
|
path = "#{answer}.rb"
|
|
131
|
-
File.
|
|
132
|
-
f.write ""
|
|
133
|
-
end
|
|
111
|
+
File.write(path, "")
|
|
134
112
|
@path = path
|
|
135
113
|
testcase.run_test
|
|
136
114
|
metadata = testcase.instance_variable_get(:@metadata)
|
|
@@ -139,9 +117,7 @@ module Beaker
|
|
|
139
117
|
|
|
140
118
|
it 'resets the step name' do
|
|
141
119
|
path = 'test.rb'
|
|
142
|
-
File.
|
|
143
|
-
f.write ""
|
|
144
|
-
end
|
|
120
|
+
File.write(path, "")
|
|
145
121
|
@path = path
|
|
146
122
|
# we have to create a TestCase by hand, so that we can set old
|
|
147
123
|
tc = described_class.new({}, logger, {}, path)
|
|
@@ -153,6 +129,5 @@ module Beaker
|
|
|
153
129
|
expect(metadata[:step][:name]).to be_nil
|
|
154
130
|
end
|
|
155
131
|
end
|
|
156
|
-
|
|
157
132
|
end
|
|
158
133
|
end
|