From 141f8ad5ace106ca6440cb82850b771b06d3b7b6 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 14 Jul 2013 23:24:46 -0400 Subject: [PATCH] test re-invoking a builder if the command-line options change --- build_tests/simple/build.rb | 1 + spec/build_tests_spec.rb | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/build_tests/simple/build.rb b/build_tests/simple/build.rb index 9775f9a..e109562 100644 --- a/build_tests/simple/build.rb +++ b/build_tests/simple/build.rb @@ -1,3 +1,4 @@ Rscons::Environment.new do |env| + # CHANGE FLAGS env.Program('simple', Dir['*.c']) end diff --git a/spec/build_tests_spec.rb b/spec/build_tests_spec.rb index c96bcfc..a3d5c0c 100644 --- a/spec/build_tests_spec.rb +++ b/spec/build_tests_spec.rb @@ -97,11 +97,19 @@ describe Rscons do 'CC header.o', 'LD header', ] - header_c = File.read('header.c') - File.open('header.c', 'w') do |fh| - fh.write(header_c) - end + file_sub('header.c') {|line| line} lines = build_testdir lines.should == [] end + + it 're-links a program when the link flags have changed' do + lines = test_dir('simple') + lines.should == [ + 'gcc -c -o simple.o -MMD -MF simple.mf simple.c', + 'gcc -o simple simple.o', + ] + file_sub('build.rb') {|line| line.sub(/.*CHANGE.FLAGS.*/, ' env["LIBS"] += ["c"]')} + lines = build_testdir + lines.should == ['gcc -o simple simple.o -lc'] + end end