Skip to content

Commit

Permalink
Make rake test fail if a command fails. Install gem
Browse files Browse the repository at this point in the history
  • Loading branch information
ngiger committed May 2, 2014
1 parent 9df10d5 commit 52e28c6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
7 changes: 6 additions & 1 deletion Rakefile
Expand Up @@ -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*']
Expand Down
15 changes: 13 additions & 2 deletions test_options.rb
Expand Up @@ -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')
Expand Down

0 comments on commit 52e28c6

Please sign in to comment.