test-kitchen 2.2.5 → 2.3.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.
@@ -50,7 +50,7 @@ module Kitchen
50
50
  # (see Base#run_command)
51
51
  def run_command
52
52
  cmd = sudo(config[:chef_solo_path]).dup
53
- .tap { |str| str.insert(0, "& ") if powershell_shell? }
53
+ .tap { |str| str.insert(0, "& ") if powershell_shell? }
54
54
 
55
55
  chef_cmd(cmd)
56
56
  end
@@ -67,7 +67,7 @@ module Kitchen
67
67
  "--log_level #{config[:log_level]}",
68
68
  "--force-formatter",
69
69
  "--no-color",
70
- "--json-attributes #{remote_path_join(config[:root_path], 'dna.json')}",
70
+ "--json-attributes #{remote_path_join(config[:root_path], "dna.json")}",
71
71
  ]
72
72
  args << "--logfile #{config[:log_file]}" if config[:log_file]
73
73
  args << "--profile-ruby" if config[:profile_ruby]
@@ -128,7 +128,7 @@ module Kitchen
128
128
  debug("Using a dummy validation.pem")
129
129
 
130
130
  source = File.join(File.dirname(__FILE__),
131
- %w{.. .. .. support dummy-validation.pem})
131
+ %w{.. .. .. support dummy-validation.pem})
132
132
  FileUtils.cp(source, File.join(sandbox_path, "validation.pem"))
133
133
  end
134
134
 
@@ -139,7 +139,7 @@ module Kitchen
139
139
  # @api private
140
140
  def shim_command
141
141
  ruby = remote_path_join(config[:ruby_bindir], "ruby")
142
- .tap { |path| path.concat(".exe") if windows_os? }
142
+ .tap { |path| path.concat(".exe") if windows_os? }
143
143
  shim = remote_path_join(config[:root_path], "chef-client-zero.rb")
144
144
 
145
145
  "#{chef_client_zero_env}\n#{sudo(ruby)} #{shim}"
@@ -58,6 +58,7 @@ module Kitchen
58
58
  # (see Base#init_command)
59
59
  def init_command
60
60
  return nil if config[:command]
61
+
61
62
  root = config[:root_path]
62
63
  data = remote_path_join(root, "data")
63
64
 
@@ -71,7 +72,7 @@ module Kitchen
71
72
  }
72
73
  POWERSHELL
73
74
  else
74
- "#{sudo('rm')} -rf #{data} ; mkdir -p #{root}"
75
+ "#{sudo("rm")} -rf #{data} ; mkdir -p #{root}"
75
76
  end
76
77
 
77
78
  prefix_command(wrap_shell_code(code))
@@ -97,6 +98,7 @@ module Kitchen
97
98
  def run_command
98
99
  return prefix_command(wrap_shell_code(config[:command])) if config[:command]
99
100
  return unless config[:script]
