cloning an Environment should make a deep copy of its construction variables

This commit is contained in:
Josh Holtrop 2013-10-08 11:54:24 -04:00
parent dc6bac2895
commit 0f5fee359d
2 changed files with 13 additions and 2 deletions

View File

@ -6,7 +6,7 @@ module Rscons
# contains a collection of construction variables, options, builders, and # contains a collection of construction variables, options, builders, and
# rules for building targets. # rules for building targets.
class Environment class Environment
# [Array] of {Builder} objects. # [Hash] of {"builder_name" => builder_object} pairs.
attr_reader :builders attr_reader :builders
# Create an Environment object. # Create an Environment object.
@ -53,7 +53,7 @@ module Rscons
@builders.each do |builder_name, builder| @builders.each do |builder_name, builder|
env.add_builder(builder) env.add_builder(builder)
end end
env.append(@varset) env.append(@varset.clone)
env.append(variables) env.append(variables)
if block_given? if block_given?

View File

@ -1,5 +1,16 @@
module Rscons module Rscons
describe Environment do describe Environment do
describe '.clone' do
it 'should create unique copies of each construction variable' do
env = Environment.new
env["CPPPATH"] << "path1"
env2 = env.clone
env2["CPPPATH"] << "path2"
env["CPPPATH"].should == ["path1"]
env2["CPPPATH"].should == ["path1", "path2"]
end
end
describe '.parse_makefile_deps' do describe '.parse_makefile_deps' do
it 'handles dependencies on one line' do it 'handles dependencies on one line' do
File.should_receive(:read).with('makefile').and_return(<<EOS) File.should_receive(:read).with('makefile').and_return(<<EOS)