regressiontest 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 15439a663924842f6fa896369b1e4c9ee7a235bc
4
+ data.tar.gz: b68ed08e39c2f2c18e8b024df017b2731231dba2
5
+ SHA512:
6
+ metadata.gz: 384c85b722be84e0f67955bd6a21d7d63471e32909cf4a9a54477cca6b024e73a5f0fc362fcbf1edfae910b498b3d39dfcf6709d0774f3932641b06825fc5556
7
+ data.tar.gz: 15be021ca148723f575c2d6eca9c2d56ba67c95369068754c122fda1b7efb0040e66111e7f1fddbca51678abefaa88861a388077401250a78ce12e1c95910a0b
data/Gemfile CHANGED
@@ -6,11 +6,10 @@ source "http://rubygems.org"
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
  group :development do
9
- gem "shoulda", ">= 0"
10
- gem "rdoc", "~> 3.12"
11
- gem "cucumber", ">= 0"
12
- gem "jeweler", "~> 1.8.3"
13
- gem "bundler", ">= 1.0.21"
14
- gem "bio", ">= 1.4.2"
15
- gem "rdoc", "~> 3.12"
9
+ gem "shoulda"
10
+ gem "cucumber"
11
+ gem "jeweler", "~> 2.0.1"
12
+ gem "bundler"
13
+ gem "rspec"
14
+ gem "rdoc"
16
15
  end
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Pjotr Prins
1
+ Copyright (c) 2012-2014 Pjotr Prins
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -36,11 +36,48 @@ by default a .ref and a .new file are created in the
36
36
  lines of output (as a regex), e.g.
37
37
 
38
38
  ```ruby
39
- RegressionTest::CliExec::exec("ls","-l",:ignore: 'INFO bio-gff3: Memory used')
39
+ RegressionTest::CliExec::exec("ls","-l",ignore: 'INFO bio-gff3: Memory used')
40
40
  ```
41
41
 
42
+ Other options are :timeout and :should_fail.
43
+
42
44
  The API doc is online. For more code examples see the test files in
