regtest 2.0.0.pre → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a917267b567e320d9f372ad942f4602282c42b4
4
- data.tar.gz: d2e5e0da3b36b4190db29449c188b31ff6072f23
3
+ metadata.gz: 28b2ce644b776836dc3a87811ecc3c8accc4365e
4
+ data.tar.gz: 64b940c2ab67af77fb2bbbf205abdd2e4122f0c1
5
5
  SHA512:
6
- metadata.gz: 2b439502a95aa227425959e0de2be46d09d71233a3fc70b62a01220650464584d5a8ff1498ffcd41b9197679ad1b69e441d477b91a648a0ccb1910ec28b9cd5c
7
- data.tar.gz: 6e3b8462a54c051a5d1ae795572c6ba5871f07df53359c21c34c2eada095b23eab01fc0176e1afa9b17bc6efcdeca48fb9c8e2bddeca03b9911b91cc5b150528
6
+ metadata.gz: c1bb833f9ae90d7cbbcbb63c503b72a6341df21728378aebabdb4ebcee97168b4567fbf6ca3185ee738434e986f7671f75a207df5d9aed9bcd1f5d151fef7337
7
+ data.tar.gz: ab381db6009de48d6698aeca01fcc550b3cc860022ecc88880942270ba4731509ee109273d94b43479635707c95a410679499dacf9554d2ca888a73e4d1430dd
@@ -1,5 +1,6 @@
1
- personal_ws-1.1 en 24
1
+ personal_ws-1.1 en 26
2
2
  NOREGTESTRC
3
+ md
3
4
  dir
4
5
  Bugfix
5
6
  ostruct
@@ -22,4 +23,5 @@ Friedrich
22
23
  SCM
23
24
  regtestrc
24
25
  metatest
26
+ README
25
27
  OpenStruct
data/Changelog CHANGED
@@ -1,4 +1,4 @@
1
- 2.0.0.pre Major Release
1
+ 2.0.0 Major Release
2
2
 
3
3
  Incompatibilities to regtest 1.x
4
4
  1. The methods sample and combinations are not longer defined as instance
@@ -15,13 +15,18 @@ will not be loaded.
15
15
  A simple plugin mechanism is implemented and two plugins are part of regtest:
16
16
  regtest/colorize and regtest/git. Plugins are usual activated by require in
17
17
  one of the .regtestrc files.
18
+ It is possible to change the exit codes for different return states of
19
+ Regtest.check_results. This is done with changing Regtest.exit_codes see
20
+ README.md for an example.
18
21
 
19
22
  Further Changes
20
- Reporting of statistics for writing files is removed because it's not useful.
21
- Now the full filename for results files are reported when running regtest.
23
+ Reporting of statistics was reduced and the full filename for results files
24
+ are now reported when running regtest.
22
25
  Some metatests are added.
23
26
  Version constant Regtest::VERSION is also added.
24
- A lot of internal refactoring and improving documentation.
27
+ Regtest.sample returns now the hash with result information. This could be
28
+ useful for plugins which overload this method.
29
+ A lot of internal refactoring and improving documentation was done.
25
30
 
26
31
 
27
32
  1.1.0
data/README.md CHANGED
@@ -161,8 +161,8 @@ use git as your SCM:
161
161
  ```ruby
162
162
  require 'regtest/colorize'
163
163
  # adapt some colorizing if wanted
164
- Regtest::Colorize.mapping[:filename] = :blue
165
- Regtest::Colorize.mapping[:statistics] = {mode: :italic}
164
+ Regtest::Colorize.mapping[:filename] = :cyan
165
+ Regtest::Colorize.mapping[:statistics] = {color: :blue, mode: :italic}
166
166
 
167
167
  require 'regtest/git'
168
168
  ```
@@ -174,7 +174,8 @@ script is accordingly set. The standard values are: 0 for success, 1 for an
174
174
  unknown result (normally a new results file) and 2 for failure. If you use
175
175
  plain regtest without a SCM plugin the exit code is 1 (= unknown result).
176
176
 