101
+
100
102
  script = remote_path_join(
101
103
  config[:root_path],
102
104
  File.basename(config[:script])
@@ -57,9 +57,9 @@ module Kitchen
57
57
  # @raise [Error] for all other unexpected exceptions
58
58
  def run_command(cmd, options = {})
59
59
  if options.fetch(:use_sudo, false)
60
- cmd = "#{options.fetch(:sudo_command, 'sudo -E')} #{cmd}"
60
+ cmd = "#{options.fetch(:sudo_command, "sudo -E")} #{cmd}"
61
61
  end
62
- subject = "[#{options.fetch(:log_subject, 'local')} command]"
62
+ subject = "[#{options.fetch(:log_subject, "local")} command]"
63
63
 
64
64
  debug("#{subject} BEGIN (#{cmd})")
65
65
  sh = Mixlib::ShellOut.new(cmd, shell_opts(options))
@@ -83,7 +83,7 @@ module Kitchen
83
83
  # @api private
84
84
  def shell_opts(options)
85
85
  filtered_opts = options.reject do |key, _value|
86
- [:use_sudo, :sudo_command, :log_subject, :quiet].include?(key)
86
+ %i{use_sudo sudo_command log_subject quiet}.include?(key)
87
87
  end
88
88
  { live_stream: logger, timeout: 60_000 }.merge(filtered_opts)
89
89
  end
@@ -154,9 +154,9 @@ module Kitchen
154
154
  args = %w{ -o UserKnownHostsFile=/dev/null }
155
155
  args += %w{ -o StrictHostKeyChecking=no }
156
156
  args += %w{ -o IdentitiesOnly=yes } if options[:keys]
157
- args += %W{ -o LogLevel=#{logger.debug? ? 'VERBOSE' : 'ERROR'} }
157
+ args += %W{ -o LogLevel=#{logger.debug? ? "VERBOSE" : "ERROR"} }
158
158
  if options.key?(:forward_agent)
159
- args += %W{ -o ForwardAgent=#{options[:forward_agent] ? 'yes' : 'no'} }
159
+ args += %W{ -o ForwardAgent=#{options[:forward_agent] ? "yes" : "no"} }
160
160
  end
161
161
  Array(options[:keys]).each { |ssh_key| args += %W{ -i #{ssh_key} } }
162
162
  args += %W{ -p #{port} }
@@ -40,6 +40,7 @@ module Kitchen
40
40
  # (see Base#execute)
41
41
  def execute(command)
42
42
  return if command.nil?
43
+
43
44
  run_command(command)
44
45
  end
45
46
 
@@ -134,6 +134,7 @@ module Kitchen
134
134
  # (see Base::Connection#execute)
135
135
  def execute(command)
136
136
  return if command.nil?
137
+
137
138
  logger.debug("[SSH] #{self} (#{command})")
138
139
  exit_code = execute_with_exit_code(command)
139
140
 
@@ -152,9 +153,9 @@ module Kitchen
152
153
  args = %w{ -o UserKnownHostsFile=/dev/null }
153
154
  args += %w{ -o StrictHostKeyChecking=no }
154
155
  args += %w{ -o IdentitiesOnly=yes } if options[:keys]
155
- args += %W{ -o LogLevel=#{logger.debug? ? 'VERBOSE' : 'ERROR'} }
156
+ args += %W{ -o LogLevel=#{logger.debug? ? "VERBOSE" : "ERROR"} }
156
157
  if options.key?(:forward_agent)
157
- args += %W{ -o ForwardAgent=#{options[:forward_agent] ? 'yes' : 'no'} }
158
+ args += %W{ -o ForwardAgent=#{options[:forward_agent] ? "yes" : "no"} }
158
159
  end
159
160
  if ssh_gateway
160
161
  gateway_command = "ssh -q #{ssh_gateway_username}@#{ssh_gateway} nc #{hostname} #{port}"
@@ -316,7 +317,7 @@ module Kitchen
316
317
  retry_connection(opts) do
317
318
  gateway_options = options.merge(port: ssh_gateway_port)
318
319
  Net::SSH::Gateway.new(ssh_gateway,
319
- ssh_gateway_username, gateway_options).ssh(hostname, username, options)
320
+ ssh_gateway_username, gateway_options).ssh(hostname, username, options)
320
321
  end
321
322
  end
322
323
 
@@ -103,6 +103,7 @@ module Kitchen
103
103
  # (see Base::Connection#execute)
104
104
  def execute(command)
105
105
  return if command.nil?
106
+
106
107
  logger.debug("[WinRM] #{self} (#{command})")
107
108
 
108
109
  exit_code, stderr = execute_with_exit_code(command)
@@ -129,7 +130,7 @@ module Kitchen
129
130
  login_command_for_linux
130
131
  else
131
132
  raise ActionFailed, "Remote login not supported in #{self.class} " \
132
- "from host OS '#{RbConfig::CONFIG['host_os']}'."
133
+ "from host OS '#{RbConfig::CONFIG["host_os"]}'."
133
134
  end
134
135
  end
135
136
 
@@ -165,6 +166,7 @@ module Kitchen
165
166
  rescue *RESCUE_EXCEPTIONS_ON_ESTABLISH => e
166
167
  retries ||= connection_retries.to_i
167
168
  raise e if (retries -= 1) < 0
169
+
168
170
  logger.debug("[WinRM] PING_COMMAND failed. Retrying...")
169
171
  logger.debug("#{e.class}::#{e.message}")
170
172
  sleep(connection_retry_sleep.to_i)
@@ -296,7 +298,7 @@ module Kitchen
296
298
  if error_regexp.match(stderr)
297
299
  stderr
298
300
  .split(error_regexp)[1..-2]
299
- .map! { |line| line.sub(/_x000D__x000A_<\/S>/, "").rstrip }
301
+ .map! { |line| line.sub(%r{_x000D__x000A_</S>}, "").rstrip }
300
302
  .each { |line| logger.warn(line) }
301
303
  else
302
304
  stderr
@@ -495,10 +497,10 @@ module Kitchen
495
497
  end
496
498
  rescue LoadError => e
497
499
  message = fail_to_load_gem_message(gem_name,
498
- spec_version)
500
+ spec_version)
499
501
  logger.fatal(message)
500
502
  raise UserError,
501
- "Could not load or activate #{gem_name}. (#{e.message})"
503
+ "Could not load or activate #{gem_name}. (#{e.message})"
502
504
  end
503
505
 
504
506
  def fail_to_load_gem_message(name, version = nil)
@@ -33,7 +33,7 @@ module Kitchen
33
33
  # @return [Integer] Logger::Severity constant value or nil if input is not
34
34
  # valid
35
35
  def self.to_logger_level(symbol)
36
- return nil unless [:debug, :info, :warn, :error, :fatal].include?(symbol)
36
+ return nil unless %i{debug info warn error fatal}.include?(symbol)
37
37
 
38
38
  Logger.const_get(symbol.to_s.upcase)
39
39
  end
@@ -141,7 +141,7 @@ module Kitchen
141
141
  # @return [String] a string representation of useful helper functions
142
142
  def self.shell_helpers
143
143
  IO.read(File.join(
144
- File.dirname(__FILE__), %w{.. .. support download_helpers.sh}
144
+ File.dirname(__FILE__), %w{.. .. support download_helpers.sh}
145
145
  ))
146
146
  end
147
147
 
@@ -164,7 +164,7 @@ module Kitchen
164
164
  def self.list_directory(path, include_dot: false, recurse: false)
165
165
  # Things (such as tests) are relying on this to not blow up if
166
166
  # the directory does not exist
167
- return [] if !Dir.exist?(path)
167
+ return [] unless Dir.exist?(path)
168
168
 
169
169
  Kitchen.mutex_chdir.synchronize do
170
170
  Dir.chdir(path) do
@@ -200,7 +200,7 @@ module Kitchen
200
200
  # @note Dir.chdir is applied to the process, thus it is not thread-safe
201
201
  # and must be synchronized.
202
202
  def self.safe_glob(path, pattern, *flags)
203
- return [] if !Dir.exist?(path)
203
+ return [] unless Dir.exist?(path)
204
204
 
205
205
  Kitchen.mutex_chdir.synchronize do
206
206
  Dir.chdir(path) do
@@ -130,8 +130,7 @@ module Kitchen
130
130
  # will be returned.
131
131
  #
132
132
  # @return [String] a command string
133
- def install_command
134
- end
133
+ def install_command; end
135
134
 
136
135
  # Generates a command string which will perform any data initialization
137
136
  # or configuration required after the verifier software is installed
@@ -139,8 +138,7 @@ module Kitchen
139
138
  # is required, then `nil` will be returned.
140
139
  #
141
140
  # @return [String] a command string
142
- def init_command
143
- end
141
+ def init_command; end
144
142
 
145
143
  # Generates a command string which will perform any commands or
146
144
  # configuration required just before the main verifier run command but
@@ -148,16 +146,14 @@ module Kitchen
148
146
  # required, then `nil` will be returned.
149
147
  #
150
148
  # @return [String] a command string
151
- def prepare_command
152
- end
149
+ def prepare_command; end
153
150
 
154
151
  # Generates a command string which will invoke the main verifier
155
152
  # command on the prepared instance. If no work is required, then `nil`
156
153
  # will be returned.
157
154
  #
158
155
  # @return [String] a command string
159
- def run_command
160
- end
156
+ def run_command; end
161
157
 
162
158
  # Returns the absolute path to the sandbox directory or raises an
163
159
  # exception if `#create_sandbox` has not yet been called.
@@ -71,7 +71,7 @@ module Kitchen
71
71
  return if local_suite_files.empty?
72
72
 
73
73
  cmd = sudo(config[:busser_bin]).dup
74
- .tap { |str| str.insert(0, "& ") if powershell_shell? }
74
+ .tap { |str| str.insert(0, "& ") if powershell_shell? }
75
75
 
76
76
  prefix_command(wrap_shell_code(Util.outdent!(<<-CMD)))
77
77
  #{busser_env}
@@ -94,7 +94,7 @@ module Kitchen
94
94
  return if local_suite_files.empty?
95
95
 
96
96
  cmd = sudo(config[:busser_bin]).dup
97
- .tap { |str| str.insert(0, "& ") if powershell_shell? }
97
+ .tap { |str| str.insert(0, "& ") if powershell_shell? }
98
98
 
99
99
  prefix_command(wrap_shell_code(Util.outdent!(<<-CMD)))
100
100
  #{busser_env}
@@ -199,7 +199,7 @@ module Kitchen
199
199
 
200
200
  def install_command_vars
201
201
  ruby = remote_path_join(config[:ruby_bindir], "ruby")
202
- .tap { |path| path.concat(".exe") if windows_os? }
202
+ .tap { |path| path.concat(".exe") if windows_os? }
203
203
  gem = remote_path_join(config[:ruby_bindir], "gem")
204
204
 
205
205
  [
@@ -17,5 +17,5 @@
17
17
  # limitations under the License.
18
18
 
19
19
  module Kitchen
20
- VERSION = "2.2.5".freeze
20
+ VERSION = "2.3.0".freeze
21
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-kitchen
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.5
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fletcher Nichol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-15 00:00:00.000000000 Z
11
+ date: 2019-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout