Merge pull request #9107 from chrisroberts/f-wsl-version-check
Check for vagrant.exe path before validating versions
This commit is contained in:
commit
fb4a1bf8e5
|
@ -447,6 +447,7 @@ module Vagrant
|
||||||
# are the same. Raise error if they do not match.
|
# are the same. Raise error if they do not match.
|
||||||
def wsl_validate_matching_vagrant_versions!
|
def wsl_validate_matching_vagrant_versions!
|
||||||
valid = false
|
valid = false
|
||||||
|
if Util::Which.which("vagrant.exe")
|
||||||
result = Util::Subprocess.execute("vagrant.exe", "version")
|
result = Util::Subprocess.execute("vagrant.exe", "version")
|
||||||
if result.exit_code == 0
|
if result.exit_code == 0
|
||||||
windows_version = result.stdout.match(/Installed Version: (?<version>[\w.-]+)/)
|
windows_version = result.stdout.match(/Installed Version: (?<version>[\w.-]+)/)
|
||||||
|
@ -461,6 +462,7 @@ module Vagrant
|
||||||
windows_version: windows_version || "unknown"
|
windows_version: windows_version || "unknown"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# systemd is in use
|
# systemd is in use
|
||||||
def systemd?
|
def systemd?
|
||||||
|
|
|
@ -182,4 +182,36 @@ describe Vagrant::Util::Platform do
|
||||||
expect(subject.systemd?).to be_falsey
|
expect(subject.systemd?).to be_falsey
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe ".wsl_validate_matching_vagrant_versions!" do
|
||||||
|
let(:exe_version){ Vagrant::VERSION.to_s }
|
||||||
|
|
||||||
|
before do
|
||||||
|
allow(Vagrant::Util::Which).to receive(:which).and_return(true)
|
||||||
|
allow(Vagrant::Util::Subprocess).to receive(:execute).with("vagrant.exe", "version").
|
||||||
|
and_return(double(exit_code: 0, stdout: "Installed Version: #{exe_version}"))
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not raise an error" do
|
||||||
|
Vagrant::Util::Platform.wsl_validate_matching_vagrant_versions!
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when windows vagrant.exe is not installed" do
|
||||||
|
before{ expect(Vagrant::Util::Which).to receive(:which).with("vagrant.exe").and_return(nil) }
|
||||||
|
|
||||||
|
it "should not raise an error" do
|
||||||
|
Vagrant::Util::Platform.wsl_validate_matching_vagrant_versions!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when versions do not match" do
|
||||||
|
let(:exe_version){ "1.9.9" }
|
||||||
|
|
||||||
|
it "should raise an error" do
|
||||||
|
expect {
|
||||||
|
Vagrant::Util::Platform.wsl_validate_matching_vagrant_versions!
|
||||||
|
}.to raise_error(Vagrant::Errors::WSLVagrantVersionMismatch)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue