Remove unused code in Config
This commit is contained in:
parent
52a32820db
commit
ad5ecf1c7f
|
@ -1,4 +1,5 @@
|
|||
require 'vagrant/config/base'
|
||||
require 'vagrant/config/error_recorder'
|
||||
|
||||
module Vagrant
|
||||
# The config class is responsible for loading Vagrant configurations
|
||||
|
@ -35,7 +36,6 @@ module Vagrant
|
|||
config_object ||= config
|
||||
|
||||
run_procs!(config_object)
|
||||
config_object.loaded!
|
||||
config_object
|
||||
end
|
||||
end
|
||||
|
@ -89,23 +89,8 @@ module Vagrant
|
|||
instance_variable_set("@#{key}".to_sym, config)
|
||||
end
|
||||
|
||||
@loaded = false
|
||||
@env = env
|
||||
end
|
||||
|
||||
def loaded?
|
||||
@loaded
|
||||
end
|
||||
|
||||
def loaded!
|
||||
@loaded = true
|
||||
end
|
||||
|
||||
# Deep clones the entire configuration tree using the marshalling
|
||||
# trick. All subclasses must be able to marshal properly.
|
||||
def deep_clone
|
||||
Marshal.load(Marshal.dump(self))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,11 +31,7 @@ module Vagrant
|
|||
# instantiated, then the given environment will be used to
|
||||
# create a new logger.
|
||||
def singleton_logger(env=nil)
|
||||
if env && env.config && env.config.loaded?
|
||||
@@singleton_logger ||= PlainLogger.new(env.config.vagrant.log_output)
|
||||
else
|
||||
PlainLogger.new(nil)
|
||||
end
|
||||
@@singleton_logger ||= PlainLogger.new(env.config.vagrant.log_output)
|
||||
end
|
||||
|
||||
# Resets the singleton logger (only used for testing).
|
||||
|
|
|
@ -124,16 +124,6 @@ class ConfigTest < Test::Unit::TestCase
|
|||
@klass.execute!
|
||||
end
|
||||
|
||||
should "not be loaded, initially" do
|
||||
assert !@klass.config.loaded?
|
||||
end
|
||||
|
||||
should "be loaded after running" do
|
||||
@klass.run {}
|
||||
@klass.execute!
|
||||
assert @klass.config.loaded?
|
||||
end
|
||||
|
||||
should "return the configuration on execute!" do
|
||||
@klass.run {}
|
||||
result = @klass.execute!
|
||||
|
@ -198,40 +188,5 @@ class ConfigTest < Test::Unit::TestCase
|
|||
assert_equal instance, config.send(key)
|
||||
end
|
||||
end
|
||||
|
||||
context "loaded status" do
|
||||
setup do
|
||||
@top= @klass::Top.new
|
||||
end
|
||||
|
||||
should "not be loaded by default" do
|
||||
assert !@top.loaded?
|
||||
end
|
||||
|
||||
should "be loaded after calling loaded!" do
|
||||
@top.loaded!
|
||||
assert @top.loaded?
|
||||
end
|
||||
end
|
||||
|
||||
context "deep cloning" do
|
||||
class DeepCloneConfig < Vagrant::Config::Base
|
||||
attr_accessor :attribute
|
||||
end
|
||||
|
||||
setup do
|
||||
@klass::Top.configures :deep, DeepCloneConfig
|
||||
@top = @klass::Top.new
|
||||
@top.deep.attribute = [1,2,3]
|
||||
end
|
||||
|
||||
should "deep clone the object" do
|
||||
copy = @top.deep_clone
|
||||
copy.deep.attribute << 4
|
||||
assert_not_equal @top.deep.attribute, copy.deep.attribute
|
||||
assert_equal 3, @top.deep.attribute.length
|
||||
assert_equal 4, copy.deep.attribute.length
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,11 +12,6 @@ class ResourceLoggerUtilTest < Test::Unit::TestCase
|
|||
@result = mock("result")
|
||||
end
|
||||
|
||||
should "return a nil plain logger if no environment is given" do
|
||||
Vagrant::Util::PlainLogger.expects(:new).with(nil).returns(@result)
|
||||
assert_equal @result, @klass.singleton_logger
|
||||
end
|
||||
|
||||
should "return a nil plain logger if the config is not loaded" do
|
||||
env = mock_environment
|
||||
env.config.stubs(:loaded?).returns(false)
|
||||
|
|
Loading…
Reference in New Issue