Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a check on windows part, to exec commands on a non cygwin environment #77

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions lib/beaker-rspec/helpers/serverspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,20 @@ class BeakerCygwin < BeakerBase
def run_command(cmd, opt = {})
node = get_working_node
script = create_script(cmd)
on node, "rm -f script.ps1"
#when node is not cygwin rm -rf will fail so lets use native del instead
#There should be a better way to do this, but for now , this works
if node.is_cygwin?
delete_command = "rm -rf"
redirection = "< /dev/null"
else
delete_command = "del"
redirection = "< NUL"
end
on node, "#{delete_command} script.ps1"
create_remote_file(node, 'script.ps1', script)
# cygwin support /dev/null, if running from winrm would use < NULL
ret = ssh_exec!(node, "powershell.exe -File script.ps1 < /dev/null")
#When using cmd on a pswindows node redirection should be set to < NUl
#when using a cygwing one, /dev/null should be fine
ret = ssh_exec!(node, "powershell.exe -File script.ps1 #{redirection}")

if @example
@example.metadata[:command] = script
Expand Down