Skip to content

Commit

Permalink
Merge pull request #1834 from ekohl/simply
Browse files Browse the repository at this point in the history
Use more expressive APIs for shorter code
  • Loading branch information
ekohl authored Nov 22, 2023
2 parents eb56cdd + 4ac1fc5 commit b637031
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
6 changes: 3 additions & 3 deletions lib/beaker/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def execute!
end

# Setup perf monitoring if needed
@perf = Beaker::Perf.new(@hosts, @options) if /(aggressive)|(normal)/.match?(@options[:collect_perf_data].to_s)
@perf = Beaker::Perf.new(@hosts, @options) if /aggressive|normal/.match?(@options[:collect_perf_data].to_s)

# pre acceptance phase
run_suite(:pre_suite, :fast)
Expand Down Expand Up @@ -138,7 +138,7 @@ def execute!
end

# cleanup on error
if /(never)|(onpass)/.match?(@options[:preserve_hosts].to_s)
if /never|onpass/.match?(@options[:preserve_hosts].to_s)
@logger.notify "Cleanup: cleaning up after failed run"
@network_manager.cleanup if @network_manager
else
Expand All @@ -159,7 +159,7 @@ def execute!
end

# cleanup on success
if /(never)|(onfail)/.match?(@options[:preserve_hosts].to_s)
if /never|onfail/.match?(@options[:preserve_hosts].to_s)
@logger.notify "Cleanup: cleaning up after successful run"
@network_manager.cleanup if @network_manager
else
Expand Down
6 changes: 1 addition & 5 deletions lib/beaker/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,7 @@ def do_rsync_to from_path, to_path, opts = {}
# We enable achieve mode and compression
rsync_args << "-az"

user = if not self['user']
"root"
else
self['user']
end
user = self['user'] || 'root'
hostname_with_user = "#{user}@#{reachable_name}"

Rsync.host = hostname_with_user
Expand Down
4 changes: 1 addition & 3 deletions lib/beaker/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ def to_array
# @example Platform.new('debian-7-xxx').with_version_codename == 'debian-wheezy-xxx'
# @return [String] the platform string with the platform version represented as a codename
def with_version_codename
version_array = [@variant, @version, @arch]
version_array = [@variant, @codename, @arch] if @codename
return version_array.join('-')
[@variant, @codename || @version, @arch].join('-')
end

# Returns the platform string with the platform version as a number. If no conversion is necessary
Expand Down

0 comments on commit b637031

Please sign in to comment.