177
- You can change the exit codes for the states with `Regtest.exit_codes` for example:
177
+ You can change the exit codes for the states with `Regtest.exit_codes`. The
178
+ following example changes the behaviour to the same as in regtest version 1.x.
178
179
 
179
180
  ```ruby
180
181
  Regtest.exit_codes[:unknown_result] = 0
data/Rakefile CHANGED
@@ -37,5 +37,11 @@ Rim.setup do |p|
37
37
  p.dependencies << %w(colorize ~>0.8)
38
38
  end
39
39
 
40
+ # JRuby does not support escaping of filenames with spaces in Open3.capture3
41
+ # therefore ignore metatest files when running on JRuby
42
+ if RUBY_ENGINE == 'jruby'
43
+ REGTEST_FILES_RB.reject! {|fn| fn =~ /metatest/}
44
+ end
45
+
40
46
  task :test => :regtest
41
47
  task :default => :test
@@ -15,17 +15,15 @@ module Regtest
15
15
 
16
16
  @start = Time.now
17
17
  @results = {}
18
- @statistics = []
19
18
  @exit_codes = Hash.new(1)
20
19
  @exit_codes.merge!({success: 0, unknown_result: 1, fail: 2})
21
20
 
22
21
  class << self
23
22
 
24
- attr_reader :exit_codes, :results, :statistics, :start
23
+ attr_reader :exit_codes, :results, :start
25
24
 
26
25
  # Define a sample
27
- def sample name, &_
28
- start = Time.now
26
+ def sample name
29
27
  h = {}
30
28
  name = name.to_s if name.kind_of?(Symbol)
31
29
  h['sample'] = name
@@ -34,7 +32,7 @@ module Regtest
34
32
  rescue Exception => e
35
33
  h['exception'] = e.message
36
34
  end
37
- output_filename = caller.first.split(/:\d+:/).first.sub(/\.rb/, '') << '.yml'
35
+ output_filename = determine_output_filename
38
36
  unless Regtest.results[output_filename]
39
37
  Regtest.report "\n", type: :filename unless Regtest.results.empty?
40
38
  Regtest.report output_filename, type: :filename
@@ -42,9 +40,7 @@ module Regtest
42
40
  end
43
41
  Regtest.results[output_filename] << h
44
42
  print '.'; $stdout.flush
45
- stop = Time.now
46
- Regtest.statistics << OpenStruct.new(filename: output_filename, sample: name, time: stop - start)
47
- name
43
+ h
48
44
  end
49
45
 
50
46
  # Build all combinations of a Hash-like object with arrays as values.
@@ -75,11 +71,18 @@ module Regtest
75
71
  res
76
72
  end
77
73
 
74
+ # Determine the filename of the ouput file (results file)
75
+ # with informations from caller
76
+ def determine_output_filename
77
+ rest = caller.drop_while {|c| c !~ /in `sample'/}.drop_while {|c| c =~ /in `sample'/}
78
+ rest.first.split(/:\d+:/).first.sub(/\.rb/, '') << '.yml'
79
+ end
80
+
78
81
  # Report some statistics, could be overwritten by plugins.
79
82
  def report_statistics
80
83
  time = Time.now - start
81
- sample_count = statistics.size
82
- report format("\n\n%d samples executed in %.2f s (%.2f samples/s)", sample_count, time, sample_count / time), type: :statistics
84
+ sample_count = results.values.map(&:size).reduce(0, &:+)
85
+ report format("\n\n%d samples executed in %.2f s (%d samples/s)", sample_count, time, sample_count / time), type: :statistics
83
86
  end
84
87
 
85
88
  # Save all results to the corresponding files.
@@ -9,7 +9,8 @@ begin
9
9
  # (see https://rubygems.org/gems/colorize)
10
10
  module Colorize
11
11
 
12
- @mapping = (%i(success fail unknown_result filename statistics).zip %i(green red yellow cyan default)).to_h
12
+ @mapping = (%i(success fail unknown_result filename).zip %i(green red yellow blue)).to_h
13
+ @mapping[:statistics] = {mode: :italic}
13
14
 
