regtest 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog +5 -0
  3. data/README.md +114 -0
  4. data/Rakefile +4 -1
  5. data/lib/regtest.rb +19 -10
  6. metadata +6 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e1feb2ecc25dc41c27accec0f36a65f978b118c
4
- data.tar.gz: 6fa8a1f8005373e60f44477bcaae010ed5bd9563
3
+ metadata.gz: abd6f8185f73664165e398cca0bef2b0939745a4
4
+ data.tar.gz: 4365febeeb57037f5f07d8719307926364ca0764
5
5
  SHA512:
6
- metadata.gz: f439ea61e766fdfdd68771b3d1f219dcbcf820126e3e58c79a37312806b75a434b554a6f9961ebff8397282da34e8ea1a6ac16ee580ce638e03d0cff791f13e5
7
- data.tar.gz: 45ce675a07a44e166a983aa9494c3038cab1c4de18f0b5b6e0661d0615f87dfd8acee43bbf282a79bb7055828b76dc45359793c690e563eff3423ace2156a471
6
+ metadata.gz: 9cc05a81f6ab89b4c049e495a7936ed43ca608cab90b13e2e02ad365f7565f97f73b798d5bd0f6d31db4fb1eefaef102a781727bb12a53296f893406d41a6653
7
+ data.tar.gz: 2fb9fe69b682acfc98c660de78e1ad699da386c85e04a8ec60be3666ecf66e8e64d782fbbcd9081c9402ba4f687eb748a18bc5e1f56adf8b162db1d8db75838a
data/Changelog CHANGED
@@ -1,3 +1,8 @@
1
+ 0.3.0
2
+ Printing some statistics.
3
+ Using regtest itself.
4
+ Update documentation.
5
+
1
6
  0.2.0
2
7
  Update rake task (set lib directory to $LOAD_PATH).
3
8
 
