diff --git a/Rakefile b/Rakefile index b7e9ed5..0ebd9eb 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,8 @@ require "bundler/gem_tasks" require "rspec/core/rake_task" -RSpec::Core::RakeTask.new(:spec) +RSpec::Core::RakeTask.new(:spec) do |t| + t.fail_on_error = false +end task :default => :spec diff --git a/build_tests/c-simple/spec.rb b/build_tests/c-simple/spec.rb deleted file mode 100644 index a3877b2..0000000 --- a/build_tests/c-simple/spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -it 'builds a C program with one source file' do - env = Rscons::Environment.new - env.Program('simple', 'simple.c') - File.exist?('simple.o').should be_true - `./simple`.should =~ /This is a simple C program/ -end diff --git a/build_tests/c-simple/simple.c b/spec/build_items/simple.c similarity index 100% rename from build_tests/c-simple/simple.c rename to spec/build_items/simple.c diff --git a/spec/build_tests_spec.rb b/spec/build_tests_spec.rb index 77b9d7d..dba6cc0 100644 --- a/spec/build_tests_spec.rb +++ b/spec/build_tests_spec.rb @@ -1,21 +1,34 @@ require 'fileutils' describe Rscons do - FileUtils.rm_rf('build_tests/test') - test_dirs = Dir['build_tests/*/'] - test_dirs.each do |build_test_rel_path| - context build_test_rel_path do - before do - FileUtils.cp_r(build_test_rel_path, 'build_tests/test') - @owd = Dir.pwd - Dir.chdir('build_tests/test') - $stdout.stub(:puts) { nil } - end - instance_eval(File.read(File.join(build_test_rel_path, 'spec.rb'))) - after do - Dir.chdir(@owd) - FileUtils.rm_rf('build_tests/test') - end + FileUtils.rm_rf('build_test') + + def setup_testdir(files, &blk) + FileUtils.mkdir_p('build_test') + files.each do |fname| + src = "spec/build_items/#{fname}" + dst = "build_test/#{fname}" + FileUtils.mkdir_p(File.dirname(dst)) + FileUtils.cp_r(src, dst) + end + Dir.chdir('build_test', &blk) + FileUtils.rm_rf('build_test') + end + + before do + $stdout.stub(:puts) { nil } + end + + ########################################################################### + # Build Tests + ########################################################################### + + it 'builds a C program with one source file' do + setup_testdir(['simple.c']) do + env = Rscons::Environment.new + env.Program('simple', 'simple.c') + File.exist?('simple.o').should be_true + `./simple`.should =~ /This is a simple C program/ end end end