Get rid of "VAGRANT_ENV" since that was just a hack. Log output location configurable now.
This commit is contained in:
parent
6c9c09c1b1
commit
03079d9fa6
|
@ -1,5 +1,7 @@
|
|||
Vagrant::Config.run do |config|
|
||||
# default config goes here
|
||||
config.vagrant.log_output = STDOUT
|
||||
|
||||
config.ssh.username = "vagrant"
|
||||
config.ssh.password = "vagrant"
|
||||
config.ssh.host = "localhost"
|
||||
|
|
|
@ -16,8 +16,4 @@ require 'vagrant/config'
|
|||
require 'vagrant/env'
|
||||
require 'vagrant/provisioning'
|
||||
require 'vagrant/ssh'
|
||||
require 'vagrant/vm'
|
||||
|
||||
# TODO: Make this configurable
|
||||
log_output = ENV['VAGRANT_ENV'] == 'test' ? nil : STDOUT
|
||||
VAGRANT_LOGGER = Vagrant::Logger.new(log_output)
|
||||
require 'vagrant/vm'
|
|
@ -24,6 +24,8 @@ module Vagrant
|
|||
config_runners.each do |block|
|
||||
block.call(config)
|
||||
end
|
||||
|
||||
config.loaded!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -74,16 +76,32 @@ module Vagrant
|
|||
attr_accessor :json
|
||||
end
|
||||
|
||||
class VagrantConfig < Base
|
||||
attr_accessor :log_output
|
||||
end
|
||||
|
||||
class Top < Base
|
||||
attr_accessor :dotfile_name
|
||||
attr_reader :ssh
|
||||
attr_reader :vm
|
||||
attr_reader :chef
|
||||
attr_reader :vagrant
|
||||
|
||||
def initialize
|
||||
@ssh = SSHConfig.new
|
||||
@vm = VMConfig.new
|
||||
@chef = ChefConfig.new
|
||||
@vagrant = VagrantConfig.new
|
||||
|
||||
@loaded = false
|
||||
end
|
||||
|
||||
def loaded?
|
||||
@loaded
|
||||
end
|
||||
|
||||
def loaded!
|
||||
@loaded = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,7 +26,7 @@ module Vagrant
|
|||
]
|
||||
|
||||
load_paths.each do |path|
|
||||
VAGRANT_LOGGER.info "Loading config from #{path}..."
|
||||
logger.info "Loading config from #{path}..."
|
||||
load path if File.exist?(path)
|
||||
end
|
||||
|
||||
|
|
|
@ -12,7 +12,12 @@ error
|
|||
end
|
||||
|
||||
def logger
|
||||
VAGRANT_LOGGER
|
||||
# TODO: Buffer messages until config is loaded, then output them?
|
||||
if Vagrant.config.loaded?
|
||||
@logger ||= Vagrant::Logger.new(Vagrant.config.vagrant.log_output)
|
||||
else
|
||||
Vagrant::Logger.new(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ error
|
|||
end
|
||||
end
|
||||
|
||||
def start
|
||||
def start(sleep_interval = 5)
|
||||
logger.info "Booting VM..."
|
||||
@vm.start(:headless, true)
|
||||
|
||||
|
@ -149,7 +149,7 @@ error
|
|||
return true
|
||||
end
|
||||
|
||||
sleep 5 unless ENV['VAGRANT_ENV'] == 'test'
|
||||
sleep sleep_interval
|
||||
end
|
||||
|
||||
logger.info "Failed to connect to VM! Failed to boot?"
|
||||
|
|
|
@ -7,9 +7,6 @@ rescue LoadError
|
|||
Bundler.setup
|
||||
end
|
||||
|
||||
# This silences logger output
|
||||
ENV['VAGRANT_ENV'] = 'test'
|
||||
|
||||
# ruby-debug, not necessary, but useful if we have it
|
||||
begin
|
||||
require 'ruby-debug'
|
||||
|
|
|
@ -35,12 +35,19 @@ class ConfigTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
should "run the blocks with the same config object" do
|
||||
config = mock("config")
|
||||
config.expects(:foo).twice
|
||||
Vagrant::Config.stubs(:config).returns(config)
|
||||
Vagrant::Config.run { |config| config.foo }
|
||||
Vagrant::Config.run { |config| config.foo }
|
||||
Vagrant::Config.run { |config| assert config }
|
||||
Vagrant::Config.run { |config| assert config }
|
||||
Vagrant::Config.execute!
|
||||
end
|
||||
|
||||
should "not be loaded, initially" do
|
||||
assert !Vagrant::Config.config.loaded?
|
||||
end
|
||||
|
||||
should "be loaded after running" do
|
||||
Vagrant::Config.run {}
|
||||
Vagrant::Config.execute!
|
||||
assert Vagrant::Config.config.loaded?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -82,19 +82,19 @@ class VMTest < Test::Unit::TestCase
|
|||
should "start the VM in headless mode" do
|
||||
@mock_vm.expects(:start).with(:headless, true).once
|
||||
Vagrant::SSH.expects(:up?).once.returns(true)
|
||||
@vm.start
|
||||
@vm.start(0)
|
||||
end
|
||||
|
||||
should "repeatedly ping the SSH port and return false with no response" do
|
||||
seq = sequence('pings')
|
||||
Vagrant::SSH.expects(:up?).times(Vagrant.config[:ssh][:max_tries].to_i - 1).returns(false).in_sequence(seq)
|
||||
Vagrant::SSH.expects(:up?).once.returns(true).in_sequence(seq)
|
||||
assert @vm.start
|
||||
assert @vm.start(0)
|
||||
end
|
||||
|
||||
should "ping the max number of times then just return" do
|
||||
Vagrant::SSH.expects(:up?).times(Vagrant.config[:ssh][:max_tries].to_i).returns(false)
|
||||
assert !@vm.start
|
||||
assert !@vm.start(0)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue