regtest 1.0.0 → 1.1.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: accc98eaba516d684361d2dbe6a3d3bb13699ba8
4
- data.tar.gz: 55c62a159fcbd0f218aaeb2ff69a70b4914a1f9f
3
+ metadata.gz: 0e25e74bc6bf4d1abf0c84fe8f7602b0bc355385
4
+ data.tar.gz: 80178a4963af2aebd6cb87d9c9e57fc7dc359dd8
5
5
  SHA512:
6
- metadata.gz: 15f9eca32bcfb978ff004972b19e51dbab4542a2f0fe098aebdb8c9600d76b836b0bead6e0c922d0c2a03773775113b9bd32aa867a1da548cf725295d622a329
7
- data.tar.gz: d39493f32b6cdaa8dc1bce1874f48cba1e75ce18b3b925ac2682c291d091c2035981c23e19bfdf560749c64fb6f07eeaa769ff5acdcc7b0d38dd248d54ebd125
6
+ metadata.gz: 32e29f778fa7128b743fab14bd29834d9a52c2f226e13a46d473e538c64962965df1ef9b622bf35462a60c4e568cf6d88b6aa282c34302debc05b5af87058e87
7
+ data.tar.gz: 1dfba5fe46becc517109a06670ccebcbabb930fc032570e67f34195649495a3d7b0f32f329887e8e7ed92dc4d492da507df275bcd4f13b8a4351f63b4dedb41e
data/Changelog CHANGED
@@ -1,3 +1,9 @@
1
+ 1.1.0
2
+ Remove output of statistics for writing files: It's not useful.
3
+ Report filename of generated results not only the basename of it.
4
+ Add metatest. :)
5
+ Some refactoring.
6
+
1
7
  1.0.0
2
8
  Some updates in documentation and project description.
3
9
 
data/Rakefile CHANGED
@@ -10,19 +10,19 @@ require 'regtest/task'
10
10
 
11
11
  Rim.setup do |p|
12
12
  p.name = 'regtest'
13
- p.version = '1.0.0'
13
+ p.version = '1.1.0'
14
14
  p.authors = 'Jan Friedrich'
15
15
  p.email = 'janfri26@gmail.com'
16
16
  p.summary = 'Simple regression testing for Ruby projects.'
17
17
  p.license = 'Ruby'
18
18
  p.description = <<-END.gsub(/^ +/, '')
19
19
  This library support a very simple way to do regression testing in Ruby
20
- projects. You write Ruby scripts with samples. Run these and get the sample
20
+ projects. You write Ruby scripts with samples. Run these and get the sample
21
21
  results as YAML output besides your scripts. Check both the scripts and the YAML
22
- files with the results in you Source Code Control System. When you run the
22
+ files with the results in you Source Code Control System. When you run the
23
23
  scrips on a later (or even previous) version of your code a simple diff show you
24
24
  if and how the changes in your code impact the results of your samples.
25
-
25
+
26
26
  This is not a replacement for unit testing but a complement: You can produce a
27
27
  lot of samples with a small amount of Ruby code (e.g. a large number of
28
28
  combinations of data).
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # Regtest - Simple Regression Testing For Ruby Projects
5
5
  #
6
- # Copyright 2014, 2015 by Jan Friedrich <janfri26@gmail.com>
6
+ # Copyright 2014, 2015, 2017 by Jan Friedrich <janfri26@gmail.com>
7
7
  # License: Regtest is licensed under the same terms as Ruby itself.
8
8
  #
9
9
 
@@ -28,7 +28,7 @@ module Regtest
28
28
  output_filename = caller.first.split(/:/).first.sub(/\.rb/, '') << '.yml'
29
29
  unless Regtest.results[output_filename]
30
30
  puts unless Regtest.results.empty?
31
- puts File.basename(output_filename, '.yml')
31
+ puts output_filename
32
32
  Regtest.results[output_filename] = []
33
33
  end
34
34
  Regtest.results[output_filename] << h
@@ -62,6 +62,21 @@ module Regtest
62
62
 
63
63
  class << self
64
64
  attr_accessor :count, :results, :start
