Skip to content

Commit f617252

Browse files
committed
Simplify test helpers for running shell commands
Flattening the input is not necessarily since no caller calls us with anything which needs to be flattened.
1 parent 353775e commit f617252

1 file changed

Lines changed: 2 additions & 14 deletions

File tree

spec/helpers.rb

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,7 @@ def quotelist( *args )
165165
### Run the specified command +cmd+ with system(), failing if the execution
166166
### fails.
167167
def run( *cmd )
168-
cmd.flatten!
169-
170-
if cmd.length > 1
171-
trace( quotelist(*cmd) )
172-
else
173-
trace( cmd )
174-
end
168+
trace(cmd.length == 1 ? cmd.first : quotelist(*cmd))
175169

176170
system( *cmd )
177171
raise "Command failed: [%s]" % [cmd.join(' ')] unless $?.success?
@@ -180,13 +174,7 @@ def run( *cmd )
180174
### Run the specified command +cmd+ after redirecting stdout and stderr to the specified
181175
### +logpath+, failing if the execution fails.
182176
def log_and_run( logpath, *cmd )
183-
cmd.flatten!
184-
185-
if cmd.length > 1
186-
trace( quotelist(*cmd) )
187-
else
188-
trace( cmd )
189-
end
177+
trace(cmd.length == 1 ? cmd.first : quotelist(*cmd))
190178

191179
# Eliminate the noise of creating/tearing down the database by
192180
# redirecting STDERR/STDOUT to a logfile

0 commit comments

Comments
 (0)