Merge pull request #162 from avokhmin/master

#157: FetchIpFromDnsmasqLeases returns []
This commit is contained in:
Fabio Rehm 2013-10-12 11:55:30 -07:00
commit 86be628cf2
3 changed files with 9 additions and 4 deletions

View file

@ -119,7 +119,7 @@ module Vagrant
def supports_attach_with_namespaces? def supports_attach_with_namespaces?
unless defined?(@supports_attach_with_namespaces) unless defined?(@supports_attach_with_namespaces)
@supports_attach_with_namespaces = run(:attach, '-h', '2>&1').include?('--namespaces') @supports_attach_with_namespaces = run(:attach, '-h', :show_stderr => true).values.join.include?('--namespaces')
end end
return @supports_attach_with_namespaces return @supports_attach_with_namespaces

View file

@ -58,7 +58,12 @@ module Vagrant
# Return the output, making sure to replace any Windows-style # Return the output, making sure to replace any Windows-style
# newlines with Unix-style. # newlines with Unix-style.
r.stdout.gsub("\r\n", "\n") stdout = r.stdout.gsub("\r\n", "\n")
if opts[:show_stderr]
{ :stdout => stdout, :stderr => r.stderr.gsub("\r\n", "\n") }
else
stdout
end
end end
def raw(*command, &block) def raw(*command, &block)

View file

@ -146,13 +146,13 @@ describe Vagrant::LXC::Driver::CLI do
end end
it 'supports a "namespaces" parameter' do it 'supports a "namespaces" parameter' do
subject.stub(:run).with(:attach, '-h', '2>&1').and_return('--namespaces') subject.stub(:run).with(:attach, '-h', :show_stderr => true).and_return({:stdout => '', :stderr => '--namespaces'})
subject.attach *(command + [{namespaces: ['network', 'mount']}]) subject.attach *(command + [{namespaces: ['network', 'mount']}])
subject.should have_received(:run).with(:attach, '--name', name, '--namespaces', 'NETWORK|MOUNT', '--', *command) subject.should have_received(:run).with(:attach, '--name', name, '--namespaces', 'NETWORK|MOUNT', '--', *command)
end end
it 'raises a NamespacesNotSupported error if not supported' do it 'raises a NamespacesNotSupported error if not supported' do
subject.stub(:run).with(:attach, '-h', '2>&1').and_return('not supported') subject.stub(:run).with(:attach, '-h', :show_stderr => true).and_return({:stdout => '', :stderr => 'not supported'})
expect { expect {
subject.attach *(command + [{namespaces: ['network', 'mount']}]) subject.attach *(command + [{namespaces: ['network', 'mount']}])
}.to raise_error(Vagrant::LXC::Errors::NamespacesNotSupported) }.to raise_error(Vagrant::LXC::Errors::NamespacesNotSupported)