beaker 4.38.1 → 4.39.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +12 -0
  3. data/.rubocop.yml +62 -0
  4. data/.rubocop_todo.yml +215 -0
  5. data/CHANGELOG.md +72 -33
  6. data/Gemfile +8 -1
  7. data/HISTORY.md +103 -0
  8. data/Rakefile +10 -9
  9. data/acceptance/fixtures/module/Gemfile +1 -1
  10. data/acceptance/fixtures/module/Rakefile +2 -2
  11. data/acceptance/fixtures/module/spec/acceptance/demo_spec.rb +8 -11
  12. data/acceptance/fixtures/module/spec/classes/init_spec.rb +1 -1
  13. data/acceptance/lib/helpers/test_helper.rb +3 -3
  14. data/acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb +6 -6
  15. data/acceptance/tests/base/dsl/helpers/host_helpers/archive_file_from_test.rb +6 -6
  16. data/acceptance/tests/base/dsl/helpers/host_helpers/backup_the_file_test.rb +6 -12
  17. data/acceptance/tests/base/dsl/helpers/host_helpers/create_remote_file_test.rb +4 -4
  18. data/acceptance/tests/base/dsl/helpers/host_helpers/curl_on_test.rb +1 -1
  19. data/acceptance/tests/base/dsl/helpers/host_helpers/deploy_package_repo_test.rb +7 -7
  20. data/acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb +4 -4
  21. data/acceptance/tests/base/dsl/helpers/host_helpers/retry_on_test.rb +4 -4
  22. data/acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb +8 -11
  23. data/acceptance/tests/base/dsl/helpers/host_helpers/run_cron_on_test.rb +2 -2
  24. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_on_test.rb +6 -11
  25. data/acceptance/tests/base/dsl/helpers/host_helpers/run_script_test.rb +5 -9
  26. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_from_test.rb +2 -2
  27. data/acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb +1 -1
  28. data/acceptance/tests/base/dsl/helpers/host_helpers/shell_test.rb +4 -4
  29. data/acceptance/tests/base/dsl/helpers/host_helpers/upgrade_package_test.rb +1 -1
  30. data/acceptance/tests/base/dsl/platform_tag_confiner_test.rb +1 -1
  31. data/acceptance/tests/base/dsl/structure_test.rb +4 -10
  32. data/acceptance/tests/base/host/file_test.rb +7 -7
  33. data/acceptance/tests/base/host/group_test.rb +2 -2
  34. data/acceptance/tests/base/host/host_test.rb +5 -5
  35. data/acceptance/tests/base/host/packages.rb +26 -28
  36. data/acceptance/tests/base/host/packages_unix.rb +4 -4
  37. data/acceptance/tests/base/host/user_test.rb +2 -2
  38. data/acceptance/tests/install/from_file.rb +2 -2
  39. data/beaker.gemspec +9 -9
  40. data/docs/concepts/style_guide.md +1 -1
  41. data/docs/how_to/debug_beaker_tests.md +1 -1
  42. data/docs/how_to/test_arbitrary_beaker_versions.md +2 -2
  43. data/lib/beaker/cli.rb +6 -8
  44. data/lib/beaker/command.rb +3 -3
  45. data/lib/beaker/command_factory.rb +2 -2
  46. data/lib/beaker/dsl/assertions.rb +1 -1
  47. data/lib/beaker/dsl/helpers/hocon_helpers.rb +2 -2
  48. data/lib/beaker/dsl/helpers/host_helpers.rb +11 -11
  49. data/lib/beaker/dsl/helpers/web_helpers.rb +3 -3
  50. data/lib/beaker/dsl/outcomes.rb +4 -4
  51. data/lib/beaker/dsl/roles.rb +2 -2
  52. data/lib/beaker/dsl/structure.rb +10 -10
  53. data/lib/beaker/host/aix/group.rb +3 -3
  54. data/lib/beaker/host/aix/user.rb +3 -3
  55. data/lib/beaker/host/cisco.rb +11 -11
  56. data/lib/beaker/host/eos.rb +2 -2
  57. data/lib/beaker/host/mac/exec.rb +1 -1
  58. data/lib/beaker/host/mac/group.rb +7 -7
  59. data/lib/beaker/host/mac/pkg.rb +6 -6
  60. data/lib/beaker/host/mac/user.rb +6 -6
  61. data/lib/beaker/host/pswindows/exec.rb +8 -8
  62. data/lib/beaker/host/pswindows/file.rb +1 -1
  63. data/lib/beaker/host/pswindows/group.rb +3 -3
  64. data/lib/beaker/host/pswindows/pkg.rb +6 -6
  65. data/lib/beaker/host/pswindows/user.rb +2 -2
  66. data/lib/beaker/host/unix/exec.rb +6 -6
  67. data/lib/beaker/host/unix/file.rb +3 -4
  68. data/lib/beaker/host/unix/group.rb +3 -3
  69. data/lib/beaker/host/unix/pkg.rb +17 -17
  70. data/lib/beaker/host/unix/user.rb +3 -3
  71. data/lib/beaker/host/unix.rb +10 -9
  72. data/lib/beaker/host/windows/exec.rb +3 -3
  73. data/lib/beaker/host/windows/file.rb +2 -2
  74. data/lib/beaker/host/windows/group.rb +3 -3
  75. data/lib/beaker/host/windows/pkg.rb +6 -6
  76. data/lib/beaker/host/windows/user.rb +2 -2
  77. data/lib/beaker/host/windows.rb +2 -2
  78. data/lib/beaker/host.rb +7 -7
  79. data/lib/beaker/host_prebuilt_steps.rb +38 -45
  80. data/lib/beaker/hypervisor.rb +4 -4
  81. data/lib/beaker/local_connection.rb +3 -3
  82. data/lib/beaker/logger.rb +5 -11
  83. data/lib/beaker/logger_junit.rb +2 -2
  84. data/lib/beaker/network_manager.rb +2 -2
  85. data/lib/beaker/options/command_line_parser.rb +1 -1
  86. data/lib/beaker/options/hosts_file_parser.rb +21 -4
  87. data/lib/beaker/options/options_file_parser.rb +1 -1
  88. data/lib/beaker/options/options_hash.rb +1 -3
  89. data/lib/beaker/options/parser.rb +6 -6
  90. data/lib/beaker/options/presets.rb +2 -2
  91. data/lib/beaker/options/validator.rb +2 -2
  92. data/lib/beaker/perf.rb +9 -9
  93. data/lib/beaker/platform.rb +1 -1
  94. data/lib/beaker/shared/host_manager.rb +4 -5
  95. data/lib/beaker/shared/repetition.rb +4 -4
  96. data/lib/beaker/shared/semvar.rb +2 -2
  97. data/lib/beaker/shared/timed.rb +2 -2
  98. data/lib/beaker/ssh_connection.rb +9 -9
  99. data/lib/beaker/subcommand.rb +6 -6
  100. data/lib/beaker/tasks/quick_start.rb +2 -2
  101. data/lib/beaker/tasks/rake_task.rb +3 -3
  102. data/lib/beaker/test_suite.rb +2 -2
  103. data/lib/beaker/test_suite_result.rb +8 -11
  104. data/lib/beaker/version.rb +1 -1
  105. data/spec/beaker/cli_spec.rb +46 -43
  106. data/spec/beaker/command_spec.rb +17 -7
  107. data/spec/beaker/dsl/assertions_spec.rb +2 -11
  108. data/spec/beaker/dsl/helpers/host_helpers_spec.rb +7 -7
  109. data/spec/beaker/dsl/helpers/web_helpers_spec.rb +2 -2
  110. data/spec/beaker/dsl/outcomes_spec.rb +1 -0
  111. data/spec/beaker/dsl/roles_spec.rb +48 -5
  112. data/spec/beaker/dsl/structure_spec.rb +22 -15
  113. data/spec/beaker/dsl/test_tagging_spec.rb +16 -16
  114. data/spec/beaker/dsl/wrappers_spec.rb +7 -7
  115. data/spec/beaker/host/cisco_spec.rb +8 -8
  116. data/spec/beaker/host/freebsd/exec_spec.rb +3 -3
  117. data/spec/beaker/host/freebsd/pkg_spec.rb +6 -3
  118. data/spec/beaker/host/mac/exec_spec.rb +3 -3
  119. data/spec/beaker/host/mac_spec.rb +6 -6
  120. data/spec/beaker/host/pswindows/exec_spec.rb +8 -5
  121. data/spec/beaker/host/pswindows/file_spec.rb +6 -3
  122. data/spec/beaker/host/pswindows_spec.rb +1 -1
  123. data/spec/beaker/host/unix/exec_spec.rb +24 -24
  124. data/spec/beaker/host/unix/file_spec.rb +18 -17
  125. data/spec/beaker/host/unix/pkg_spec.rb +26 -22
  126. data/spec/beaker/host/unix_spec.rb +8 -8
  127. data/spec/beaker/host/windows/exec_spec.rb +4 -4
  128. data/spec/beaker/host/windows/file_spec.rb +4 -4
  129. data/spec/beaker/host/windows/group_spec.rb +12 -12
  130. data/spec/beaker/host/windows/pkg_spec.rb +5 -5
  131. data/spec/beaker/host_prebuilt_steps_spec.rb +26 -20
  132. data/spec/beaker/host_spec.rb +72 -63
  133. data/spec/beaker/hypervisor/hypervisor_spec.rb +14 -14
  134. data/spec/beaker/localhost_connection_spec.rb +6 -4
  135. data/spec/beaker/logger_junit_spec.rb +16 -17
  136. data/spec/beaker/logger_spec.rb +54 -52
  137. data/spec/beaker/network_manager_spec.rb +5 -5
  138. data/spec/beaker/options/command_line_parser_spec.rb +2 -2
  139. data/spec/beaker/options/data/hosts_preserved.yml +395 -0
  140. data/spec/beaker/options/hosts_file_parser_spec.rb +9 -2
  141. data/spec/beaker/options/options_file_parser_spec.rb +1 -1
  142. data/spec/beaker/options/options_hash_spec.rb +4 -4
  143. data/spec/beaker/options/parser_spec.rb +23 -23
  144. data/spec/beaker/options/presets_spec.rb +2 -2
  145. data/spec/beaker/options/subcommand_options_parser_spec.rb +4 -3
  146. data/spec/beaker/options/validator_spec.rb +18 -18
  147. data/spec/beaker/perf_spec.rb +29 -28
  148. data/spec/beaker/platform_spec.rb +3 -2
  149. data/spec/beaker/shared/error_handler_spec.rb +1 -1
  150. data/spec/beaker/shared/fog_credentials_spec.rb +12 -12
  151. data/spec/beaker/shared/host_manager_spec.rb +7 -7
  152. data/spec/beaker/shared/repetition_spec.rb +9 -9
  153. data/spec/beaker/ssh_connection_spec.rb +14 -12
  154. data/spec/beaker/subcommand/subcommand_util_spec.rb +9 -4
  155. data/spec/beaker/subcommand_spec.rb +30 -28
  156. data/spec/beaker/test_case_spec.rb +11 -15
  157. data/spec/beaker/test_suite_spec.rb +24 -24
  158. data/spec/matchers.rb +1 -1
  159. data/spec/mocks.rb +5 -5
  160. data/spec/spec_helper.rb +0 -3
  161. metadata +59 -59
  162. data/spec/mock_fission.rb +0 -60
  163. data/spec/mock_vsphere.rb +0 -314
  164. data/spec/mock_vsphere_helper.rb +0 -183
