Merge pull request #11787 from fliam/fix-privileged-powershell-executable-on-wsl

Use the correct powershell executable for privileged commands
This commit is contained in:
Jeff Bonhag 2020-07-30 16:11:00 -04:00 committed by GitHub
commit f0f681716d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions

View File

@ -231,7 +231,7 @@ module Vagrant
"-PassThru -WindowStyle Hidden -Wait -Verb RunAs; if($p){ exit $p.ExitCode; }else{ exit 1 }"
cmd = [
"powershell",
executable,
"-NoLogo",
"-NoProfile",
"-NonInteractive",

View File

@ -281,4 +281,35 @@ describe Vagrant::Util::PowerShell do
end
end
describe ".powerup_command" do
let(:result) do
Vagrant::Util::Subprocess::Result.new( exit_code, stdout, stderr)
end
let(:exit_code){ 0 }
let(:stdout){ "" }
let(:stderr){ "" }
context "when the powershell executable is 'powershell'" do
before do
allow(described_class).to receive(:executable).and_return("powershell")
end
it "should use the 'powershell' executable" do
expect(Vagrant::Util::Subprocess).to receive(:execute).with("powershell", any_args).and_return(result)
described_class.powerup_command("run", [], [])
end
end
context "when the powershell executable is 'powershell.exe'" do
before do
allow(described_class).to receive(:executable).and_return("powershell.exe")
end
it "should use the 'powershell.exe' executable" do
expect(Vagrant::Util::Subprocess).to receive(:execute).with("powershell.exe", any_args).and_return(result)
described_class.powerup_command("run", [], [])
end
end
end
end