Skip to content

Commit

Permalink
Added test target to rake
Browse files Browse the repository at this point in the history
  • Loading branch information
ngiger committed Apr 23, 2014
1 parent 2496614 commit b1377c2
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -74,6 +74,7 @@ $ oddb2xml -t md # => md_article.xml, md_product.xml, md_
$ oddb2xml -a nonpharma -t md -c tar.gz # => md_xml_dd.mm.yyyy_hh.mm.tar.gz
$ oddb2xml -f dat # => oddb.dat
$ oddb2xml -f dat -a nonpharma # => oddb_with_migel.dat
$ oddb2xml -e # => oddb_article.xml
```

output.
Expand Down Expand Up @@ -253,3 +254,9 @@ You can also run
* tools/win_fetch_cacerts.rb

for your currently open Terminal to download and set the Certificate.


## Testing

* Calling rake spec runs spec tests.
* Calling rake test installs the gems and runs oddb2xml with the most commonly used combinations. All output is placed under under ausgabe/<timestamp>. These files should be manually compared to the ones generated by the last release to check for possible problems.
4 changes: 2 additions & 2 deletions bin/oddb2xml
Expand Up @@ -28,8 +28,8 @@ Usage:
-x N, --context=N context N {product|address}. product is default.
For debugging purposes
--skip-download skips downloading files it the file is already under data/downloads.
Downloaded files are saved under data/downloads
--skip-download skips downloading files it the file is already under data/download.
Downloaded files are saved under data/download
-h, --help Show this help message.
EOS
end
Expand Down
40 changes: 40 additions & 0 deletions test_options.rb
@@ -0,0 +1,40 @@
#!/usr/bin/env ruby
# Helper script to test all common usageas of oddb2xml
# - runs rake install to install the gem
# - Creates an output directory ausgabe/time_stamp
# - runs all commands (and add ---skip-download)
# - saveds output and data/download to ausgabe/time_stamp


require 'fileutils'

def test_one_call(cmd)
dest = File.join(Ausgabe, cmd.gsub(/[ -]/, '_'))
cmd.sub!('oddb2xml', 'oddb2xml --skip-download')
files = (Dir.glob('%.xls*') + Dir.glob('*.dat*') + Dir.glob('*.xml'))
FileUtils.rm(files, :verbose => true)
puts "#{Time.now}: Running cmd #{cmd}"
startTime = Time.now
res = system(cmd)
endTime = Time.now
diffSeconds = (endTime - startTime).to_i
duration = "#{Time.now}: Took #{sprintf('%3d', diffSeconds)} seconds for"
puts "#{duration} success #{res} for #{cmd}"
exit 2 unless res
FileUtils.makedirs(dest)
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


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)
test_one_call('oddb2xml -f dat', 'oddb.dat')
test_one_call('oddb2xml -f xml', 'oddb.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')
test_one_call('oddb2xml -e') # take hours, therefor at the end

0 comments on commit b1377c2

Please sign in to comment.