14
15
  class << self
15
16
  # Color mapping (all parameters of ColorizedString.colorize are supported
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Regtest
5
- VERSION = '2.0.0.pre'
5
+ VERSION = '2.0.0'
6
6
  end
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: regtest 2.0.0.pre ruby lib
2
+ # stub: regtest 2.0.0 ruby lib
3
3
  #
4
4
  # This file is automatically generated by rim.
5
5
  # PLEASE DO NOT EDIT IT DIRECTLY!
@@ -7,15 +7,15 @@
7
7
 
8
8
  Gem::Specification.new do |s|
9
9
  s.name = "regtest"
10
- s.version = "2.0.0.pre"
10
+ s.version = "2.0.0"
11
11
 
12
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
12
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
13
13
  s.require_paths = ["lib"]
14
14
  s.authors = ["Jan Friedrich"]
15
- s.date = "2017-09-12"
15
+ s.date = "2017-09-22"
16
16
  s.description = "This library supports a very simple way to do regression testing with Ruby. It\nis not limited to Ruby projects you can use it also in other contexts where you\ncan extract data with Ruby.\n\nYou write Ruby scripts with samples. Run these and get the sample results as\nresults files besides your scripts. Check both the scripts and the results\nfiles in you Source Code Management System (SCM). When you run the scrips on a\nlater (or even previous) version of your code a simple diff show you if and how\nthe changes in your code or environment impact the results of your samples.\n\nThis is not a replacement for unit testing but a complement: You can produce a\nlot of samples with a small amount of Ruby code (e.g. a large number of\ncombinations of data).\n"
17
17
  s.email = "janfri26@gmail.com"
18
- s.files = ["./.aspell.pws", "Changelog", "Gemfile", "LICENSE", "README.md", "Rakefile", "lib/regtest", "lib/regtest.rb", "lib/regtest/colorize.rb", "lib/regtest/git.rb", "lib/regtest/task.rb", "lib/regtest/version.rb", "regtest.gemspec", "regtest/combinations.rb", "regtest/combinations.yml", "regtest/example.rb", "regtest/example.yml", "regtest/filename with spaces.rb", "regtest/filename with spaces.yml", "regtest/metatest.rb", "regtest/metatest.yml", "regtest/metatest_git.rb", "regtest/metatest_git.yml", "regtest/no_samples.rb"]
18
+ s.files = ["./.aspell.pws", "Changelog", "Gemfile", "LICENSE", "README.md", "Rakefile", "lib/regtest", "lib/regtest.rb", "lib/regtest/colorize.rb", "lib/regtest/git.rb", "lib/regtest/task.rb", "lib/regtest/version.rb", "regtest.gemspec", "regtest/combinations.rb", "regtest/combinations.yml", "regtest/examples.rb", "regtest/examples.yml", "regtest/filename with spaces.rb", "regtest/filename with spaces.yml", "regtest/metatest.rb", "regtest/metatest.yml", "regtest/metatest_git.rb", "regtest/metatest_git.yml", "regtest/no_samples.rb"]
19
19
  s.homepage = "https://github.com/janfri/regtest"
20
20
  s.licenses = ["Ruby"]
21
21
  s.required_ruby_version = Gem::Requirement.new(">= 2.1.0")
@@ -15,3 +15,6 @@ Regtest.sample 'Division by zero' do
15
15
  # exception value for the sample.
16
16
  2 / 0
17
17
  end
18
+
19
+ # If no block is given => exception no block given (yield)
20
+ Regtest.sample 'no block'
@@ -4,3 +4,6 @@ result: some text
4
4
  ---
5
5
  sample: Division by zero
6
6
  exception: divided by 0
7
+ ---
8
+ sample: no block
9
+ exception: no block given (yield)
@@ -6,8 +6,10 @@ require 'open3'
6
6
  require 'regtest'
7
7
  require 'tmpdir'
8
8
 
9
+ $my_dir = File.expand_path(__dir__)
10
+
9
11
  Dir.mktmpdir('regtest') do |tmpdir|
