Merge pull request #10938 from andersk/virtualbox-usable
virtualbox: Fix usability test to reject bad installs without crashing
This commit is contained in:
commit
96e275451c
|
@ -8,9 +8,10 @@ module VagrantPlugins
|
|||
def self.installed?
|
||||
Driver::Meta.new
|
||||
true
|
||||
rescue Vagrant::Errors::VirtualBoxInvalidVersion
|
||||
return false
|
||||
rescue Vagrant::Errors::VirtualBoxNotDetected
|
||||
rescue Vagrant::Errors::VirtualBoxInvalidVersion,
|
||||
Vagrant::Errors::VirtualBoxNotDetected,
|
||||
Vagrant::Errors::VirtualBoxKernelModuleNotLoaded,
|
||||
Vagrant::Errors::VirtualBoxInstallIncomplete
|
||||
return false
|
||||
end
|
||||
|
||||
|
@ -19,10 +20,10 @@ module VagrantPlugins
|
|||
# version and all that, which checks for VirtualBox being present
|
||||
Driver::Meta.new
|
||||
true
|
||||
rescue Vagrant::Errors::VirtualBoxInvalidVersion
|
||||
raise if raise_error
|
||||
return false
|
||||
rescue Vagrant::Errors::VirtualBoxNotDetected
|
||||
rescue Vagrant::Errors::VirtualBoxInvalidVersion,
|
||||
Vagrant::Errors::VirtualBoxNotDetected,
|
||||
Vagrant::Errors::VirtualBoxKernelModuleNotLoaded,
|
||||
Vagrant::Errors::VirtualBoxInstallIncomplete
|
||||
raise if raise_error
|
||||
return false
|
||||
end
|
||||
|
|
|
@ -47,6 +47,22 @@ describe VagrantPlugins::ProviderVirtualBox::Provider do
|
|||
expect { subject.usable?(true) }.
|
||||
to raise_error(Vagrant::Errors::VirtualBoxInvalidVersion)
|
||||
end
|
||||
|
||||
it "raises an exception if virtualbox kernel module is not loaded" do
|
||||
allow(VagrantPlugins::ProviderVirtualBox::Driver::Meta).to receive(:new).
|
||||
and_raise(Vagrant::Errors::VirtualBoxKernelModuleNotLoaded)
|
||||
|
||||
expect { subject.usable?(true) }.
|
||||
to raise_error(Vagrant::Errors::VirtualBoxKernelModuleNotLoaded)
|
||||
end
|
||||
|
||||
it "raises an exception if virtualbox installation is incomplete" do
|
||||
allow(VagrantPlugins::ProviderVirtualBox::Driver::Meta).to receive(:new).
|
||||
and_raise(Vagrant::Errors::VirtualBoxInstallIncomplete)
|
||||
|
||||
expect { subject.usable?(true) }.
|
||||
to raise_error(Vagrant::Errors::VirtualBoxInstallIncomplete)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#driver" do
|
||||
|
|
Loading…
Reference in New Issue