@@ -4,7 +4,7 @@ test_name "dsl::helpers::host_helpers #scp_from" do
4
4
  if test_scp_error_on_close?
5
5
  step "#scp_from fails if the local path cannot be found" do
6
6
  remote_tmpdir = default.tmpdir()
7
- remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_tmpdir, "testfile.txt")
7
+ remote_filename, _contents = create_remote_file_from_fixture("simple_text_file", default, remote_tmpdir, "testfile.txt")
8
8
 
9
9
  assert_raises Beaker::Host::CommandFailure do
10
10
  scp_from default, remote_filename, "/non/existent/file.txt"
@@ -40,7 +40,7 @@ test_name "dsl::helpers::host_helpers #scp_from" do
40
40
  remote_tmpdir = default.tmpdir()
41
41
  remote_filename = File.join(remote_tmpdir, "testfile.txt")
42
42
  on hosts, "mkdir -p #{remote_tmpdir}"
43
- results = on hosts, %Q{echo "${RANDOM}:${RANDOM}:${RANDOM}" > #{remote_filename}}
43
+ on hosts, %Q{echo "${RANDOM}:${RANDOM}:${RANDOM}" > #{remote_filename}}
44
44
 
45
45
  scp_from hosts, remote_filename, local_dir
46
46
  remote_contents = on(hosts.last, "cat #{remote_filename}").stdout
@@ -11,7 +11,7 @@ test_name "dsl::helpers::host_helpers #scp_to" do
11
11
  if test_scp_error_on_close?
12
12
  step "#scp_to fails if the remote path cannot be found" do
13
13
  Dir.mktmpdir do |local_dir|
14
- local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
14
+ local_filename, _contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
15
15
 
16
16
  # assert_raises Beaker::Host::CommandFailure do
17
17
  assert_raises RuntimeError do
@@ -14,7 +14,7 @@ test_name "dsl::helpers::host_helpers #shell" do
14
14
 
15
15
  step "#shell makes command error output available via `.stderr` on success" do
16
16
  output = shell("/bin/nonexistent-command", :acceptable_exit_codes => [0, 127]).stderr
17
- assert_match /No such file/, output
17
+ assert_match(/No such file/, output)
18
18
  end
19
19
 
20
20
  step "#shell makes exit status available via `.exit_code`" do
@@ -25,7 +25,7 @@ test_name "dsl::helpers::host_helpers #shell" do
25
25
  step "#shell with :acceptable_exit_codes will not fail for named exit codes" do
26
26
  result = shell "/bin/nonexistent-command", :acceptable_exit_codes => [0, 127]
27
27
  output = result.stderr
28
- assert_match /No such file/, output
28
+ assert_match(/No such file/, output)
29
29
  status = result.exit_code
30
30
  assert_equal 127, status
31
31
  end
@@ -40,12 +40,12 @@ test_name "dsl::helpers::host_helpers #shell" do
40
40
  result = shell "env", { :environment => { 'FOO' => 'bar' } }
41
41
  output = result.stdout
42
42
 
43
- assert_match /\bFOO=bar\b/, output
43
+ assert_match(/\bFOO=bar\b/, output)
44
44
  end
45
45
 
46
46
  step "#shell allows assertions to be used in the optional block" do
47
47
  shell %Q{echo "${RANDOM}:${RANDOM}"} do
48
- assert_match /\d+:\d+/, stdout
48
+ assert_match(/\d+:\d+/, stdout)
49
49
  end
50
50
  end
51
51
  end
@@ -43,7 +43,7 @@ test_name "dsl::helpers::host_helpers #upgrade_package" do
43
43
  # > No Packages marked for Update
44
44
 
45
45
  result = upgrade_package default, "non-existent-package-name"
46
- assert_match /No Packages marked for Update/i, result
46
+ assert_match(/No Packages marked for Update/i, result)
47
47
  end
48
48
  end
49
49
 
@@ -26,7 +26,7 @@ test_name "DSL::Structure::PlatformTagConfiner" do
26
26
  begin
27
27
  tag( 'tag1' )
28
28
  rescue Beaker::DSL::Outcomes::SkipTest => e
29
- if e.message =~ /^No\ suitable\ hosts\ found/
29
+ if /^No\ suitable\ hosts\ found/.match?(e.message)
30
30
  # SkipTest is raised in the case when there are no hosts leftover for a test
31
31
  # after confining. It's a very common acceptance test case where all of the
32
32
  # hosts involved are of the same platform, and are thus all confined
@@ -15,8 +15,6 @@ test_name "dsl::structure" do
15
15
 
16
16
  step "#confine_block leaves hosts array intact after running block on matching hosts" do
17
17
  begin
18
- previous_hosts = hosts.dup
19
-
20
18
  @in_confine = 0
21
19
  confine_block :to, :platform => default["platform"] do
22
20
  @in_confine +=1
@@ -46,8 +44,6 @@ test_name "dsl::structure" do
46
44
 
47
45
  step "#confine_block leaves hosts array intact after skipping block on non-matching hosts" do
48
46
  begin
49
- previous_hosts = hosts.dup
50
-
51
47
  @in_confine = 0
52
48
  confine_block :except, :platform => default["platform"] do
53
49
  @in_confine +=1
@@ -62,8 +58,6 @@ test_name "dsl::structure" do
62
58
  end
63
59
 
64
60
  step "#confine_block allows blocks to raise skip_test" do
65
- previous_hosts = hosts.dup
66
-
67
61
  begin
68
62
  @in_confine = 0
69
63
  confine_block :to, :platform => default["platform"] do
@@ -71,7 +65,7 @@ test_name "dsl::structure" do
71
65
  skip_test "this block raises a skip"
72
66
  end
73
67
  rescue Beaker::DSL::Outcomes::SkipTest => e
74
- assert_match /this block raises a skip/, e.message, "#confine_block raised an unexpected skip_test"
68
+ assert_match(/this block raises a skip/, e.message, "#confine_block raised an unexpected skip_test")
75
69
  assert_equal 1, @in_confine, "#confine_block did not execute supplied block"
76
70
  assert_equal hosts.dup, hosts, "#confine_block did not preserve the hosts array"
77
71
  end
@@ -84,7 +78,7 @@ test_name "dsl::structure" do
84
78
  fail "#confine did not skip test but should have."
85
79
 
86
80
  rescue Beaker::DSL::Outcomes::SkipTest => e
87
- assert_match /No suitable hosts found with {:platform=>"test"}/, e.message, "#confine raised an unexpected skip_test"
81
+ assert_match(/No suitable hosts found with {:platform=>"test"}/, e.message, "#confine raised an unexpected skip_test")
88
82
  end
89
83
  end
90
84
 
@@ -95,8 +89,8 @@ test_name "dsl::structure" do
95
89
  fail "#confine did not skip test but should have."
96
90
 
97
91
  rescue Beaker::DSL::Outcomes::SkipTest => e
98
- assert_match /No suitable hosts found without {:platform=>"#{default['platform']}"}/, e.message, "#confine raised an unexpected
99
- # skip_test"
92
+ assert_match(/No suitable hosts found without {:platform=>"#{default['platform']}"}/, e.message, "#confine raised an unexpected
93
+ # skip_test")
100
94
  end
101
95
  end
102
96
  end
@@ -11,7 +11,7 @@ test_name 'File Test' do
11
11
  tmpfile = host.tmpfile('beaker')
12
12
  # ensure we have a user to chown to
13
13
  host.chown('testuser', tmpfile)
14
- assert_match /testuser/, host.ls_ld(tmpfile), "Should have found testuser in `ls -ld` output"
14
+ assert_match(/testuser/, host.ls_ld(tmpfile), "Should have found testuser in `ls -ld` output")
15
15
  end
16
16
  end
17
17
 
@@ -21,7 +21,7 @@ test_name 'File Test' do
21
21
  tmpdir = host.tmpdir('beaker')
22
22
  # ensure we have a user to chown to
23
23
  host.chgrp('testgroup', tmpdir)
24
- assert_match /testgroup/, host.ls_ld(tmpdir), "Should have found testgroup in `ls -ld` output: #{stdout}"
24
+ assert_match(/testgroup/, host.ls_ld(tmpdir), "Should have found testgroup in `ls -ld` output: #{stdout}")
25
25
  end
26
26
  end
27
27
 
@@ -31,7 +31,7 @@ test_name 'File Test' do
31
31
  tmpdir = host.tmpdir('beaker')
32
32
  on host, host.touch("#{tmpdir}/somefile.txt", false)
33
33
  host.chown('testuser', tmpdir, true)
34
- assert_match /testuser/, host.ls_ld("#{tmpdir}/somefile.txt"), "Should have found testuser in `ls -ld` output for sub-file"
34
+ assert_match(/testuser/, host.ls_ld("#{tmpdir}/somefile.txt"), "Should have found testuser in `ls -ld` output for sub-file")
35
35
  end
36
36
  end
37
37
 
@@ -41,7 +41,7 @@ test_name 'File Test' do
41
41
  tmpfile = host.tmpfile('beaker')
42
42
  # ensure we have a group to chgrp to
43
43
  host.chgrp('testgroup', tmpfile)
44
- assert_match /testgroup/, host.ls_ld(tmpfile), "Should have found testgroup in `ls -ld` output"
44
+ assert_match(/testgroup/, host.ls_ld(tmpfile), "Should have found testgroup in `ls -ld` output")
45
45
  end
46
46
  end
47
47
 
@@ -51,7 +51,7 @@ test_name 'File Test' do
51
51
  tmpdir = host.tmpdir('beaker')
52
52
  # ensure we have a group to chgrp to
53
53
  host.chgrp('testgroup', tmpdir)
54
- assert_match /testgroup/, host.ls_ld(tmpdir), "Should have found testgroup in `ls -ld` output"
54
+ assert_match(/testgroup/, host.ls_ld(tmpdir), "Should have found testgroup in `ls -ld` output")
55
55
  end
56
56
  end
57
57
 
@@ -61,7 +61,7 @@ test_name 'File Test' do
61
61
  tmpdir = host.tmpdir('beaker')
62
62
  on host, host.touch("#{tmpdir}/somefile.txt", false)
63
63
  host.chgrp('testgroup', tmpdir, true)
64
- assert_match /testgroup/, host.ls_ld("#{tmpdir}/somefile.txt"), "Should have found testgroup in `ls -ld` output for sub-file"
64
+ assert_match(/testgroup/, host.ls_ld("#{tmpdir}/somefile.txt"), "Should have found testgroup in `ls -ld` output for sub-file")
65
65
  end
66
66
  end
67
67
 
@@ -69,7 +69,7 @@ test_name 'File Test' do
69
69
  hosts.each do |host|
70
70
  # create a tmp file to mangle
71
71
  tmpdir = host.tmpdir('beaker')
72
- assert_match /beaker/, host.ls_ld(tmpdir), "Should have found beaker in `ls -ld` output"
72
+ assert_match(/beaker/, host.ls_ld(tmpdir), "Should have found beaker in `ls -ld` output")
73
73
  end
74
74
  end
75
75
 
@@ -1,6 +1,6 @@
1
1
  test_name 'Group Test' do
2
2
  step "#group_get: has an Administrators group on Windows" do
3
- hosts.select { |h| h['platform'] =~ /windows/ }.each do |host|
3
+ hosts.select { |h| h['platform'].include?('windows') }.each do |host|
4
4
  host.group_get('Administrators') do |result|
5
5
  refute_match(result.stdout, '1376', 'Output indicates Administrators not found')
6
6
  end
@@ -8,7 +8,7 @@ test_name 'Group Test' do
8
8
  end
9
9
 
10
10
  step "#group_get: should not have CroMags group on Windows" do
11
- hosts.select { |h| h['platform'] =~ /windows/ }.each do |host|
11
+ hosts.select { |h| h['platform'].include?('windows') }.each do |host|
12
12
  assert_raises Beaker::Host::CommandFailure do
13
13
  host.group_get('CroMags') { |result| }
14
14
  end
@@ -20,7 +20,7 @@ end
20
20
 
21
21
  step "#is_x86_64? : can determine arch on hosts"
22
22
  hosts.each do |host|
23
- if host['platform'] =~ /x86_64|_64|amd64|-64/
23
+ if /x86_64|_64|amd64|-64/.match?(host['platform'])
24
24
  assert_equal(true, host.is_x86_64?, "is_x86_64? should be true on #{host}: #{host['platform']}")
25
25
  else
26
26
  assert_equal(false, host.is_x86_64?, "is_x86_64? should be false on #{host}: #{host['platform']}")
@@ -213,7 +213,7 @@ hosts.each do |host|
213
213
  #each local file should have a single match on the host
214
214
  local_paths.each do |path|
215
215
  search_name = path.gsub(/^.*fixtures\//, '') #reduce down to the path that should match
216
- matched = host_paths.select{ |check| check =~ /#{Regexp.escape(search_name)}$/ }
216
+ matched = host_paths.select{ |check| /#{Regexp.escape(search_name)}$/.match?(check) }
217
217
  assert_equal(1, matched.length, "should have found a single instance of path #{search_name}, found #{matched.length}: \n #{matched}")
218
218
  host_paths = host_paths - matched
219
219
  end
@@ -238,9 +238,9 @@ hosts.each do |host|
238
238
  #each local file should have a single match on the host
239
239
  local_paths.each do |path|
240
240
  search_name = path.gsub(/^.*fixtures\//, '') #reduce down to the path that should match
241
- matched = host_paths.select{ |check| check =~ /#{Regexp.escape(search_name)}$/ }
241
+ matched = host_paths.select{ |check| /#{Regexp.escape(search_name)}$/.match?(check) }
242
242
  re = /((\/|\A)tests(\/|\z))|((\/|\A)Gemfile(\/|\z))/
243
- if path !~ re
243
+ if !path&.match?(re)
244
244
  assert_equal(1, matched.length, "should have found a single instance of path #{search_name}, found #{matched.length}: \n #{matched}")
245
245
  else
246
246
  assert_equal(0, matched.length, "should have found no instances of path #{search_name}, found #{matched.length}: \n #{matched}")
@@ -270,7 +270,7 @@ hosts.each do |host|
270
270
  search_name = path.gsub(/^.*fixtures\/module\//, '') #reduce down to the path that should match
271
271
  matched = host_paths.select{ |check| check =~ /#{Regexp.escape(search_name)}$/ }
272
272
  re = /((\/|\A)module(\/|\z))|((\/|\A)Gemfile(\/|\z))/
273
- if path.gsub(/^.*module\//, '') !~ re
273
+ if !path.gsub(/^.*module\//, '')&.match?(re)
274
274
  assert_equal(1, matched.length, "should have found a single instance of path #{search_name}, found #{matched.length}: \n #{matched}")
275
275
  else
276
276
  assert_equal(0, matched.length, "should have found no instances of path #{search_name}, found #{matched.length}: \n #{matched}")
@@ -2,27 +2,25 @@ test_name 'confirm packages on hosts behave correctly'
2
2
  confine :except, :platform => %w(osx)
3
3
 
4
4
  def get_host_pkg(host)
5
- case
6
- when host['platform'] =~ /sles-10/
7
- Beaker::HostPrebuiltSteps::SLES10_PACKAGES
8
- when host['platform'] =~ /opensuse|sles-/
9
- Beaker::HostPrebuiltSteps::SLES_PACKAGES
10
- when host['platform'] =~ /debian/
11
- Beaker::HostPrebuiltSteps::DEBIAN_PACKAGES
12
- when host['platform'] =~ /cumulus/
13
- Beaker::HostPrebuiltSteps::CUMULUS_PACKAGES
14
- when (host['platform'] =~ /windows/ and host.is_cygwin?)
15
- Beaker::HostPrebuiltSteps::WINDOWS_PACKAGES
16
- when (host['platform'] =~ /windows/ and not host.is_cygwin?)
17
- Beaker::HostPrebuiltSteps::PSWINDOWS_PACKAGES
18
- when host['platform'] =~ /freebsd/
19
- Beaker::HostPrebuiltSteps::FREEBSD_PACKAGES
20
- when host['platform'] =~ /openbsd/
21
- Beaker::HostPrebuiltSteps::OPENBSD_PACKAGES
22
- when host['platform'] =~ /solaris-10/
23
- Beaker::HostPrebuiltSteps::SOLARIS10_PACKAGES
24
- else
25
- Beaker::HostPrebuiltSteps::UNIX_PACKAGES
5
+ case host['platform']
6
+ when /sles-10/
7
+ Beaker::HostPrebuiltSteps::SLES10_PACKAGES
8
+ when /opensuse|sles-/
9
+ Beaker::HostPrebuiltSteps::SLES_PACKAGES
10
+ when /debian/
11
+ Beaker::HostPrebuiltSteps::DEBIAN_PACKAGES
12
+ when /cumulus/
13
+ Beaker::HostPrebuiltSteps::CUMULUS_PACKAGES
14
+ when /windows/
15
+ host.is_cygwin? ? Beaker::HostPrebuiltSteps::WINDOWS_PACKAGES : Beaker::HostPrebuiltSteps::PSWINDOWS_PACKAGES
16
+ when /freebsd/
17
+ Beaker::HostPrebuiltSteps::FREEBSD_PACKAGES
18
+ when /openbsd/
19
+ Beaker::HostPrebuiltSteps::OPENBSD_PACKAGES
20
+ when /solaris-10/
21
+ Beaker::HostPrebuiltSteps::SOLARIS10_PACKAGES
22
+ else
23
+ Beaker::HostPrebuiltSteps::UNIX_PACKAGES
26
24
  end
27
25
 
28
26
  end
@@ -50,12 +48,12 @@ hosts.each do |host|
50
48
  # this works on Windows as well, althought it pulls in
51
49
  # a lot of dependencies.
52
50
  # skipping this test for windows since it requires a restart
53
- next if host['platform'] =~ /windows/
51
+ next if host['platform'].include?('windows')
54
52
  package = 'zsh'
55
- package = 'CSWzsh' if host['platform'] =~ /solaris-10/
56
- package = 'git' if host['platform'] =~ /opensuse|sles/
53
+ package = 'CSWzsh' if host['platform'].include?('solaris-10')
54
+ package = 'git' if /opensuse|sles/.match?(host['platform'])
57
55
 
58
- if host['platform'] =~ /solaris-11/
56
+ if host['platform'].include?('solaris-11')
59
57
  logger.debug("#{package} should be uninstalled on #{host}")
60
58
  host.uninstall_package(package)
61
59
  assert_equal(false, host.check_for_package(package), "'#{package}' should not be installed")
@@ -66,15 +64,15 @@ hosts.each do |host|
66
64
  cmdline_args = ''
67
65
  # Newer vmpooler hosts created by Packer templates, and running Cygwin 2.4,
68
66
  # must have these switches passed
69
- cmdline_args = '--local-install --download' if (host['platform'] =~ /windows/ and host.is_cygwin?)
67
+ cmdline_args = '--local-install --download' if (host['platform'].include?('windows') and host.is_cygwin?)
70
68
  host.install_package(package, cmdline_args)
71
69
  assert(host.check_for_package(package), "'#{package}' should be installed")
72
70
 
73
71
  # windows does not support uninstall_package
74
- unless host['platform'] =~ /windows/
72
+ unless host['platform'].include?('windows')
75
73
  logger.debug("#{package} should be uninstalled on #{host}")
76
74
  host.uninstall_package(package)
77
- if host['platform'] =~ /debian/
75
+ if host['platform'].include?('debian')
78
76
  assert_equal(false, host.check_for_command(package), "'#{package}' should not be installed or available")
79
77
  else
80
78
  assert_equal(false, host.check_for_package(package), "'#{package}' should not be installed")
@@ -16,9 +16,9 @@ def clean_file(host, file)
16
16
  end
17
17
 
18
18
  def pkg_file(host, pkg_name)
19
- if host['platform'] =~ /debian|ubuntu/
19
+ if /debian|ubuntu/.match?(host['platform'])
20
20
  "/etc/apt/sources.list.d/#{pkg_name}.list"
21
- elsif host['platform'] =~ /el/
21
+ elsif host['platform'].include?('el')
22
22
  "/etc/yum.repos.d/#{pkg_name}.repo"
23
23
  else
24
24
  nil
@@ -33,7 +33,7 @@ end
33
33
  step '#deploy_apt_repo : deploy puppet-server nightly repo'
34
34
  hosts.each do |host|
35
35
 
36
- if host['platform'] =~ /debian|ubuntu/
36
+ if /debian|ubuntu/.match?(host['platform'])
37
37
  clean_file(host, pkg_name)
38
38
  host.deploy_apt_repo(pkg_fixtures, pkg_name, 'latest')
39
39
  assert(host.file_exist?(pkg_file(host, pkg_name)), 'apt file should exist')
@@ -45,7 +45,7 @@ end
45
45
  step '#deploy_yum_repo : deploy puppet-server nightly repo'
46
46
  hosts.each do |host|
47
47
 
48
- if host['platform'] =~ /el/
48
+ if host['platform'].include?('el')
49
49
  clean_file(host, pkg_name)
50
50
  host.deploy_yum_repo(pkg_fixtures, pkg_name, 'latest')
51
51
  assert(host.file_exist?(pkg_file(host, pkg_name)), 'yum file should exist')
@@ -1,6 +1,6 @@
1
1
  test_name 'User Test' do
2
2
  step "#user_get: has an Administrator user on Windows" do
3
- hosts.select { |h| h['platform'] =~ /windows/ }.each do |host|
3
+ hosts.select { |h| h['platform'].include?('windows') }.each do |host|
4
4
  host.user_get('Administrator') do |result|
5
5
  refute_match(result.stdout, 'NET HELPMSG', 'Output indicates Administrator not found')
6
6
  end
@@ -8,7 +8,7 @@ test_name 'User Test' do
8
8
  end
9
9
 
10
10
  step "#user_get: should not have CaptainCaveman user on Windows" do
11
- hosts.select { |h| h['platform'] =~ /windows/ }.each do |host|
11
+ hosts.select { |h| h['platform'].include?('windows') }.each do |host|
12
12
  assert_raises Beaker::Host::CommandFailure do
13
13
  host.user_get('CaptainCaveman') { |result| }
14
14
  end
@@ -4,7 +4,7 @@ confine :except, :platform => /^windows|osx/
4
4
 
5
5
  step 'install arbitrary msi via url' do
6
6
  hosts.each do |host|
7
- if host['platform'] =~ /win/
7
+ if host['platform'].include?('win')
8
8
  # this should be implemented at the host/win/pkg.rb level someday
9
9
  generic_install_msi_on(host, 'https://releases.hashicorp.com/vagrant/1.8.4/vagrant_1.8.4.msi', {}, {:debug => true})
10
10
  end
@@ -13,7 +13,7 @@ end
13
13
 
14
14
  step 'install arbitrary dmg via url' do
15
15
  hosts.each do |host|
16
- if host['platform'] =~ /osx/
16
+ if host['platform'].include?('osx')
17
17
  host.generic_install_dmg('https://releases.hashicorp.com/vagrant/1.8.4/vagrant_1.8.4.dmg', 'Vagrant', 'Vagrant.pkg')
18
18
  end
19
19
  end
data/beaker.gemspec CHANGED
@@ -21,31 +21,31 @@ Gem::Specification.new do |s|
21
21
  s.required_ruby_version = Gem::Requirement.new('>= 2.4')
22
22
 
23
23
  # Testing dependencies
24
- s.add_development_dependency 'rspec', '~> 3.0'
25
- s.add_development_dependency 'rspec-its'
26
24
  s.add_development_dependency 'fakefs', '~> 1.0'
27
25
  s.add_development_dependency 'rake', '~> 13.0'
26
+ s.add_development_dependency 'rspec', '~> 3.0'
27
+ s.add_development_dependency 'rspec-its'
28
28
 
29
29
  # Documentation dependencies
30
30
  s.add_development_dependency 'yard', '~> 0.9.11'
31
31
 
32
32
  # Run time dependencies
33
- s.add_runtime_dependency 'minitest', '~> 5.4'
34
33
  s.add_runtime_dependency 'minitar', '~> 0.6'
34
+ s.add_runtime_dependency 'minitest', '~> 5.4'
35
35
  s.add_runtime_dependency 'rexml'
36
36
 
37
- s.add_runtime_dependency 'hocon', '~> 1.0'
38
- s.add_runtime_dependency 'net-ssh', '>= 5.0'
39
37
  s.add_runtime_dependency 'ed25519', '~> 1.0' # net-ssh compatibility with ed25519 keys
40
- s.add_runtime_dependency 'net-scp', '>= 1.2', '< 4.0'
38
+ s.add_runtime_dependency 'hocon', '~> 1.0'
41
39
  s.add_runtime_dependency 'inifile', '~> 3.0'
40
+ s.add_runtime_dependency 'net-scp', '>= 1.2', '< 5.0'
41
+ s.add_runtime_dependency 'net-ssh', '>= 5.0'
42
42
 
43
- s.add_runtime_dependency 'rsync', '~> 1.0.9'
44
- s.add_runtime_dependency 'open_uri_redirections', '~> 0.2.1'
45
43
  s.add_runtime_dependency 'in-parallel', '~> 0.1'
44
+ s.add_runtime_dependency 'open_uri_redirections', '~> 0.2.1'
45
+ s.add_runtime_dependency 'rsync', '~> 1.0.9'
46
46
  s.add_runtime_dependency 'thor', ['>= 1.0.1', '< 2.0']
47
47
 
48
48
  # Run time dependencies that are Beaker libraries
49
- s.add_runtime_dependency 'stringify-hash', '~> 0.0'
50
49
  s.add_runtime_dependency 'beaker-hostgenerator'
50
+ s.add_runtime_dependency 'stringify-hash', '~> 0.0'
51
51
  end
@@ -57,7 +57,7 @@ test_name 'The source attribute' do
57
57
  target_file_on_nix = '/tmp/source_attr_test'
58
58
  teardown do
59
59
  hosts.each do |host|
60
- on(host, "rm #{target_file_on_nix}", :accept_all_exit_codes => true) unless host['platform'] =~ /^win/
60
+ on(host, "rm #{target_file_on_nix}", :accept_all_exit_codes => true) unless host['platform'].start_with('win')
61
61
  end
62
62
  end
63
63
  ...
@@ -33,7 +33,7 @@ Here's a test file that exercises different ways of running commands on Beaker h
33
33
  ```
34
34
  hosts.each do |h|
35
35
  on h, "echo hello"
36
- if h['platform'] =~ /windows/
36
+ if h['platform'].include?('windows')
37
37
  scp_to h, "beaker.gemspec", "/cygdrive/c/Documents\ and\ Settings/All\ Users/Application\ Data/"
38
38
  end
39
39
  on(h, "echo test block") do |result|
@@ -4,9 +4,9 @@ In order to adjust the beaker version used without commiting a change to a Gemfi
4
4
 
5
5
  ```ruby
6
6
  def location_for(place, fake_version = nil)
7
- if place =~ /^(git[:@][^#]*)#(.*)/
7
+ if /^(git[:@][^#]*)#(.*)/.match?(place)
8
8
  [fake_version, { :git => $1, :branch => $2, :require => false }].compact
9
- elsif place =~ /^file:\/\/(.*)/
9
+ elsif /^file:\/\/(.*)/.match?(place)
10
10
  ['>= 0', { :path => File.expand_path($1), :require => false }]
11
11
  else
12
12
  [place, { :require => false }]
data/lib/beaker/cli.rb CHANGED
@@ -104,12 +104,10 @@ module Beaker
104
104
  end
105
105
 
106
106
  # Setup perf monitoring if needed
107
- if @options[:collect_perf_data].to_s =~ /(aggressive)|(normal)/
107
+ if /(aggressive)|(normal)/.match?(@options[:collect_perf_data].to_s)
108
108
  @perf = Beaker::Perf.new( @hosts, @options )
109
109
  end
110
110
 
111
- errored = false
112
-
113
111
  #pre acceptance phase
114
112
  run_suite(:pre_suite, :fast)
115
113
 
@@ -120,7 +118,7 @@ module Beaker
120
118
  rescue => e
121
119
  #post acceptance on failure
122
120
  #run post-suite if we are in fail-slow mode
123
- if @options[:fail_mode].to_s =~ /slow/
121
+ if @options[:fail_mode].to_s.include?('slow')
124
122
  run_suite(:post_suite)
125
123
  @perf.print_perf_info if defined? @perf
126
124
  end
@@ -140,7 +138,7 @@ module Beaker
140
138
  end
141
139
 
142
140
  #cleanup on error
143
- if @options[:preserve_hosts].to_s =~ /(never)|(onpass)/
141
+ if /(never)|(onpass)/.match?(@options[:preserve_hosts].to_s)
144
142
  @logger.notify "Cleanup: cleaning up after failed run"
145
143
  if @network_manager
146
144
  @network_manager.cleanup
@@ -163,7 +161,7 @@ module Beaker
163
161
  end
164
162
 
165
163
  #cleanup on success
166
- if @options[:preserve_hosts].to_s =~ /(never)|(onfail)/
164
+ if /(never)|(onfail)/.match?(@options[:preserve_hosts].to_s)
167
165
  @logger.notify "Cleanup: cleaning up after successful run"
168
166
  if @network_manager
169
167
  @network_manager.cleanup
@@ -184,7 +182,7 @@ module Beaker
184
182
  # continue to execute tests.
185
183
  def run_suite(suite_name, failure_strategy = nil)
186
184
  if (@options[suite_name].empty?)
187
- @logger.notify("No tests to run for suite '#{suite_name.to_s}'")
185
+ @logger.notify("No tests to run for suite '#{suite_name}'")
188
186
  return
189
187
  end
190
188
  Beaker::TestSuite.new(
@@ -225,7 +223,7 @@ module Beaker
225
223
  hosts_yaml['HOSTS'] = combined_instance_and_options_hosts
226
224
  hosts_yaml['CONFIG'] = Beaker::Options::OptionsHash.new.merge(hosts_yaml['CONFIG'] || {})
227
225
  # save the rest of the options, excepting the HOSTS that we have already processed
228
- hosts_yaml['CONFIG'] = hosts_yaml['CONFIG'].merge(@options.reject{ |k,v| k =~ dontpreserve })
226
+ hosts_yaml['CONFIG'] = hosts_yaml['CONFIG'].merge(@options.reject{ |k,_v| dontpreserve.match?(k) })
229
227
  # remove copy of HOSTS information
230
228
  hosts_yaml['CONFIG']['provision'] = false
231
229
  File.open(preserved_hosts_filename, 'w') do |file|
@@ -76,7 +76,7 @@ module Beaker
76
76
  append_commands = host.append_commands( cmd, ac, :cmd_exe => @cmdexe )
77
77
 
78
78
  # This will cause things like `puppet -t -v agent` which is maybe bad.
79
- if host[:platform] =~ /cisco_ios_xr/
79
+ if host[:platform]&.include?('cisco_ios_xr')
80
80
  cmd_line_array = [prepend_commands, env_string, cmd, options_string, args_string, append_commands]
81
81
  else
82
82
  cmd_line_array = [env_string, prepend_commands, cmd, options_string, args_string, append_commands]
@@ -141,7 +141,7 @@ module Beaker
141
141
  end
142
142
 
143
143
  class HostCommand < Command
144
- def cmd_line host
144
+ def cmd_line _host
145
145
  eval "\"#{@command}\""
146
146
  end
147
147
  end
@@ -162,7 +162,7 @@ module Beaker
162
162
  # @return a new {SedCommand} object
163
163
  def initialize platform, expression, filename, opts = {}
164
164
  command = "sed -i -e \"#{expression}\" #{filename}"
165
- if platform =~ /solaris|aix|osx|openbsd/
165
+ if /solaris|aix|osx|openbsd/.match?(platform)
166
166
  command.slice! '-i '
167
167
  temp_file = opts[:temp_file] ? opts[:temp_file] : "#{filename}.tmp"
168
168
  command << " > #{temp_file} && mv #{temp_file} #{filename} && rm -f #{temp_file}"
@@ -10,7 +10,7 @@ module Beaker
10
10
  # +assertions+. This is not provided by Assertions and must be
11
11
  # provided by the thing including Assertions. See Minitest::Runnable
12
12
  # for an example.
13
- attr_accessor :assertions
13
+ attr_writer :assertions
14
14
  def assertions
15
15
  @assertions || 0
16
16
  end
@@ -27,7 +27,7 @@ module Beaker
27
27
  #
28
28
  # @api private
29
29
  # @return [String] Stdout from command execution
30
- def execute(command, options={}, &block)
30
+ def execute(command, options={})
31
31
  cmd_create_options = {}
32
32
  exec_opts = options.dup
33
33
  cmd_create_options[:prepend_cmds] = exec_opts.delete(:prepend_cmds) || nil
@@ -24,7 +24,7 @@ module Beaker
24
24
  # +assertions+. This is not provided by Assertions and must be
25
25
  # provided by the thing including Assertions. See Minitest::Runnable
26
26
  # for an example.
27
- attr_accessor :assertions
27
+ attr_writer :assertions
28
28
  def assertions
29
29
  @assertions || 0
30
30
  end
@@ -53,7 +53,7 @@ module Beaker
53
53
  #
54
54
  # @raise ArgumentError if arguments are missing or incorrect.
55
55
  # @return nil
56
- def hocon_file_edit_on(hosts, filename, &block)
56
+ def hocon_file_edit_on(hosts, filename)
57
57
  if not block_given?
58
58
  msg = 'DSL method `hocon_file_edit_on` provides a given block'
59
59
  msg << ' a hocon file to edit. No block was provided.'
@@ -80,7 +80,7 @@ module Beaker
80
80
  # doc.set_value('c.d', '[6, 2, 73, 4, 45]')
81
81
  # end
82
82
  #
83
- def hocon_file_edit_in_place_on(hosts, filename, &block)
83
+ def hocon_file_edit_in_place_on(hosts, filename)
84
84
  hocon_file_edit_on(hosts, filename) do |host, doc|
85
85
  content_doc = yield host, doc
86
86
  create_remote_file(host, filename, content_doc.render)