10
- Dir.chdir __dir__ do
12
+ Dir.chdir $my_dir do
11
13
  Dir['*.rb'].each do |filename|
12
14
  # Beware of endless recursion.
13
15
  next if filename =~ /metatest/
@@ -15,12 +17,13 @@ Dir.mktmpdir('regtest') do |tmpdir|
15
17
  end
16
18
  end
17
19
  Dir.chdir tmpdir do
18
- lib_dir = File.join(__dir__, '../lib')
20
+ lib_dir = File.join($my_dir, '../lib')
19
21
  o, e, ps = Open3.capture3(*[{'NOREGTESTRC' => 'true'}, 'ruby', '-I', lib_dir], *Dir['*.rb'].sort)
20
22
  Regtest.sample 'metatest' do
21
23
  res = {'stdout' => o, 'stderr' => e}
22
24
  # Levelling out runtime specific differences.
23
25
  res['stdout'].gsub!(/\d+\.\d+/, 'x.xx')
26
+ res['stdout'].gsub!(%r(\d+ samples/s), 'x samples/s')
24
27
  res['exitstatus'] = ps.exitstatus
25
28
  res
26
29
  end
@@ -4,12 +4,12 @@ result:
4
4
  stdout: |
5
5
  combinations.yml
6
6
  ......
7
- example.yml
8
- ..
7
+ examples.yml
8
+ ...
9
9
  filename with spaces.yml
10
10
  .
11
11
 
12
- 9 samples executed in x.xx s (x.xx samples/s)
12
+ 10 samples executed in x.xx s (x samples/s)
13
13
 
14
14
  Please check result files manually. Regtest isn't able to do that.
15
15
  stderr: ''
@@ -10,8 +10,10 @@ begin
10
10
  require 'regtest/git'
11
11
  require 'tmpdir'
12
12
 
13
+ $my_dir = File.expand_path(__dir__)
14
+
13
15
  def create_sample name
14
- lib_dir = File.join(__dir__, '../lib')
16
+ lib_dir = File.join($my_dir, '../lib')
15
17
  o, e, ps = Open3.capture3(*[{'NOREGTESTRC' => 'true'}, 'ruby', '-I', lib_dir, '-r', 'regtest/git'], *Dir['*.rb'].sort)
16
18
  Regtest.sample name do
17
19
  res = {'stdout' => o, 'stderr' => e}
@@ -35,7 +37,7 @@ begin
35
37
  END
36
38
 
37
39
  Dir.mktmpdir('regtest') do |tmpdir|
38
- Dir.chdir __dir__ do
40
+ Dir.chdir $my_dir do
39
41
  Dir['*.rb'].each do |filename|
40
42
  # Beware of endless recursion.
41
43
  next if filename =~ /metatest/
@@ -45,11 +47,11 @@ begin
45
47
  Dir.chdir tmpdir do
46
48
  execute 'git init'
47
49
  create_sample 'all new'
48
- execute 'git add *.rb example.yml combinations.yml'
50
+ execute 'git add *.rb examples.yml combinations.yml'
49
51
  create_sample 'only one new'
50
- example_rb = File.read('example.rb')
52
+ example_rb = File.read('examples.rb')
51
53
  example_rb << NEW_SAMPLE
52
- File.write('example.rb', example_rb)
54
+ File.write('examples.rb', example_rb)
53
55
  create_sample 'one new one modified to index'
54
56
  execute 'git commit -m "commit"'
55
57
  create_sample 'one new one modified'
@@ -4,16 +4,16 @@ result:
4
4
  stdout: |
5
5
  combinations.yml
6
6
  ......
7
- example.yml
8
- ..
7
+ examples.yml
8
+ ...
9
9
  filename with spaces.yml
10
10
  .
11
11
 
12
- 9 samples executed in x.xx s (x.xx samples/s)
12
+ 10 samples executed in x.xx s (x samples/s)
13
13
 
14
14
  There is at least one new sample result file.
15
15
  ?? combinations.yml
16
- ?? example.yml
16
+ ?? examples.yml
17
17
  ?? filename with spaces.yml
