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
|
||||
|
||||
def nfs?
|
||||
tries = 10
|
||||
begin
|
||||
system("which nfsd > /dev/null 2>&1")
|
||||
$?.to_i == 0
|
||||
rescue TypeError
|
||||
false
|
||||
tries -= 1
|
||||
retry if tries > 0
|
||||
|
||||
# Hopefully this point isn't reached
|
||||
raise
|
||||
end
|
||||
end
|
||||
|
||||
def nfs_export(ip, folders)
|
||||
|
|
|
@ -12,26 +12,20 @@ class BSDHostTest < Test::Unit::TestCase
|
|||
|
||||
context "supporting nfs check" do
|
||||
should "support NFS" do
|
||||
@instance.expects(:system).with() do |cmd|
|
||||
`which which`
|
||||
true
|
||||
end
|
||||
|
||||
@instance.expects(:system).returns(true)
|
||||
assert @instance.nfs?
|
||||
end
|
||||
|
||||
should "not support NFS if nfsd is not found" do
|
||||
@instance.expects(:system).with() do |cmd|
|
||||
`which thisshouldnoteverneverexist`
|
||||
true
|
||||
end
|
||||
|
||||
@instance.expects(:system).returns(false)
|
||||
assert !@instance.nfs?
|
||||
end
|
||||
|
||||
should "not support NFS if an error is raised" do
|
||||
@instance.expects(:system).raises(TypeError.new("foo"))
|
||||
assert !@instance.nfs?
|
||||
should "retry until a boolean is returned" do
|
||||
seq = sequence("seq")
|
||||
@instance.expects(:system).in_sequence(seq).raises(TypeError.new("foo"))
|
||||
@instance.expects(:system).in_sequence(seq).returns(true)
|
||||
assert @instance.nfs?
|
||||
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.authors = ["Mitchell Hashimoto", "John Bender"]
|
||||
s.date = %q{2010-07-15}
|
||||
s.date = %q{2010-07-16}
|
||||
s.default_executable = %q{vagrant}
|
||||
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"]
|
||||
|
|
Loading…
Reference in New Issue