cloned Environments should inherit n_threads - close #42

This commit is contained in:
Josh Holtrop 2017-07-11 10:29:25 -04:00
parent 2a96495e83
commit 775363ddbd
3 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,7 @@
base_env = Rscons::Environment.new do |env|
env.n_threads = 165
end
my_env = base_env.clone
puts my_env.n_threads

View File

@ -118,6 +118,7 @@ module Rscons
env.add_post_build_hook(&build_hook_block) env.add_post_build_hook(&build_hook_block)
end end
end end
env.instance_variable_set(:@n_threads, @n_threads)
if block_given? if block_given?
yield env yield env

View File

@ -762,6 +762,13 @@ EOF
expect(result.stderr).to match /Failed to build foo_4/ expect(result.stderr).to match /Failed to build foo_4/
end end
it "clones n_threads attribute when cloning an Environment" do
test_dir("simple")
result = run_test(rsconsfile: "clone_n_threads.rb")
expect(result.stderr).to eq ""
expect(lines(result.stdout)).to eq ["165"]
end
context "backward compatibility" do context "backward compatibility" do
it "allows a builder to call Environment#run_builder in a non-threaded manner" do it "allows a builder to call Environment#run_builder in a non-threaded manner" do
test_dir("simple") test_dir("simple")