18
18
  stderr: ''
19
19
  exitstatus: 1
@@ -23,16 +23,16 @@ result:
23
23
  stdout: |
24
24
  combinations.yml
25
25
  ......
26
- example.yml
27
- ..
26
+ examples.yml
27
+ ...
28
28
  filename with spaces.yml
29
29
  .
30
30
 
31
- 9 samples executed in x.xx s (x.xx samples/s)
31
+ 10 samples executed in x.xx s (x samples/s)
32
32
 
33
33
  There is at least one new sample result file.
34
34
  A combinations.yml
35
- A example.yml
35
+ A examples.yml
36
36
  ?? filename with spaces.yml
37
37
  stderr: ''
38
38
  exitstatus: 1
@@ -42,16 +42,16 @@ result:
42
42
  stdout: |
43
43
  combinations.yml
44
44
  ......
45
- example.yml
46
- ...
45
+ examples.yml
46
+ ....
47
47
  filename with spaces.yml
48
48
  .
49
49
 
50
- 10 samples executed in x.xx s (x.xx samples/s)
50
+ 11 samples executed in x.xx s (x samples/s)
51
51
 
52
52
  There are changes in your sample results!
53
53
  A combinations.yml
54
- AM example.yml
54
+ AM examples.yml
55
55
  ?? filename with spaces.yml
56
56
  stderr: ''
57
57
  exitstatus: 2
@@ -61,15 +61,15 @@ result:
61
61
  stdout: |
62
62
  combinations.yml
63
63
  ......
64
- example.yml
65
- ...
64
+ examples.yml
65
+ ....
66
66
  filename with spaces.yml
67
67
  .
68
68
 
69
- 10 samples executed in x.xx s (x.xx samples/s)
69
+ 11 samples executed in x.xx s (x samples/s)
70
70
 
71
71
  There are changes in your sample results!
72
- M example.yml
72
+ M examples.yml
73
73
  ?? filename with spaces.yml
74
74
  stderr: ''
75
75
  exitstatus: 2
@@ -79,15 +79,15 @@ result:
79
79
  stdout: |
80
80
  combinations.yml
81
81
  ......
82
- example.yml
83
- ...
82
+ examples.yml
83
+ ....
84
84
  filename with spaces.yml
85
85
  .
86
86
 
87
- 10 samples executed in x.xx s (x.xx samples/s)
87
+ 11 samples executed in x.xx s (x samples/s)
88
88
 
89
89
  Looks good. :)
90
- M example.yml
90
+ M examples.yml
91
91
  A "filename with spaces.yml"
92
92
  stderr: ''
93
93
  exitstatus: 0
@@ -97,12 +97,12 @@ result:
97
97
  stdout: |
98
98
  combinations.yml
99
99
  ......
100
- example.yml
101
- ...
100
+ examples.yml
101
+ ....
102
102
  filename with spaces.yml
103
103
  .
104
104
 
105
- 10 samples executed in x.xx s (x.xx samples/s)
105
+ 11 samples executed in x.xx s (x samples/s)
106
106
 
107
107
  Looks good. :)
108
108
  stderr: ''
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: 2.0.0.pre
4
+ version: 2.0.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: 2017-09-12 00:00:00.000000000 Z
11
+ date: 2017-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -99,8 +99,8 @@ files:
99
99
  - regtest.gemspec
100
100
  - regtest/combinations.rb
101
101
  - regtest/combinations.yml
102
- - regtest/example.rb
103
- - regtest/example.yml
102
+ - regtest/examples.rb
103
+ - regtest/examples.yml
104
104
  - regtest/filename with spaces.rb
105
105
  - regtest/filename with spaces.yml
106
106
  - regtest/metatest.rb
@@ -123,9 +123,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
123
  version: 2.1.0
124
124
  required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  requirements:
126
- - - ">"
126
+ - - ">="
127
127
  - !ruby/object:Gem::Version
128
- version: 1.3.1
128
+ version: '0'
129
129
  requirements: []
130
130
  rubyforge_project:
131
131
  rubygems_version: 2.6.13