test building with a header file
This commit is contained in:
parent
760f698963
commit
06be9a812e
3
build_tests/header/build.rb
Normal file
3
build_tests/header/build.rb
Normal file
@ -0,0 +1,3 @@
|
||||
Rscons::Environment.new do |env|
|
||||
env.Program('header', Dir['*.c'])
|
||||
end
|
7
build_tests/header/header.c
Normal file
7
build_tests/header/header.c
Normal file
@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include "header.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("The value is %d\n", VALUE);
|
||||
}
|
6
build_tests/header/header.h
Normal file
6
build_tests/header/header.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef HEADER_H
|
||||
#define HEADER_H
|
||||
|
||||
#define VALUE 2
|
||||
|
||||
#endif
|
@ -3,16 +3,17 @@ require 'fileutils'
|
||||
describe Rscons do
|
||||
before(:all) do
|
||||
FileUtils.rm_rf('build_tests_run')
|
||||
FileUtils.cp_r('build_tests', 'build_tests_run')
|
||||
@owd = Dir.pwd
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
Dir.chdir(@owd)
|
||||
FileUtils.rm_rf('build_tests_run')
|
||||
end
|
||||
|
||||
def test_dir(build_test_directory)
|
||||
Dir.chdir("build_tests_run/#{build_test_directory}")
|
||||
FileUtils.cp_r("build_tests/#{build_test_directory}", 'build_tests_run')
|
||||
Dir.chdir("build_tests_run")
|
||||
if File.exists?("build.rb")
|
||||
system("ruby -I #{@owd}/lib -r rscons build.rb")
|
||||
end
|
||||
@ -27,4 +28,10 @@ describe Rscons do
|
||||
File.exists?('simple.o').should be_true
|
||||
`./simple`.should == "This is a simple C program\n"
|
||||
end
|
||||
|
||||
it 'builds a C program with one source file and one header file' do
|
||||
test_dir('header')
|
||||
File.exists?('header.o').should be_true
|
||||
`./header`.should == "The value is 2\n"
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user