test rebuilding when a source file changes

This commit is contained in:
Josh Holtrop 2013-06-26 22:21:43 -04:00
parent 37d324173a
commit 68329ca7ad

View File

@ -15,9 +15,13 @@ describe Rscons do
FileUtils.rm_rf('build_test') FileUtils.rm_rf('build_test')
end end
def clear_cache
Rscons::Cache.open.clear
end
before do before do
$stdout.stub(:puts) { nil } $stdout.stub(:puts) { nil }
Rscons::Cache.open.clear clear_cache
end end
########################################################################### ###########################################################################
@ -53,4 +57,19 @@ describe Rscons do
env.Program('simple', 'simple.c') env.Program('simple', 'simple.c')
end end
end end
it 'rebuilds the application when the source file changes' do
setup_testdir(['simple.c']) do
env = Rscons::Environment.new
env.Program('simple', 'simple.c')
`./simple`.should =~ /This is a simple C program/
c = File.read('simple.c')
File.open('simple.c', 'w') do |fh|
fh.puts c.sub('simple', 'modified')
end
clear_cache
env.Program('simple', 'simple.c')
`./simple`.should =~ /This is a modified C program/
end
end
end end