From 52e28c6cbdb5d9372b9c18a2f2b8117d1bf0f0ed Mon Sep 17 00:00:00 2001 From: Niklaus Giger Date: Fri, 2 May 2014 09:48:42 +0200 Subject: [PATCH] Make rake test fail if a command fails. Install gem --- Rakefile | 7 ++++++- test_options.rb | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index a762d1d..5307cbf 100644 --- a/Rakefile +++ b/Rakefile @@ -19,10 +19,15 @@ task :spec => :clean desc 'Run oddb2xml with all commonly used combinations' task :test => [:clean, :spec, :gem] do - system("./test_options.rb 2>&1 | tee test_options.log") + log_file = 'test_options.log' + puts "Running test_options.rb with Output redirected to #{log_file}. This will take some time (e.g. 20 minutes)" + res = system("./test_options.rb 2>&1 > #{log_file}") + puts "Running test_options.rb returned #{res.inspect}. Output was redirected to #{log_file}" + exit 1 unless res end require 'rake/clean' +CLEAN.include FileList['pkg/*.gem'] CLEAN.include FileList['*.xls*'] CLEAN.include FileList['*.xml*'] CLEAN.include FileList['*.dat*'] diff --git a/test_options.rb b/test_options.rb index b6a099b..670058a 100755 --- a/test_options.rb +++ b/test_options.rb @@ -22,19 +22,30 @@ def test_one_call(cmd) puts "#{duration} success #{res} for #{cmd}" exit 2 unless res FileUtils.makedirs(dest) + return unless File.directory?('data/download') FileUtils.cp_r('data/download', dest, :preserve => true, :verbose => true) if Dir.glob(Ausgabe).size > 0 FileUtils.cp(Dir.glob('*.dat'), dest, :preserve => true, :verbose => true) if Dir.glob('*.dat').size > 0 FileUtils.cp(Dir.glob('*.xml'), dest, :preserve => true, :verbose => true) if Dir.glob('*.xml').size > 0 FileUtils.cp(Dir.glob('*.gz'), dest, :preserve => true, :verbose => true) if Dir.glob('*.gz').size > 0 end +def prepare_for_gem_test + [ "rake clean gem" , # build our gem first +# "gem uninstall --all --ignore-dependencies --executables", + "gem install pkg/*.gem" + ].each { + |cmd| + puts "Running #{cmd}" + exit 1 unless system(cmd) + } +end -system("rake install") # build and install our gem first Ausgabe = File.join(Dir.pwd, 'ausgabe', Time.now.strftime('%Y.%m.%d-%H:%M')) FileUtils.makedirs(Ausgabe) +prepare_for_gem_test +test_one_call('oddb2xml -f xml') test_one_call('oddb2xml -x address') test_one_call('oddb2xml -f dat') -test_one_call('oddb2xml -f xml') test_one_call('oddb2xml -f dat -a nonpharma') test_one_call('oddb2xml -t md') test_one_call('oddb2xml -a nonpharma -t md -c tar.gz')