spec/build_tests_spec.rb in rscons-1.4.1 vs spec/build_tests_spec.rb in rscons-1.4.2

- old
+ new

@@ -496,6 +496,32 @@ env.build_root = "build" env.add_builder(TestBuilder.new) env.TestBuilder("file") end end + + it "expands construction variables in builder target and sources before invoking the builder" do + test_dir('custom_builder') + class MySource < Rscons::Builder + def run(target, sources, cache, env, vars) + File.open(target, 'w') do |fh| + fh.puts <<EOF + #define THE_VALUE 678 +EOF + end + target + end + end + + Rscons::Environment.new do |env| + env["hdr"] = "inc.h" + env["src"] = "program.c" + env.add_builder(MySource.new) + env.MySource('${hdr}') + env.Program('program', "${src}") + end + + lines.should == ['CC program.o', 'LD program'] + File.exists?('inc.h').should be_true + `./program`.should == "The value is 678\n" + end end