65
+
66
+ def report
67
+ time = Time.now - start
68
+ puts format("\n\n%d samples executed in %.2f s (%.2f samples/s)", count, time, count / time)
69
+ end
70
+
71
+ def save
72
+ results.each_pair do |filename, arr|
73
+ File.open(filename, 'w') do |f|
74
+ arr.each do |h|
75
+ f.write h.to_yaml
76
+ end
77
+ end
78
+ end
79
+ end
65
80
  end
66
81
 
67
82
  module_function :sample, :combinations
@@ -70,18 +85,6 @@ end
70
85
 
71
86
  at_exit do
72
87
  ARGV.each {|a| load a}
73
- sample_count = Regtest.count
74
- sample_time = Time.now - Regtest.start
75
- puts format("\n\n%d samples executed in %.2f s (%.2f samples/s)", sample_count, sample_time, sample_count / sample_time)
76
- save_start = Time.now
77
- Regtest.results.each_pair do |filename,arr|
78
- File.open(filename, 'w') do |f|
79
- arr.each do |h|
80
- f.write h.to_yaml
81
- end
82
- end
83
- end
84
- files_count = Regtest.results.size
85
- save_time = Time.now - save_start
86
- puts format("%d files written in %.2f s (%.2f files/s)", files_count, save_time, files_count / save_time)
88
+ Regtest.report
89
+ Regtest.save
87
90
  end
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: regtest 1.0.0 ruby lib
2
+ # stub: regtest 1.1.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 = "1.0.0"
10
+ s.version = "1.1.0"
11
11
 
12
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-08-19"
16
- s.description = "This library support a very simple way to do regression testing in Ruby\nprojects. You write Ruby scripts with samples. Run these and get the sample\nresults as YAML output besides your scripts. Check both the scripts and the YAML\nfiles with the results in you Source Code Control System. When you run the\nscrips on a later (or even previous) version of your code a simple diff show you\nif and how the changes in your code 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"
15
+ s.date = "2017-08-29"
16
+ s.description = "This library support a very simple way to do regression testing in Ruby\nprojects. You write Ruby scripts with samples. Run these and get the sample\nresults as YAML output besides your scripts. Check both the scripts and the YAML\nfiles with the results in you Source Code Control System. When you run the\nscrips on a later (or even previous) version of your code a simple diff show you\nif and how the changes in your code 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 = ["Changelog", "Gemfile", "LICENSE", "README.md", "Rakefile", "lib/regtest", "lib/regtest.rb", "lib/regtest/task.rb", "regtest.gemspec", "regtest/combinations.rb", "regtest/combinations.yml", "regtest/example.rb", "regtest/example.yml", "regtest/no_samples.rb"]
18
+ s.files = ["Changelog", "Gemfile", "LICENSE", "README.md", "Rakefile", "lib/regtest", "lib/regtest.rb", "lib/regtest/task.rb", "regtest.gemspec", "regtest/combinations.rb", "regtest/combinations.yml", "regtest/example.rb", "regtest/example.yml", "regtest/metatest.rb", "regtest/metatest.yml", "regtest/no_samples.rb"]
19
19
  s.homepage = "https://github.com/janfri/regtest"
20
20
  s.licenses = ["Ruby"]
21
21
  s.rubygems_version = "2.6.12"
@@ -25,14 +25,17 @@ Gem::Specification.new do |s|
25
25
  s.specification_version = 4
26
26
 
27
27
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
28
- s.add_development_dependency(%q<rim>, ["~> 2.11"])
29
- s.add_development_dependency(%q<regtest>, ["~> 0.4"])
28
+ s.add_development_dependency(%q<rake>, ["< 100", "> 0"])
29
+ s.add_development_dependency(%q<rim>, ["~> 2.12"])
30
+ s.add_development_dependency(%q<regtest>, ["~> 1.0"])
30
31
  else
31
- s.add_dependency(%q<rim>, ["~> 2.11"])
32
- s.add_dependency(%q<regtest>, ["~> 0.4"])
32
+ s.add_dependency(%q<rake>, ["< 100", "> 0"])
33
+ s.add_dependency(%q<rim>, ["~> 2.12"])
34
+ s.add_dependency(%q<regtest>, ["~> 1.0"])
33
35
  end
