test rebuilding C module when header changes
This commit is contained in:
parent
06be9a812e
commit
1eb9008885
@ -11,11 +11,26 @@ describe Rscons do
|
|||||||
FileUtils.rm_rf('build_tests_run')
|
FileUtils.rm_rf('build_tests_run')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def build_testdir
|
||||||
|
if File.exists?("build.rb")
|
||||||
|
system("ruby -I #{@owd}/lib -r rscons build.rb")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_dir(build_test_directory)
|
def test_dir(build_test_directory)
|
||||||
FileUtils.cp_r("build_tests/#{build_test_directory}", 'build_tests_run')
|
FileUtils.cp_r("build_tests/#{build_test_directory}", 'build_tests_run')
|
||||||
Dir.chdir("build_tests_run")
|
Dir.chdir("build_tests_run")
|
||||||
if File.exists?("build.rb")
|
build_testdir
|
||||||
system("ruby -I #{@owd}/lib -r rscons build.rb")
|
end
|
||||||
|
|
||||||
|
def file_sub(fname)
|
||||||
|
contents = File.read(fname)
|
||||||
|
replaced = ''
|
||||||
|
contents.each_line do |line|
|
||||||
|
replaced += yield(line)
|
||||||
|
end
|
||||||
|
File.open(fname, 'w') do |fh|
|
||||||
|
fh.write(replaced)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -34,4 +49,12 @@ describe Rscons do
|
|||||||
File.exists?('header.o').should be_true
|
File.exists?('header.o').should be_true
|
||||||
`./header`.should == "The value is 2\n"
|
`./header`.should == "The value is 2\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'rebuilds a C module when a header it depends on changes' do
|
||||||
|
test_dir('header')
|
||||||
|
`./header`.should == "The value is 2\n"
|
||||||
|
file_sub('header.h') {|line| line.sub(/2/, '5')}
|
||||||
|
build_testdir
|
||||||
|
`./header`.should == "The value is 5\n"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user