43
- the source tree.
45
+ the source tree. A good example can be found in the
46
+ [bio-table](https://github.com/pjotrp/bioruby-table) project which uses
47
+ cucumber features combined with the regressiontest gem. The features
48
+ look like
49
+
50
+ ```ruby
51
+ Scenario: Test the numerical filter by indexed column values
52
+ Given I have input file(s) named "test/data/input/table1.csv"
53
+ When I execute "./bin/bio-table --num-filter 'values[3] > 0.05'"
54
+ Then I expect the named output to match "table1-0_05"
55
+ ```
56
+
57
+ and are listed in
58
+ [cli.feature](https://github.com/pjotrp/bioruby-table/blob/master/features/cli.feature)
59
+ and the matching steps are simply
60
+
61
+ ```ruby
62
+ Given /^I have input file\(s\) named "(.*?)"$/ do |arg1|
63
+ @filenames = arg1.split(/,/)
64
+ end
65
+
66
+ When /^I execute "(.*?)"$/ do |arg1|
67
+ @cmd = arg1 + ' ' + @filenames.join(' ')
68
+ end
69
+
70
+ Then /^I expect the named output to match "(.*?)"$/ do |arg1|
71
+ RegressionTest::CliExec::exec(@cmd,arg1).should be_true
72
+ end
73
+ ```
74
+
75
+ and listed in
76
+ [cli.rb](https://github.com/pjotrp/bioruby-table/blob/master/features/step_definitions/cli-feature.rb).
77
+ The automatically generated regression output files are checked into
78
+ git in the
79
+ [test/data/regression](https://github.com/pjotrp/bioruby-table/tree/master/test/data/regression)
80
+ directory and checked with 'bundle exec rake'.
44
81
 
45
82
  ## Project home page
46
83
 
@@ -64,5 +101,5 @@ This Biogem is published at [#regressiontest](http://biogems.info/index.html)
64
101
 
65
102
  ## Copyright
66
103
 
67
- Copyright (c) 2012 Pjotr Prins. See LICENSE.txt for further details.
104
+ Copyright (c) 2012-2014 Pjotr Prins. See LICENSE.txt for further details.
68
105
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -2,7 +2,6 @@
2
2
  #
3
3
  # BioRuby regressiontest Plugin BioRegressiontest
4
4
  # Author:: Pjotr Prins
5
- # Copyright:: 2012
6
5
 
7
6
  USAGE = "Describe regressiontest"
8
7
 
@@ -13,7 +12,7 @@ VERSION_FILENAME=File.join(gempath,'VERSION')
13
12
  version = File.new(VERSION_FILENAME).read.chomp
14
13
 
15
14
  # print banner
16
- print "regressiontest #{version} by Pjotr Prins 2012\n"
15
+ print "regressiontest #{version} by Pjotr Prins\n"
17
16
 
18
17
  if ARGV.size == 0
19
18
  print USAGE
@@ -7,45 +7,76 @@ module RegressionTest
7
7
  # Regression test runner compares output in ./test/data/regression (by default).
8
8
  # The convention is to have a file with names .ref (reference) and create .new
9
9
  #
10
- # You can add an :ignore regex option which ignores lines in the comparsion files
10
+ # You can add an :ignore regex option which ignores lines in the comparson files
11
11
  # matching a regex
12
+ #
13
+ # :timeout sets the time out for calling a system command
14
+ #
15
+ # :should_fail expects the system command to return a non-zero
12
16
  module CliExec
17
+ FilePair = Struct.new(:outfn,:reffn)
18
+
13
19
  def CliExec::exec command, testname, options = {}
14
20
  # ---- Find .ref file
15
21
  fullname = DEFAULT_TESTDIR + "/" + testname
16
- basefn = if File.exist?(testname+".ref")
22
+ basefn = if File.exist?(testname+".ref") || File.exist?(testname+"-stderr.ref")
17
23
  testname
18
- elsif fullname + ".ref"
24
+ elsif File.exist?(fullname + ".ref") || File.exist?(fullname+"-stderr.ref")
19
25
  FileUtils.mkdir_p DEFAULT_TESTDIR
20
26
  fullname
21
27
  else
22
28
  raise "Can not find reference file for #{testname} - expected #{fullname}.ref"
23
29
  end
24
- outfn = basefn + ".new"
25
- reffn = basefn + ".ref"
30
+ std_out = FilePair.new(basefn + ".new", basefn + ".ref")
31
+ std_err = FilePair.new(basefn + "-stderr.new", basefn + "-stderr.ref")
32
+ files = [std_out,std_err]
26
33
  # ---- Create .new file
27
- cmd = command + " > #{outfn}"
34
+ cmd = command + " > #{std_out.outfn} 2>#{std_err.outfn}"
28
35
  $stderr.print cmd,"\n"
29
- if Kernel.system(cmd) == false
36
+ exec_ret = nil
37
+ if options[:timeout] && options[:timeout] > 0
38
+ Timeout.timeout(options[:timeout]) do
39
+ begin
40
+ exec_ret = Kernel.system(cmd)
41
+ rescue Timeout::Error
42
+ $stderr.print cmd, " failed to finish in under #{options[:timeout]}\n"
43
+ return false
44
+ end
45
+ end
46
+ else
47
+ exec_ret = Kernel.system(cmd)
48
+ end
49
+ expect_fail = (options[:should_fail] != nil)
50
+ if !expect_fail and exec_ret==0
30
51
  $stderr.print cmd," returned an error\n"
31
52
  return false
32
53
  end
54
+ if expect_fail and exec_ret
55
+ $stderr.print cmd," did not return an error\n"
56
+ return false
57
+ end
33
58
  if options[:ignore]
34
59
  regex = options[:ignore]
35
- outfn1 = outfn + ".1"
36
- FileUtils.mv(outfn,outfn1)
37
- buf = []
38
- f1 = File.open(outfn1)
39
- f = File.open(outfn,"w")
40
- f1.each_line do | line |
41
- f.print(line) if line !~ /#{regex}/
60
+ files.each do |f|
61
+ outfn = f.outfn
62
+ outfn1 = outfn + ".1"
63
+ FileUtils.mv(outfn,outfn1)
64
+ f1 = File.open(outfn1)
65
+ f2 = File.open(outfn,"w")
66
+ f1.each_line do | line |
67
+ f2.print(line) if line !~ /#{regex}/
68
+ end
69
+ f1.close
70
+ f2.close
71
+ FileUtils::rm(outfn1)
42
72
  end
43
- f1.close
44
- f.close
45
- FileUtils::rm(outfn1)
46
73
  end
47
74
  # ---- Compare the two files
48
- compare_files(outfn,reffn,options[:ignore])
75
+ files.each do |f|
76
+ next unless File.exist?(f.reffn)
77
+ return false unless compare_files(f.outfn,f.reffn,options[:ignore])
78
+ end
79
+ return true
49
80
  end
50
81
 
51
82
  def CliExec::compare_files fn1, fn2, ignore = nil
metadata CHANGED
@@ -1,93 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regressiontest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Pjotr Prins
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-08-20 00:00:00.000000000Z
11
+ date: 2014-09-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: shoulda
16
- requirement: &21093520 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
- version_requirements: *21093520
25
- - !ruby/object:Gem::Dependency
26
- name: rdoc
27
- requirement: &21092280 !ruby/object:Gem::Requirement
28
- none: false
22
+ version_requirements: !ruby/object:Gem::Requirement
29
23
  requirements:
30
- - - ~>
24
+ - - ">="
31
25
  - !ruby/object:Gem::Version
32
- version: '3.12'
33
- type: :development
34
- prerelease: false
35
- version_requirements: *21092280
26
+ version: '0'
36
27
  - !ruby/object:Gem::Dependency
37
28
  name: cucumber
38
- requirement: &21089660 !ruby/object:Gem::Requirement
39
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
40
30
  requirements:
41
- - - ! '>='
31
+ - - ">="
42
32
  - !ruby/object:Gem::Version
43
33
  version: '0'
44
34
  type: :development
45
35
  prerelease: false
46
- version_requirements: *21089660
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: jeweler
49
- requirement: &21088240 !ruby/object:Gem::Requirement
50
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
51
44
  requirements:
52
- - - ~>
45
+ - - "~>"
53
46
  - !ruby/object:Gem::Version
54
- version: 1.8.3
47
+ version: 2.0.1
55
48
  type: :development
56
49
  prerelease: false
57
- version_requirements: *21088240
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.0.1
58
55
  - !ruby/object:Gem::Dependency
59
56
  name: bundler
60
- requirement: &21086560 !ruby/object:Gem::Requirement
61
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
62
58
  requirements:
63
- - - ! '>='
59
+ - - ">="
64
60
  - !ruby/object:Gem::Version
65
- version: 1.0.21
61
+ version: '0'
66
62
  type: :development
67
63
  prerelease: false
68
- version_requirements: *21086560
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: bio
71
- requirement: &21084920 !ruby/object:Gem::Requirement
72
- none: false
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
73
72
  requirements:
74
- - - ! '>='
73
+ - - ">="
75
74
  - !ruby/object:Gem::Version
76
- version: 1.4.2
75
+ version: '0'
77
76
  type: :development
78
77
  prerelease: false
79
- version_requirements: *21084920
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
80
83
  - !ruby/object:Gem::Dependency
81
84
  name: rdoc
82
- requirement: &21083440 !ruby/object:Gem::Requirement
83
- none: false
85
+ requirement: !ruby/object:Gem::Requirement
84
86
  requirements:
85
- - - ~>
87
+ - - ">="
86
88
  - !ruby/object:Gem::Version
87
- version: '3.12'
89
+ version: '0'
88
90
  type: :development
89
91
  prerelease: false
90
- version_requirements: *21083440
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
91
97
  description: Regression testing for the command line, and library API
92
98
  email: pjotr.public01@thebird.nl
93
99
  executables:
@@ -97,8 +103,8 @@ extra_rdoc_files:
97
103
  - LICENSE.txt
98
104
  - README.md
99
105
  files:
100
- - .document
101
- - .travis.yml
106
+ - ".document"
107
+ - ".travis.yml"
102
108
  - Gemfile
103
109
  - LICENSE.txt
104
110
  - README.md
@@ -115,29 +121,25 @@ files:
115
121
  homepage: http://github.com/pjotrp/regressiontest
116
122
  licenses:
117
123
  - MIT
124
+ metadata: {}
118
125
  post_install_message:
119
126
  rdoc_options: []
120
127
  require_paths:
121
128
  - lib
122
129
  required_ruby_version: !ruby/object:Gem::Requirement
123
- none: false
124
130
  requirements:
125
- - - ! '>='
131
+ - - ">="
126
132
  - !ruby/object:Gem::Version
127
133
  version: '0'
128
- segments:
129
- - 0
130
- hash: -25856528596506647
131
134
  required_rubygems_version: !ruby/object:Gem::Requirement
132
- none: false
133
135
  requirements:
134
- - - ! '>='
136
+ - - ">="
135
137
  - !ruby/object:Gem::Version
136
138
  version: '0'
137
139
  requirements: []
138
140
  rubyforge_project:
139
- rubygems_version: 1.8.10
141
+ rubygems_version: 2.0.3
140
142
  signing_key:
141
- specification_version: 3
143
+ specification_version: 4
142
144
  summary: Functional (regression) testing library
143
145
  test_files: []