34
36
  else
35
- s.add_dependency(%q<rim>, ["~> 2.11"])
36
- s.add_dependency(%q<regtest>, ["~> 0.4"])
37
+ s.add_dependency(%q<rake>, ["< 100", "> 0"])
38
+ s.add_dependency(%q<rim>, ["~> 2.12"])
39
+ s.add_dependency(%q<regtest>, ["~> 1.0"])
37
40
  end
38
41
  end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ require 'fileutils'
5
+ require 'open3'
6
+ require 'regtest'
7
+ require 'tmpdir'
8
+
9
+ Dir.mktmpdir('regtest') do |tmpdir|
10
+ Dir.chdir __dir__ do
11
+ Dir['*.rb'].each do |filename|
12
+ # beware of endless recursion
13
+ next if filename =~ /metatest/
14
+ FileUtils.cp filename, tmpdir
15
+ end
16
+ end
17
+ Dir.chdir tmpdir do
18
+ _, o, e = Open3.popen3("ruby -I #{File.join(__dir__, '../lib')} #{Dir['*.rb'].sort.join(' ')}")
19
+ Regtest.sample 'metatest' do
20
+ res = {'stdout' => o.read, 'stderr' => e.read}
21
+ # levelling runtime specific values
22
+ res['stdout'].gsub!(/\d+\.\d+/, 'x.xx')
23
+ res
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,11 @@
1
+ ---
2
+ sample: metatest
3
+ result:
4
+ stdout: |
5
+ combinations.yml
6
+ ......
7
+ example.yml
8
+ ..
9
+
10
+ 8 samples executed in x.xx s (x.xx samples/s)
11
+ stderr: ''
metadata CHANGED
@@ -1,48 +1,68 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regtest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.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-08-19 00:00:00.000000000 Z
11
+ date: 2017-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "<"
18
+ - !ruby/object:Gem::Version
19
+ version: '100'
20
+ - - ">"
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "<"
28
+ - !ruby/object:Gem::Version
29
+ version: '100'
30
+ - - ">"
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: rim
15
35
  requirement: !ruby/object:Gem::Requirement
16
36
  requirements:
17
37
  - - "~>"
18
38
  - !ruby/object:Gem::Version
19
- version: '2.11'
39
+ version: '2.12'
20
40
  type: :development
21
41
  prerelease: false
22
42
  version_requirements: !ruby/object:Gem::Requirement
23
43
  requirements:
24
44
  - - "~>"
25
45
  - !ruby/object:Gem::Version
26
- version: '2.11'
46
+ version: '2.12'
27
47
  - !ruby/object:Gem::Dependency
28
48
  name: regtest
29
49
  requirement: !ruby/object:Gem::Requirement
30
50
  requirements:
31
51
  - - "~>"
32
52
  - !ruby/object:Gem::Version
33
- version: '0.4'
53
+ version: '1.0'
34
54
  type: :development
35
55
  prerelease: false
36
56
  version_requirements: !ruby/object:Gem::Requirement
37
57
  requirements:
38
58
  - - "~>"
39
59
  - !ruby/object:Gem::Version
40
- version: '0.4'
60
+ version: '1.0'
41
61
  description: |
42
62
  This library support a very simple way to do regression testing in Ruby
43
- projects. You write Ruby scripts with samples. Run these and get the sample
63
+ projects. You write Ruby scripts with samples. Run these and get the sample
44
64
  results as YAML output besides your scripts. Check both the scripts and the YAML
45
- files with the results in you Source Code Control System. When you run the
65
+ files with the results in you Source Code Control System. When you run the
46
66
  scrips on a later (or even previous) version of your code a simple diff show you
47
67
  if and how the changes in your code impact the results of your samples.
48
68
 
@@ -66,6 +86,8 @@ files:
66
86
  - regtest/combinations.yml
67
87
  - regtest/example.rb
68
88
  - regtest/example.yml
89
+ - regtest/metatest.rb
90
+ - regtest/metatest.yml
69
91
  - regtest/no_samples.rb
70
92
  homepage: https://github.com/janfri/regtest
71
93
  licenses: