spec/build_tests_spec.rb in rscons-0.0.11 vs spec/build_tests_spec.rb in rscons-0.0.12

- old
+ new

@@ -11,16 +11,34 @@ FileUtils.rm_rf('build_tests_run') end def build_testdir if File.exists?("build.rb") - system("ruby -I #{@owd}/lib -r rscons build.rb > build.out") + build_rb = File.read("build.rb") + File.open("build.rb", "w") do |fh| + fh.puts(<<EOF + build_rb) +require "simplecov" + +SimpleCov.start do + root("#{@owd}") + command_name("build_test_#{@build_test_name}") + add_filter("spec") +end + +require "rscons" +EOF + end + IO.popen(%{ruby -I #{@owd}/lib build.rb}) do |io| + io.readlines.reject do |line| + line =~ /^Coverage report/ + end + end.map(&:strip) end - get_build_output end def test_dir(build_test_directory) + @build_test_name = build_test_directory FileUtils.cp_r("build_tests/#{build_test_directory}", 'build_tests_run') Dir.chdir("build_tests_run") build_testdir end @@ -33,14 +51,10 @@ File.open(fname, 'w') do |fh| fh.write(replaced) end end - def get_build_output - File.read('build.out').lines.map(&:strip) - end - ########################################################################### # Tests ########################################################################### it 'builds a C program with one source file' do @@ -114,39 +128,37 @@ end it 'builds object files in a different build directory' do lines = test_dir('build_dir') `./build_dir`.should == "Hello from two()\n" - File.exists?('build/one/one.o').should be_true - File.exists?('build/two/two.o').should be_true + File.exists?('build_one/one.o').should be_true + File.exists?('build_two/two.o').should be_true end it 'cleans built files' do lines = test_dir('build_dir') `./build_dir`.should == "Hello from two()\n" - File.exists?('build/one/one.o').should be_true - File.exists?('build/two/two.o').should be_true + File.exists?('build_one/one.o').should be_true + File.exists?('build_two/two.o').should be_true Rscons.clean - File.exists?('build/one/one.o').should be_false - File.exists?('build/two/two.o').should be_false - File.exists?('build/one').should be_false - File.exists?('build/two').should be_false - File.exists?('build').should be_false + File.exists?('build_one/one.o').should be_false + File.exists?('build_two/two.o').should be_false + File.exists?('build_one').should be_false + File.exists?('build_two').should be_false File.exists?('src/one/one.c').should be_true end it 'does not clean created directories if other non-rscons-generated files reside there' do lines = test_dir('build_dir') `./build_dir`.should == "Hello from two()\n" - File.exists?('build/one/one.o').should be_true - File.exists?('build/two/two.o').should be_true - File.open('build/two/tmp', 'w') { |fh| fh.puts "dum" } + File.exists?('build_one/one.o').should be_true + File.exists?('build_two/two.o').should be_true + File.open('build_two/tmp', 'w') { |fh| fh.puts "dum" } Rscons.clean - File.exists?('build/one/one.o').should be_false - File.exists?('build/two/two.o').should be_false - File.exists?('build/one').should be_false - File.exists?('build/two').should be_true - File.exists?('build').should be_true + File.exists?('build_one/one.o').should be_false + File.exists?('build_two/two.o').should be_false + File.exists?('build_one').should be_false + File.exists?('build_two').should be_true File.exists?('src/one/one.c').should be_true end it 'allows Ruby classes as custom builders to be used to construct files' do lines = test_dir('custom_builder')