add rspec test for overridding construction variables for an individual builer

This commit is contained in:
Josh Holtrop 2013-09-12 23:05:04 -04:00
parent 837dff9374
commit e04e67698a
4 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Rscons::Environment.new(echo: :command) do |env|
env.Object("one.o", "one.c", 'CPPFLAGS' => ['-DONE'])
env.Program('two_sources', ['one.o', 'two.c'])
end

View File

@ -0,0 +1,8 @@
#include <stdio.h>
#ifdef ONE
int main(int argc, char *argv[])
{
printf("This is a C program with two sources.\n");
}
#endif

View File

@ -0,0 +1,3 @@
#ifdef ONE
#error ONE should not be defined
#endif

View File

@ -143,4 +143,14 @@ describe Rscons do
`./simple`.should == "This is a simple C++ program\n"
end
it 'allows overriding construction variables for individual builder calls' do
lines = test_dir('two_sources')
lines.should == [
'gcc -c -o one.o -MMD -MF one.mf -DONE one.c',
'gcc -c -o two.o -MMD -MF two.mf two.c',
'gcc -o two_sources one.o two.o',
]
File.exists?('two_sources').should be_true
`./two_sources`.should == "This is a C program with two sources.\n"
end
end