data/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # Regtest - Simple Regression Testing For Ruby Projects
2
+
3
+ ## Description
4
+
5
+ This library support a very simple way to do regression testing in Ruby projects.
6
+ I am using it for integration testing of my projects
7
+ [mini_exiftool](https://github.com/janfri/mini_exiftool/tree/master/regtest)
8
+ and [multi_exiftool](https://github.com/janfri/multi_exiftool-redesign/tree/master/regtest)
9
+ to check if exiftool itself returns different values or
10
+ new tags in newer versions.
11
+
12
+ ## Installation
13
+
14
+ Installing the gem with
15
+ gem install regtest
16
+ or put a copy of regtest.rb in your project.
17
+
18
+ ## Using
19
+
20
+ The idea behind regtest is the following workflow:
21
+ 1. Writing samples
22
+ 2. Running samples
23
+ 3. Checking results (differences between the actual results and the
24
+ results of a previous run of your samples)
25
+
26
+ ### Writing Samples
27
+
28
+ A samples file is a simple Ruby script with one ore more samples,
29
+ for example
30
+ require 'regtest'
31
+
32
+ Regtest.sample 'String result' do
33
+ # Doing something to get the result of the sample
34
+ # end make sure it is the result of the block
35
+ 'some text'
36
+ end
37
+
38
+ Regtest.sample 'Division by zero' do
39
+ # If an exception occurs while execution of the
40
+ # block it is catched and used as value for the
41
+ # sample
42
+ 2 / 0
43
+ end
44
+
45
+ The name of the sample (parameter of the `Regtest.sample` method)
46
+ and the results of the samples (return value of the block) are stored
47
+ in YAML format. So it should be a YAML friendly value as String,
48
+ Number, boolean value, Symbol.
49
+ Results could also be an Array or Hash with such values.
50
+
51
+ You can also include Regtest to have the sample method at
52
+ top level.
53
+ require 'regtest'
54
+ include Regtest
55
+
56
+ sample :x do
57
+ :x
58
+ end
59
+
60
+ By convention sample files are stored in a directory `regtest`
61
+ in your Ruby application.
62
+
63
+
64
+ ### Running Samples
65
+
66
+ Wether you run your examples manually
67
+ ruby -I lib regtest/*.rb
68
+ or using the Rake task of regtest:
69
+ Add the line
70
+ require 'regtest/task'
71
+ to your Rakefile and you can run your samples with
72
+ rake regtest
73
+
74
+ ### Checking Results
75
+
76
+ The results of each samples file are stored as a collection of
77
+ YAML documents in a corresponding results file (YAML) per samples
78
+ file.
79
+ For example for the samples files
80
+ regtest/foo.rb
81
+ regtest/bar.rb
82
+ are the corresponding results files
83
+ regtest/foo.yml
84
+ regtest/bar.yml
85
+
86
+ So the content of the results file of the example above is
87
+ ---
88
+ sample: String result
89
+ result: some text
90
+ ---
91
+ sample: Division by zero
92
+ exception: divided by 0
93
+
94
+ Each time you run one ore more samples file the corresponding
95
+ results file will be overwritten (or generated if not yet
96
+ existend) with the actual result values of your samples.
97
+ So source code version control programm is the tool to determine
98
+ changes between older runs of the samples.
99
+ Therefore the samples file and their corresponding results files
100
+ should be taken under version control.
101
+
102
+ ## Source Code
103
+
104
+ The code is hosted on [github](https://github.com/janfri/regtest) and
105
+ [gitorious](https://gitorious.org/regtest).
106
+ Change it to your needs. Release a fork. It is open source.
107
+
108
+ ## Author
109
+
110
+ Jan Friedrich <janfri26@gmail.com>
111
+
112
+ ## License
113
+
114
+ Regtest is licensed under the same terms as Ruby itself.
data/Rakefile CHANGED
@@ -2,9 +2,12 @@ require 'rim'
2
2
  require 'rim/check_version'
3
3
  require 'rim/gem'
4
4
 
5
+ $:.unshift 'lib'
6
+ require 'regtest/task'
7
+
5
8
  Rim.setup do |p|
6
9
  p.name = 'regtest'
7
- p.version = '0.2.0'
10
+ p.version = '0.3.0'
8
11
  p.authors = 'Jan Friedrich'
9
12
  p.email = 'janfri26@gmail.com'
10
13
  p.summary = 'Regression testing in Ruby.'
data/lib/regtest.rb CHANGED
@@ -1,15 +1,17 @@
1
1
  #
2
- # Regtest - Regression testing for Ruby
2
+ # Regtest - Simple Regression Testing For Ruby Projects
3
3
  #
4
4
  # Copyright 2014 by Jan Friedrich (janfri26@gmail.com)
5
- # License: Rubys License
5
+ # License: Regtest is licensed under the same terms as Ruby itself.
6
6
  #
7
7
 
8
8
  require 'yaml'
9
9
 
10
10
  module Regtest
11
11
 
12
- @@results = {}
12
+ @count = 0
13
+ @results = {}
14
+ @start = Time.now
13
15
 
14
16
  def sample name
15
17
  h = {}
@@ -21,17 +23,18 @@ module Regtest
21
23
  h['exception'] = e.message
22
24
  end
23
25
  output_filename = caller.first.split(/:/).first.sub(/\.rb/, '') << '.yml'
24
- unless @@results[output_filename]
25
- puts unless @@results.empty?
26
+ unless Regtest.results[output_filename]
27
+ puts unless Regtest.results.empty?
26
28
  puts File.basename(output_filename, '.yml')
27
- @@results[output_filename] = []
29
+ Regtest.results[output_filename] = []
28
30
  end
29
- @@results[output_filename] << h
31
+ Regtest.results[output_filename] << h
32
+ Regtest.count += 1
30
33
  print '.'; $stdout.flush
31
34
  end
32
35
 
33
- def self.results
34
- @@results
36
+ class << self
37
+ attr_accessor :count, :results, :start
35
38
  end
36
39
 
37
40
  module_function :sample
@@ -40,7 +43,10 @@ end
40
43
 
41
44
  at_exit do
42
45
  ARGV.each {|a| load a}
43
- puts
46
+ sample_count = Regtest.count
47
+ sample_time = Time.now - Regtest.start
48
+ puts format("\n\n%d samples executed in %.2f s (%.2f samples/s)", sample_count, sample_time, sample_count / sample_time)
49
+ save_start = Time.now
44
50
  Regtest.results.each_pair do |filename,arr|
45
51
  File.open(filename, 'w') do |f|
46
52
  arr.each do |h|
@@ -48,4 +54,7 @@ at_exit do
48
54
  end
49
55
  end
50
56
  end
57
+ files_count = Regtest.results.size
58
+ save_time = Time.now - save_start
59
+ puts format("%d files written in %.2f s (%.2f files/s)", files_count, save_time, files_count / save_time)
51
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regtest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Friedrich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-30 00:00:00.000000000 Z
11
+ date: 2014-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rim
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.8.0
19
+ version: 1.8.1
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.8.0
26
+ version: 1.8.1
27
27
  description: Regression testing in Ruby.
28
28
  email: janfri26@gmail.com
29
29
  executables: []
@@ -31,6 +31,7 @@ extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
33
  - Changelog
34
+ - README.md
34
35
  - Rakefile
35
36
  - lib/regtest.rb
36
37
  - lib/regtest/task.rb
@@ -54,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
55
  version: '0'
55
56
  requirements: []
56
57
  rubyforge_project:
57
- rubygems_version: 2.2.1
58
+ rubygems_version: 2.2.2
58
59
  signing_key:
59
60
  specification_version: 4
60
61
  summary: Regression testing in Ruby.