Retry the BSD#nfs? call at least 10 times if a weird TypeError is raised
This commit is contained in:
parent
f9f59282f4
commit
302bc348d3
|
@ -5,10 +5,16 @@ module Vagrant
|
||||||
include Util
|
include Util
|
||||||
|
|
||||||
def nfs?
|
def nfs?
|
||||||
system("which nfsd > /dev/null 2>&1")
|
tries = 10
|
||||||
$?.to_i == 0
|
begin
|
||||||
rescue TypeError
|
system("which nfsd > /dev/null 2>&1")
|
||||||
false
|
rescue TypeError
|
||||||
|
tries -= 1
|
||||||
|
retry if tries > 0
|
||||||
|
|
||||||
|
# Hopefully this point isn't reached
|
||||||
|
raise
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def nfs_export(ip, folders)
|
def nfs_export(ip, folders)
|
||||||
|
|
|
@ -12,26 +12,20 @@ class BSDHostTest < Test::Unit::TestCase
|
||||||
|
|
||||||
context "supporting nfs check" do
|
context "supporting nfs check" do
|
||||||
should "support NFS" do
|
should "support NFS" do
|
||||||
@instance.expects(:system).with() do |cmd|
|
@instance.expects(:system).returns(true)
|
||||||
`which which`
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
assert @instance.nfs?
|
assert @instance.nfs?
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not support NFS if nfsd is not found" do
|
should "not support NFS if nfsd is not found" do
|
||||||
@instance.expects(:system).with() do |cmd|
|
@instance.expects(:system).returns(false)
|
||||||
`which thisshouldnoteverneverexist`
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
assert !@instance.nfs?
|
assert !@instance.nfs?
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not support NFS if an error is raised" do
|
should "retry until a boolean is returned" do
|
||||||
@instance.expects(:system).raises(TypeError.new("foo"))
|
seq = sequence("seq")
|
||||||
assert !@instance.nfs?
|
@instance.expects(:system).in_sequence(seq).raises(TypeError.new("foo"))
|
||||||
|
@instance.expects(:system).in_sequence(seq).returns(true)
|
||||||
|
assert @instance.nfs?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
||||||
|
|
||||||
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
||||||
s.authors = ["Mitchell Hashimoto", "John Bender"]
|
s.authors = ["Mitchell Hashimoto", "John Bender"]
|
||||||
s.date = %q{2010-07-15}
|
s.date = %q{2010-07-16}
|
||||||
s.default_executable = %q{vagrant}
|
s.default_executable = %q{vagrant}
|
||||||
s.description = %q{Vagrant is a tool for building and distributing virtualized development environments.}
|
s.description = %q{Vagrant is a tool for building and distributing virtualized development environments.}
|
||||||
s.email = ["mitchell.hashimoto@gmail.com", "john.m.bender@gmail.com"]
|
s.email = ["mitchell.hashimoto@gmail.com", "john.m.bender@gmail.com"]
|
||||||
|
|
Loading…
Reference in New Issue