Skip to content

Commit

Permalink
(FACT-2580) Added rm_rf, mkdir_p and mv for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-miclea committed May 18, 2020
1 parent 8532fbe commit 54b35b7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/beaker/host/unix/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def get_ip
# @param [String] dir The directory structure to create on the host
# @return [Boolean] True, if directory construction succeeded, otherwise False
def mkdir_p dir
cmd = "mkdir -p #{dir}"
cmd = "mkdir -p \"#{dir}\""
result = exec(Beaker::Command.new(cmd), :acceptable_exit_codes => [0, 1])
result.exit_code == 0
end
Expand All @@ -144,7 +144,7 @@ def rm_rf path
# @param [Boolean] rm Remove the destination prior to move
def mv orig, dest, rm=true
rm_rf dest unless !rm
execute("mv #{orig} #{dest}")
execute("mv \"#{orig}\" \"#{dest}\"")
end

# Attempt to ping the provided target hostname
Expand Down
4 changes: 2 additions & 2 deletions spec/beaker/host/unix/exec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ def to_s

it 'rm first' do
expect( instance ).to receive(:execute).with("rm -rf #{destination}").and_return(0)
expect( instance ).to receive(:execute).with("mv #{origin} #{destination}").and_return(0)
expect( instance ).to receive(:execute).with("mv \"#{origin}\" \"#{destination}\"").and_return(0)
expect( instance.mv(origin, destination) ).to be === 0

end

it 'does not rm' do
expect( instance ).to receive(:execute).with("mv #{origin} #{destination}").and_return(0)
expect( instance ).to receive(:execute).with("mv \"#{origin}\" \"#{destination}\"").and_return(0)
expect( instance.mv(origin, destination, false) ).to be === 0
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/beaker/host_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ module Beaker
allow( result ).to receive( :exit_code ).and_return( 0 )
allow( host ).to receive( :exec ).and_return( result )

expect( Beaker::Command ).to receive(:new).with("mkdir -p test/test/test")
expect( Beaker::Command ).to receive(:new).with("mkdir -p \"test/test/test\"")
expect( host.mkdir_p('test/test/test') ).to be == true

end
Expand All @@ -337,7 +337,7 @@ module Beaker
allow( result ).to receive( :exit_code ).and_return( 0 )
allow( host ).to receive( :exec ).and_return( result )

expect( Beaker::Command ).to receive(:new).with("mkdir -p test/test/test")
expect( Beaker::Command ).to receive(:new).with("mkdir -p \"test/test/test\"")
expect( host.mkdir_p('test/test/test') ).to be == true

end
Expand Down

0 comments on commit 54b35b7

Please sign in to comment.