regtest 2.2.1 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.aspell.pws +12 -12
- data/Changelog +8 -0
- data/LICENSE +1 -1
- data/README.md +35 -3
- data/Rakefile +8 -1
- data/lib/regtest/git.rb +61 -40
- data/lib/regtest/version.rb +1 -1
- data/lib/regtest.rb +9 -1
- data/regtest.gemspec +8 -17
- metadata +3 -44
- data/lib/regtest/colorize.rb +0 -8
- data/regtest/combinations.rb +0 -15
- data/regtest/combinations.yml +0 -30
- data/regtest/examples.rb +0 -20
- data/regtest/examples.yml +0 -9
- data/regtest/filename with spaces.rb +0 -8
- data/regtest/filename with spaces.yml +0 -4
- data/regtest/log.log +0 -3
- data/regtest/log.rb +0 -18
- data/regtest/log.yml +0 -6
- data/regtest/log_append.log +0 -4
- data/regtest/log_append.rb +0 -32
- data/regtest/log_append.yml +0 -18
- data/regtest/log_rewrite.log +0 -1
- data/regtest/log_rewrite.rb +0 -32
- data/regtest/log_rewrite.yml +0 -12
- data/regtest/metatest.rb +0 -31
- data/regtest/metatest.yml +0 -24
- data/regtest/metatest_git.rb +0 -67
- data/regtest/metatest_git.yml +0 -177
- data/regtest/no_samples.rb +0 -8
- data/regtest/toplevel.log +0 -1
- data/regtest/toplevel.rb +0 -30
- data/regtest/toplevel.yml +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84ca27fae1d12f7b8616fa32743dbacccfb64fc25b7783b9ec19e7ddc8c8ef2b
|
4
|
+
data.tar.gz: c414dd15ee7d42cd2717caac6530556232a6930c4c107270a16d2138226947c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a43f2252a7cb0993eaef29d017e9132b908930fdc298c599f714331053e900bf602655294cfd8fbd24363e01e7053bea6cff90fd2ff11ba7afcdafa6277bbbf
|
7
|
+
data.tar.gz: b3b77f936f251b850246799aa4a0eb01adead35ad758f9e8fefa6c9d02cc00d4017905af2b08dc822de0ace51e4ebabea1b5c294aaf2d52b86f04183fa2ac48d
|
data/.aspell.pws
CHANGED
@@ -1,17 +1,26 @@
|
|
1
|
-
personal_ws-1.1 en
|
1
|
+
personal_ws-1.1 en 37
|
2
2
|
Bugfix
|
3
3
|
ENV
|
4
4
|
Friedrich
|
5
5
|
Gemfile
|
6
|
+
Matz
|
6
7
|
NOREGTESTRC
|
8
|
+
OpenStruct
|
7
9
|
README
|
10
|
+
Rakefile
|
8
11
|
Regtest
|
9
12
|
SCM
|
13
|
+
STDERR
|
10
14
|
SemVer
|
11
15
|
SemVerTag
|
12
16
|
YAML
|
17
|
+
arg
|
18
|
+
ary
|
19
|
+
backtrace
|
20
|
+
backtraces
|
13
21
|
basename
|
14
22
|
bitbucket
|
23
|
+
catched
|
15
24
|
dir
|
16
25
|
exiftool
|
17
26
|
gettime
|
@@ -19,20 +28,11 @@ github
|
|
19
28
|
md
|
20
29
|
metatest
|
21
30
|
metatests
|
31
|
+
ostruct
|
22
32
|
rb
|
23
33
|
rc
|
24
34
|
regtest
|
25
35
|
regtestrc
|
26
36
|
scripref
|
27
|
-
yml
|
28
|
-
arg
|
29
|
-
Matz
|
30
|
-
ary
|
31
|
-
Matz
|
32
|
-
OpenStruct
|
33
|
-
Rakefile
|
34
|
-
arg
|
35
|
-
ary
|
36
|
-
catched
|
37
|
-
ostruct
|
38
37
|
yaml
|
38
|
+
yml
|
data/Changelog
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
2.3.0
|
2
|
+
Remove regtest/colorize use regtest/colors instead.
|
3
|
+
Add Regtest::Git.work_tree and Regtest::Git.git_dir to be more flexible when
|
4
|
+
using different git repositories.
|
5
|
+
Add flag Regtest.show_exceptions for easier analysing problems when unexpected
|
6
|
+
exceptions occur.
|
7
|
+
Optimize some internals.
|
8
|
+
|
1
9
|
2.2.1
|
2
10
|
Adapt git output to work with different git versions.
|
3
11
|
Simplify determination of filenames for outputs.
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -54,7 +54,7 @@ require 'regtest'
|
|
54
54
|
|
55
55
|
Regtest.sample 'String result' do
|
56
56
|
# Doing something to get the result of the sample
|
57
|
-
#
|
57
|
+
# and ensure it is the result of the block
|
58
58
|
'some text'
|
59
59
|
end
|
60
60
|
|
@@ -151,7 +151,7 @@ corresponding results files should be taken under version control.
|
|
151
151
|
The key idea behind regtest is to produce values that are invariant and check
|
152
152
|
if this assumption is true at another (mostly later) state of code. But often
|
153
153
|
there are temporary or specific values which changes or could change at each
|
154
|
-
run of regtest. This could be for example an id
|
154
|
+
run of regtest. This could be for example an id of a created record or the
|
155
155
|
version of a used external service or some time-relevant values. Sometimes it
|
156
156
|
is useful, to know the actual value of one of these.
|
157
157
|
|
@@ -219,6 +219,22 @@ Because the log files contains only temporary stuff they should normally not
|
|
219
219
|
checked in the SCM.
|
220
220
|
|
221
221
|
|
222
|
+
## Exceptions an backtraces
|
223
|
+
|
224
|
+
If there is an exception raised inside a regtest sample its message is a part
|
225
|
+
of the result of the sample. This is intentional because exceptions are
|
226
|
+
possible results you want to check.
|
227
|
+
|
228
|
+
But sometimes an exception occur inside of a sample that was not the intention
|
229
|
+
of the sample code. In such situation it would be helpful to have the full
|
230
|
+
exception message with the backtrace, to find the code location where the error
|
231
|
+
occurred.
|
232
|
+
|
233
|
+
You can do this with setting `Regtest.show_exceptions = true` (normally in a
|
234
|
+
local `.regtestrc` file, see below) temporarily. Then the exception and
|
235
|
+
backtrace is written to STDERR.
|
236
|
+
|
237
|
+
|
222
238
|
## Configuration and Plugins
|
223
239
|
|
224
240
|
You can adapt the behaviour of regtest with plugins. To configure this and
|
@@ -255,11 +271,27 @@ Regtest.exit_codes[:unknown_result] = 0
|
|
255
271
|
Regtest.exit_codes[:fail] = 0
|
256
272
|
```
|
257
273
|
|
258
|
-
This also should be
|
274
|
+
This also should be done in a `.regtest` file and not in the sample files.
|
259
275
|
|
260
276
|
Because in a `.regtestrc` file are individual configuration aspects of your
|
261
277
|
workflow and environment it should not be checked into your SCM.
|
262
278
|
|
279
|
+
|
280
|
+
## Plugin regtest/git
|
281
|
+
|
282
|
+
If you use the git plugin (`require 'regtest/git'`) there will be two options
|
283
|
+
you can set:
|
284
|
+
|
285
|
+
* `Regtest::Git.git_dir`
|
286
|
+
* `Regtest::Git.work_tree`
|
287
|
+
|
288
|
+
which corresponds to the git parameters `--git-dir` and `--work-path`. Which
|
289
|
+
could be helpful if you run `regtest` from inside an other git repository than
|
290
|
+
your regtest files. Have a look at the git documentation for more details.
|
291
|
+
|
292
|
+
As said above: this should also be done in a local `.regtestrc` file.
|
293
|
+
|
294
|
+
|
263
295
|
## Rake task
|
264
296
|
|
265
297
|
Regtest includes a Rake task `regtest`. Per default it runs any `.rb` files
|
data/Rakefile
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
$:.unshift 'lib'
|
5
5
|
|
6
6
|
require 'rim/tire'
|
7
|
-
require 'rim/regtest'
|
8
7
|
require 'rim/version'
|
9
8
|
|
10
9
|
require 'regtest/task'
|
@@ -42,5 +41,13 @@ if RUBY_ENGINE == 'jruby'
|
|
42
41
|
REGTEST_FILES_RB.reject! {|fn| fn =~ /metatest/}
|
43
42
|
end
|
44
43
|
|
44
|
+
task :before_regtest do
|
45
|
+
verbose false do
|
46
|
+
rm_rf 'regtest/*.log'
|
47
|
+
rm_rf 'regtest/*.yml'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
task :regtest => :before_regtest
|
45
52
|
task :test => :regtest
|
46
53
|
task :default => :test
|
data/lib/regtest/git.rb
CHANGED
@@ -3,54 +3,75 @@
|
|
3
3
|
|
4
4
|
require 'open3'
|
5
5
|
|
6
|
-
# Check if git is available
|
6
|
+
# Check if git is available
|
7
7
|
begin
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
module Git
|
15
|
-
|
16
|
-
# Redefine Regtest.check_results.
|
17
|
-
def check_results
|
18
|
-
output_files = Regtest.results.keys
|
19
|
-
if output_files.empty?
|
20
|
-
report "\nNothing to do.", type: :success
|
21
|
-
return :success
|
22
|
-
end
|
23
|
-
git_stat, _, _ = Open3.capture3(*%w(git status --porcelain --), *output_files)
|
24
|
-
case git_stat
|
25
|
-
when /^.M/ # at least one modified file
|
26
|
-
report "\nThere are changes in your sample results!", type: :fail
|
27
|
-
system *%w(git status -s --), *output_files
|
28
|
-
return :fail
|
29
|
-
when /^.\?/ # at least one unknown file
|
30
|
-
report "\nThere is at least one new sample result file.", type: :unknown_result
|
31
|
-
system *%w(git status -s --), *output_files
|
32
|
-
return :unknown_result
|
33
|
-
when '', /^. / # no changes in (maybe staged) files
|
34
|
-
report "\nLooks good. :)", type: :success
|
35
|
-
system *%w(git status -s --), *output_files
|
36
|
-
return :success
|
37
|
-
else
|
38
|
-
report "\nYour sample results are in a bad condition!", type: :fail
|
39
|
-
system *%w(git status -s --), *output_files
|
40
|
-
return :fail
|
41
|
-
end
|
42
|
-
end
|
8
|
+
Open3.capture2e('git --version')
|
9
|
+
module Regtest
|
10
|
+
|
11
|
+
# Regtest plugin for git (results are checked automatically when running
|
12
|
+
# regtest)
|
13
|
+
module Git
|
43
14
|
|
15
|
+
# Redefine Regtest.check_results.
|
16
|
+
def check_results
|
17
|
+
output_files = Regtest.results.keys
|
18
|
+
if output_files.empty?
|
19
|
+
report "\nNothing to do.", type: :success
|
20
|
+
return :success
|
21
|
+
end
|
22
|
+
git_status = ['git', git_global_args, %w(status -s --)].flatten
|
23
|
+
git_results, stderr, _ = Open3.capture3(*git_status, *output_files)
|
24
|
+
unless stderr.empty?
|
25
|
+
report "\ngit command coud not be executed!", type: :fail
|
26
|
+
return :fail
|
27
|
+
end
|
28
|
+
case git_results
|
29
|
+
when /^.M/ # at least one modified file
|
30
|
+
report "\nThere are changes in your sample results!", type: :fail
|
31
|
+
system *git_status, *output_files
|
32
|
+
return :fail
|
33
|
+
when /^.\?/ # at least one unknown file
|
34
|
+
report "\nThere is at least one new sample result file.", type: :unknown_result
|
35
|
+
system *git_status, *output_files
|
36
|
+
return :unknown_result
|
37
|
+
when '', /^. / # no changes in (maybe staged) files
|
38
|
+
report "\nLooks good. :)", type: :success
|
39
|
+
system *git_status, *output_files
|
40
|
+
return :success
|
41
|
+
else
|
42
|
+
report "\nYour sample results are in a bad condition!", type: :fail
|
43
|
+
system *git_status, *output_files
|
44
|
+
return :fail
|
45
|
+
end
|
44
46
|
end
|
45
47
|
|
46
48
|
class << self
|
47
|
-
|
49
|
+
# git parameter +--work-tree+
|
50
|
+
attr_accessor :work_tree
|
51
|
+
|
52
|
+
# git parameter +--git-dir+
|
53
|
+
attr_accessor :git_dir
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def git_global_args
|
59
|
+
args = []
|
60
|
+
if wt = Regtest::Git.work_tree
|
61
|
+
args << format('--work-tree=%s', wt)
|
62
|
+
end
|
63
|
+
if gt = Regtest::Git.git_dir
|
64
|
+
args << format('--git-dir=%s', gt)
|
65
|
+
end
|
66
|
+
args
|
48
67
|
end
|
49
68
|
|
50
69
|
end
|
51
|
-
|
52
|
-
|
53
|
-
|
70
|
+
|
71
|
+
class << self
|
72
|
+
prepend Git
|
73
|
+
end
|
74
|
+
|
54
75
|
end
|
55
76
|
rescue Errno::ENOENT
|
56
77
|
warn 'git command not found: plugin regtest/git disabled'
|
data/lib/regtest/version.rb
CHANGED
data/lib/regtest.rb
CHANGED
@@ -3,7 +3,8 @@
|
|
3
3
|
#
|
4
4
|
# Regtest - Simple Regression Testing With Ruby
|
5
5
|
#
|
6
|
-
# Copyright 2014, 2015, 2017-2019 by Jan Friedrich
|
6
|
+
# Copyright 2014, 2015, 2017-2019, 2021, 2024 by Jan Friedrich
|
7
|
+
# <janfri26@gmail.com>
|
7
8
|
# License: Regtest is licensed under the same terms as Ruby itself.
|
8
9
|
#
|
9
10
|
|
@@ -21,6 +22,7 @@ module Regtest
|
|
21
22
|
@log_filenames = Set.new
|
22
23
|
@exit_codes = Hash.new(1)
|
23
24
|
@exit_codes.merge!({success: 0, unknown_result: 1, fail: 2})
|
25
|
+
@show_exceptions = false
|
24
26
|
|
25
27
|
# Define a sample
|
26
28
|
def sample name
|
@@ -31,6 +33,9 @@ module Regtest
|
|
31
33
|
h['result'] = yield
|
32
34
|
rescue Exception => e
|
33
35
|
h['exception'] = e.message
|
36
|
+
if show_exceptions
|
37
|
+
$stderr.puts nil, e.full_message
|
38
|
+
end
|
34
39
|
end
|
35
40
|
output_filename = Regtest.determine_filename_from_caller('.yml')
|
36
41
|
unless Regtest.results[output_filename]
|
@@ -96,6 +101,9 @@ module Regtest
|
|
96
101
|
|
97
102
|
attr_reader :exit_codes, :log_filenames, :results, :start
|
98
103
|
|
104
|
+
# Flag to show exceptions on STDERR
|
105
|
+
attr_accessor :show_exceptions
|
106
|
+
|
99
107
|
# Determine a filename which is derived from the filename of the "real"
|
100
108
|
# caller of the calling method
|
101
109
|
# @param ext new extension (i.e. '.yml')
|
data/regtest.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: regtest 2.
|
2
|
+
# stub: regtest 2.3.0 ruby lib
|
3
3
|
#
|
4
4
|
# This file is automatically generated by rim.
|
5
5
|
# PLEASE DO NOT EDIT IT DIRECTLY!
|
@@ -7,32 +7,23 @@
|
|
7
7
|
|
8
8
|
Gem::Specification.new do |s|
|
9
9
|
s.name = "regtest"
|
10
|
-
s.version = "2.
|
10
|
+
s.version = "2.3.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 = "
|
15
|
+
s.date = "2024-09-12"
|
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/
|
18
|
+
s.files = ["./.aspell.pws", "Changelog", "Gemfile", "LICENSE", "README.md", "Rakefile", "lib/regtest", "lib/regtest.rb", "lib/regtest/colors.rb", "lib/regtest/git.rb", "lib/regtest/task.rb", "lib/regtest/version.rb", "regtest.gemspec"]
|
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")
|
22
|
-
s.rubygems_version = "3.
|
22
|
+
s.rubygems_version = "3.6.0.dev"
|
23
23
|
s.summary = "Simple regression testing with Ruby."
|
24
24
|
|
25
|
-
|
26
|
-
s.specification_version = 4
|
27
|
-
end
|
25
|
+
s.specification_version = 4
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
s.add_development_dependency(%q<rim>, ["~> 2.17"])
|
32
|
-
s.add_development_dependency(%q<regtest>, ["~> 2"])
|
33
|
-
else
|
34
|
-
s.add_dependency(%q<rake>, [">= 0"])
|
35
|
-
s.add_dependency(%q<rim>, ["~> 2.17"])
|
36
|
-
s.add_dependency(%q<regtest>, ["~> 2"])
|
37
|
-
end
|
27
|
+
s.add_development_dependency(%q<rake>, [">= 0"])
|
28
|
+
s.add_development_dependency(%q<rim>, ["~> 2.17"])
|
38
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: regtest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Friedrich
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2024-09-12 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rake
|
@@ -38,20 +37,6 @@ dependencies:
|
|
38
37
|
- - "~>"
|
39
38
|
- !ruby/object:Gem::Version
|
40
39
|
version: '2.17'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: regtest
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '2'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '2'
|
55
40
|
description: |
|
56
41
|
This library supports a very simple way to do regression testing with Ruby. It
|
57
42
|
is not limited to Ruby projects you can use it also in other contexts where you
|
@@ -78,40 +63,15 @@ files:
|
|
78
63
|
- README.md
|
79
64
|
- Rakefile
|
80
65
|
- lib/regtest.rb
|
81
|
-
- lib/regtest/colorize.rb
|
82
66
|
- lib/regtest/colors.rb
|
83
67
|
- lib/regtest/git.rb
|
84
68
|
- lib/regtest/task.rb
|
85
69
|
- lib/regtest/version.rb
|
86
70
|
- regtest.gemspec
|
87
|
-
- regtest/combinations.rb
|
88
|
-
- regtest/combinations.yml
|
89
|
-
- regtest/examples.rb
|
90
|
-
- regtest/examples.yml
|
91
|
-
- regtest/filename with spaces.rb
|
92
|
-
- regtest/filename with spaces.yml
|
93
|
-
- regtest/log.log
|
94
|
-
- regtest/log.rb
|
95
|
-
- regtest/log.yml
|
96
|
-
- regtest/log_append.log
|
97
|
-
- regtest/log_append.rb
|
98
|
-
- regtest/log_append.yml
|
99
|
-
- regtest/log_rewrite.log
|
100
|
-
- regtest/log_rewrite.rb
|
101
|
-
- regtest/log_rewrite.yml
|
102
|
-
- regtest/metatest.rb
|
103
|
-
- regtest/metatest.yml
|
104
|
-
- regtest/metatest_git.rb
|
105
|
-
- regtest/metatest_git.yml
|
106
|
-
- regtest/no_samples.rb
|
107
|
-
- regtest/toplevel.log
|
108
|
-
- regtest/toplevel.rb
|
109
|
-
- regtest/toplevel.yml
|
110
71
|
homepage: https://github.com/janfri/regtest
|
111
72
|
licenses:
|
112
73
|
- Ruby
|
113
74
|
metadata: {}
|
114
|
-
post_install_message:
|
115
75
|
rdoc_options: []
|
116
76
|
require_paths:
|
117
77
|
- lib
|
@@ -126,8 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
86
|
- !ruby/object:Gem::Version
|
127
87
|
version: '0'
|
128
88
|
requirements: []
|
129
|
-
rubygems_version: 3.
|
130
|
-
signing_key:
|
89
|
+
rubygems_version: 3.6.0.dev
|
131
90
|
specification_version: 4
|
132
91
|
summary: Simple regression testing with Ruby.
|
133
92
|
test_files: []
|
data/lib/regtest/colorize.rb
DELETED
data/regtest/combinations.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'ostruct'
|
5
|
-
require 'regtest'
|
6
|
-
|
7
|
-
o = OpenStruct.new
|
8
|
-
o.a = [1, 2, 3]
|
9
|
-
o.b = [:x, :y]
|
10
|
-
|
11
|
-
Regtest.combinations(o).each_with_index do |c, i|
|
12
|
-
Regtest.sample "Combination #{i}" do
|
13
|
-
c.to_h
|
14
|
-
end
|
15
|
-
end
|
data/regtest/combinations.yml
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sample: Combination 0
|
3
|
-
result:
|
4
|
-
:a: 1
|
5
|
-
:b: :x
|
6
|
-
---
|
7
|
-
sample: Combination 1
|
8
|
-
result:
|
9
|
-
:a: 1
|
10
|
-
:b: :y
|
11
|
-
---
|
12
|
-
sample: Combination 2
|
13
|
-
result:
|
14
|
-
:a: 2
|
15
|
-
:b: :x
|
16
|
-
---
|
17
|
-
sample: Combination 3
|
18
|
-
result:
|
19
|
-
:a: 2
|
20
|
-
:b: :y
|
21
|
-
---
|
22
|
-
sample: Combination 4
|
23
|
-
result:
|
24
|
-
:a: 3
|
25
|
-
:b: :x
|
26
|
-
---
|
27
|
-
sample: Combination 5
|
28
|
-
result:
|
29
|
-
:a: 3
|
30
|
-
:b: :y
|
data/regtest/examples.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'regtest'
|
5
|
-
|
6
|
-
Regtest.sample 'String result' do
|
7
|
-
# Doing something to get the result of the sample
|
8
|
-
# and make sure it is the result of the block.
|
9
|
-
'some text'
|
10
|
-
end
|
11
|
-
|
12
|
-
Regtest.sample 'Division by zero' do
|
13
|
-
# If an exception occurs while execution of the
|
14
|
-
# block it is catched and its message is used as
|
15
|
-
# exception value for the sample.
|
16
|
-
2 / 0
|
17
|
-
end
|
18
|
-
|
19
|
-
# If no block is given => exception no block given (yield)
|
20
|
-
Regtest.sample 'no block'
|
data/regtest/examples.yml
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'regtest'
|
5
|
-
|
6
|
-
Regtest.sample 'spaces in filenames' do
|
7
|
-
"If you can read this in the results file #{File.basename(__FILE__.sub(/\.rb/, '.yml')).inspect} than regtest can handle filenames with spaces. :)"
|
8
|
-
end
|
data/regtest/log.log
DELETED
data/regtest/log.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'regtest'
|
5
|
-
|
6
|
-
Regtest.sample 'test' do
|
7
|
-
a = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
8
|
-
Regtest.log a
|
9
|
-
b = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
10
|
-
Regtest.log b
|
11
|
-
a < b
|
12
|
-
end
|
13
|
-
|
14
|
-
Regtest.sample 'invalid mode' do
|
15
|
-
Regtest.log 'foo', mode: 'x'
|
16
|
-
end
|
17
|
-
|
18
|
-
Regtest.log 'Logging from outside of a sample works.'
|
data/regtest/log.yml
DELETED
data/regtest/log_append.log
DELETED
data/regtest/log_append.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'regtest'
|
5
|
-
require 'fileutils'
|
6
|
-
|
7
|
-
|
8
|
-
$log_filename = __FILE__.sub(/\.rb$/, '.log')
|
9
|
-
|
10
|
-
# set the initial content of the log file
|
11
|
-
File.open($log_filename, 'w') do |f|
|
12
|
-
f.puts 'initial line'
|
13
|
-
end
|
14
|
-
|
15
|
-
def lines_of_log_file
|
16
|
-
File.readlines($log_filename).map(&:chomp) # keyword chomp is not supported by Ruby versions < 2.4
|
17
|
-
end
|
18
|
-
|
19
|
-
Regtest.sample 'first log entry appends to file' do
|
20
|
-
Regtest.log 'first log entry', mode: 'a'
|
21
|
-
lines_of_log_file
|
22
|
-
end
|
23
|
-
|
24
|
-
Regtest.sample 'second log entry appends to file' do
|
25
|
-
Regtest.log 'second log entry'
|
26
|
-
lines_of_log_file
|
27
|
-
end
|
28
|
-
|
29
|
-
Regtest.sample 'third log entry appends to file' do
|
30
|
-
Regtest.log 'first log entry', mode: 'a'
|
31
|
-
lines_of_log_file
|
32
|
-
end
|
data/regtest/log_append.yml
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sample: first log entry appends to file
|
3
|
-
result:
|
4
|
-
- initial line
|
5
|
-
- first log entry
|
6
|
-
---
|
7
|
-
sample: second log entry appends to file
|
8
|
-
result:
|
9
|
-
- initial line
|
10
|
-
- first log entry
|
11
|
-
- second log entry
|
12
|
-
---
|
13
|
-
sample: third log entry appends to file
|
14
|
-
result:
|
15
|
-
- initial line
|
16
|
-
- first log entry
|
17
|
-
- second log entry
|
18
|
-
- first log entry
|
data/regtest/log_rewrite.log
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
third log entry
|
data/regtest/log_rewrite.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'regtest'
|
5
|
-
require 'fileutils'
|
6
|
-
|
7
|
-
|
8
|
-
$log_filename = __FILE__.sub(/\.rb$/, '.log')
|
9
|
-
|
10
|
-
# set the initial content of the log file
|
11
|
-
File.open($log_filename, 'w') do |f|
|
12
|
-
f.puts 'initial line'
|
13
|
-
end
|
14
|
-
|
15
|
-
def lines_of_log_file
|
16
|
-
File.readlines($log_filename).map(&:chomp) # keyword chomp is not supported by Ruby versions < 2.4
|
17
|
-
end
|
18
|
-
|
19
|
-
Regtest.sample 'first log entry rewrites log file' do
|
20
|
-
Regtest.log 'first log entry'
|
21
|
-
lines_of_log_file
|
22
|
-
end
|
23
|
-
|
24
|
-
Regtest.sample 'second log entry rewrites log file' do
|
25
|
-
Regtest.log 'second log entry', mode: 'w'
|
26
|
-
lines_of_log_file
|
27
|
-
end
|
28
|
-
|
29
|
-
Regtest.sample 'third log entry rewrites log file' do
|
30
|
-
Regtest.log 'third log entry', mode: 'w'
|
31
|
-
lines_of_log_file
|
32
|
-
end
|
data/regtest/log_rewrite.yml
DELETED
data/regtest/metatest.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'fileutils'
|
5
|
-
require 'open3'
|
6
|
-
require 'regtest'
|
7
|
-
require 'tmpdir'
|
8
|
-
|
9
|
-
$my_dir = File.expand_path(__dir__)
|
10
|
-
|
11
|
-
Dir.mktmpdir('regtest') do |tmpdir|
|
12
|
-
Dir.chdir $my_dir do
|
13
|
-
Dir['*.rb'].each do |filename|
|
14
|
-
# Beware of endless recursion.
|
15
|
-
next if filename =~ /metatest/
|
16
|
-
FileUtils.cp filename, tmpdir
|
17
|
-
end
|
18
|
-
end
|
19
|
-
Dir.chdir tmpdir do
|
20
|
-
lib_dir = File.join($my_dir, '../lib')
|
21
|
-
o, e, ps = Open3.capture3(*[{'NOREGTESTRC' => 'true'}, 'ruby', '-I', lib_dir], *Dir['*.rb'].sort)
|
22
|
-
Regtest.sample 'metatest' do
|
23
|
-
res = {'stdout' => o, 'stderr' => e}
|
24
|
-
# Levelling out runtime specific differences.
|
25
|
-
res['stdout'].gsub!(/\d+\.\d+/, 'x.xx')
|
26
|
-
res['stdout'].gsub!(%r(\d+ samples/s), 'x samples/s')
|
27
|
-
res['exitstatus'] = ps.exitstatus
|
28
|
-
res
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/regtest/metatest.yml
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sample: metatest
|
3
|
-
result:
|
4
|
-
stdout: |
|
5
|
-
combinations.yml
|
6
|
-
......
|
7
|
-
examples.yml
|
8
|
-
...
|
9
|
-
filename with spaces.yml
|
10
|
-
.
|
11
|
-
log.yml
|
12
|
-
..
|
13
|
-
log_append.yml
|
14
|
-
...
|
15
|
-
log_rewrite.yml
|
16
|
-
...
|
17
|
-
toplevel.yml
|
18
|
-
.....
|
19
|
-
|
20
|
-
23 samples executed in x.xx s (x samples/s)
|
21
|
-
|
22
|
-
Please check result files manually. Regtest isn't able to do that.
|
23
|
-
stderr: ''
|
24
|
-
exitstatus: 1
|
data/regtest/metatest_git.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
# If git isn't available skip this file
|
5
|
-
begin
|
6
|
-
require 'open3'
|
7
|
-
Open3.capture2e('git --version')
|
8
|
-
|
9
|
-
require 'fileutils'
|
10
|
-
require 'regtest'
|
11
|
-
require 'regtest/git'
|
12
|
-
require 'tmpdir'
|
13
|
-
|
14
|
-
$my_dir = File.expand_path(__dir__)
|
15
|
-
|
16
|
-
def create_sample name
|
17
|
-
lib_dir = File.join($my_dir, '../lib')
|
18
|
-
o, e, ps = Open3.capture3(*[{'NOREGTESTRC' => 'true'}, 'ruby', '-I', lib_dir, '-r', 'regtest/git'], *Dir['*.rb'].sort)
|
19
|
-
Regtest.sample name do
|
20
|
-
res = {'stdout' => o, 'stderr' => e}
|
21
|
-
# Levelling out runtime specific differences.
|
22
|
-
res['stdout'].gsub!(/\d+\.\d+/, 'x.xx')
|
23
|
-
res['stdout'].gsub!(%r(\d+ samples/s), 'x samples/s')
|
24
|
-
res['stdout'].gsub!(/^\?\? filename with spaces.yml$/m, '?? "filename with spaces.yml"')
|
25
|
-
res['exitstatus'] = ps.exitstatus
|
26
|
-
res
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def execute cmd
|
31
|
-
Open3.capture2e cmd
|
32
|
-
end
|
33
|
-
|
34
|
-
NEW_SAMPLE = <<-END
|
35
|
-
|
36
|
-
Regtest.sample 'new sample' do
|
37
|
-
'new sample'
|
38
|
-
end
|
39
|
-
END
|
40
|
-
|
41
|
-
Dir.mktmpdir('regtest') do |tmpdir|
|
42
|
-
Dir.chdir $my_dir do
|
43
|
-
Dir['*.rb'].each do |filename|
|
44
|
-
# Beware of endless recursion.
|
45
|
-
next if filename =~ /metatest/
|
46
|
-
FileUtils.cp filename, tmpdir
|
47
|
-
end
|
48
|
-
end
|
49
|
-
Dir.chdir tmpdir do
|
50
|
-
execute 'git init'
|
51
|
-
create_sample 'all new'
|
52
|
-
execute 'git add *.rb examples.yml combinations.yml'
|
53
|
-
create_sample 'only one new'
|
54
|
-
example_rb = File.read('examples.rb')
|
55
|
-
example_rb << NEW_SAMPLE
|
56
|
-
File.write('examples.rb', example_rb)
|
57
|
-
create_sample 'one new one modified to index'
|
58
|
-
execute 'git commit -m "commit"'
|
59
|
-
create_sample 'one new one modified'
|
60
|
-
execute 'git add *.yml'
|
61
|
-
create_sample 'all in index'
|
62
|
-
execute 'git commit -m "commit"'
|
63
|
-
create_sample 'all commited'
|
64
|
-
end
|
65
|
-
end
|
66
|
-
rescue Errno::ENOENT
|
67
|
-
end
|
data/regtest/metatest_git.yml
DELETED
@@ -1,177 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sample: all new
|
3
|
-
result:
|
4
|
-
stdout: |
|
5
|
-
combinations.yml
|
6
|
-
......
|
7
|
-
examples.yml
|
8
|
-
...
|
9
|
-
filename with spaces.yml
|
10
|
-
.
|
11
|
-
log.yml
|
12
|
-
..
|
13
|
-
log_append.yml
|
14
|
-
...
|
15
|
-
log_rewrite.yml
|
16
|
-
...
|
17
|
-
toplevel.yml
|
18
|
-
.....
|
19
|
-
|
20
|
-
23 samples executed in x.xx s (x samples/s)
|
21
|
-
|
22
|
-
There is at least one new sample result file.
|
23
|
-
?? combinations.yml
|
24
|
-
?? examples.yml
|
25
|
-
?? "filename with spaces.yml"
|
26
|
-
?? log.yml
|
27
|
-
?? log_append.yml
|
28
|
-
?? log_rewrite.yml
|
29
|
-
?? toplevel.yml
|
30
|
-
stderr: ''
|
31
|
-
exitstatus: 1
|
32
|
-
---
|
33
|
-
sample: only one new
|
34
|
-
result:
|
35
|
-
stdout: |
|
36
|
-
combinations.yml
|
37
|
-
......
|
38
|
-
examples.yml
|
39
|
-
...
|
40
|
-
filename with spaces.yml
|
41
|
-
.
|
42
|
-
log.yml
|
43
|
-
..
|
44
|
-
log_append.yml
|
45
|
-
...
|
46
|
-
log_rewrite.yml
|
47
|
-
...
|
48
|
-
toplevel.yml
|
49
|
-
.....
|
50
|
-
|
51
|
-
23 samples executed in x.xx s (x samples/s)
|
52
|
-
|
53
|
-
There is at least one new sample result file.
|
54
|
-
A combinations.yml
|
55
|
-
A examples.yml
|
56
|
-
?? "filename with spaces.yml"
|
57
|
-
?? log.yml
|
58
|
-
?? log_append.yml
|
59
|
-
?? log_rewrite.yml
|
60
|
-
?? toplevel.yml
|
61
|
-
stderr: ''
|
62
|
-
exitstatus: 1
|
63
|
-
---
|
64
|
-
sample: one new one modified to index
|
65
|
-
result:
|
66
|
-
stdout: |
|
67
|
-
combinations.yml
|
68
|
-
......
|
69
|
-
examples.yml
|
70
|
-
....
|
71
|
-
filename with spaces.yml
|
72
|
-
.
|
73
|
-
log.yml
|
74
|
-
..
|
75
|
-
log_append.yml
|
76
|
-
...
|
77
|
-
log_rewrite.yml
|
78
|
-
...
|
79
|
-
toplevel.yml
|
80
|
-
.....
|
81
|
-
|
82
|
-
24 samples executed in x.xx s (x samples/s)
|
83
|
-
|
84
|
-
There are changes in your sample results!
|
85
|
-
A combinations.yml
|
86
|
-
AM examples.yml
|
87
|
-
?? "filename with spaces.yml"
|
88
|
-
?? log.yml
|
89
|
-
?? log_append.yml
|
90
|
-
?? log_rewrite.yml
|
91
|
-
?? toplevel.yml
|
92
|
-
stderr: ''
|
93
|
-
exitstatus: 2
|
94
|
-
---
|
95
|
-
sample: one new one modified
|
96
|
-
result:
|
97
|
-
stdout: |
|
98
|
-
combinations.yml
|
99
|
-
......
|
100
|
-
examples.yml
|
101
|
-
....
|
102
|
-
filename with spaces.yml
|
103
|
-
.
|
104
|
-
log.yml
|
105
|
-
..
|
106
|
-
log_append.yml
|
107
|
-
...
|
108
|
-
log_rewrite.yml
|
109
|
-
...
|
110
|
-
toplevel.yml
|
111
|
-
.....
|
112
|
-
|
113
|
-
24 samples executed in x.xx s (x samples/s)
|
114
|
-
|
115
|
-
There are changes in your sample results!
|
116
|
-
M examples.yml
|
117
|
-
?? "filename with spaces.yml"
|
118
|
-
?? log.yml
|
119
|
-
?? log_append.yml
|
120
|
-
?? log_rewrite.yml
|
121
|
-
?? toplevel.yml
|
122
|
-
stderr: ''
|
123
|
-
exitstatus: 2
|
124
|
-
---
|
125
|
-
sample: all in index
|
126
|
-
result:
|
127
|
-
stdout: |
|
128
|
-
combinations.yml
|
129
|
-
......
|
130
|
-
examples.yml
|
131
|
-
....
|
132
|
-
filename with spaces.yml
|
133
|
-
.
|
134
|
-
log.yml
|
135
|
-
..
|
136
|
-
log_append.yml
|
137
|
-
...
|
138
|
-
log_rewrite.yml
|
139
|
-
...
|
140
|
-
toplevel.yml
|
141
|
-
.....
|
142
|
-
|
143
|
-
24 samples executed in x.xx s (x samples/s)
|
144
|
-
|
145
|
-
Looks good. :)
|
146
|
-
M examples.yml
|
147
|
-
A "filename with spaces.yml"
|
148
|
-
A log.yml
|
149
|
-
A log_append.yml
|
150
|
-
A log_rewrite.yml
|
151
|
-
A toplevel.yml
|
152
|
-
stderr: ''
|
153
|
-
exitstatus: 0
|
154
|
-
---
|
155
|
-
sample: all commited
|
156
|
-
result:
|
157
|
-
stdout: |
|
158
|
-
combinations.yml
|
159
|
-
......
|
160
|
-
examples.yml
|
161
|
-
....
|
162
|
-
filename with spaces.yml
|
163
|
-
.
|
164
|
-
log.yml
|
165
|
-
..
|
166
|
-
log_append.yml
|
167
|
-
...
|
168
|
-
log_rewrite.yml
|
169
|
-
...
|
170
|
-
toplevel.yml
|
171
|
-
.....
|
172
|
-
|
173
|
-
24 samples executed in x.xx s (x samples/s)
|
174
|
-
|
175
|
-
Looks good. :)
|
176
|
-
stderr: ''
|
177
|
-
exitstatus: 0
|
data/regtest/no_samples.rb
DELETED
data/regtest/toplevel.log
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.65204510187786
|
data/regtest/toplevel.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'regtest'
|
5
|
-
|
6
|
-
methods_before = methods
|
7
|
-
|
8
|
-
extend Regtest
|
9
|
-
|
10
|
-
methods_after = methods
|
11
|
-
|
12
|
-
Regtest.sample "Toplevel methods defined by 'extend Regtest'" do
|
13
|
-
(methods_after - methods_before).map(&:to_s).sort
|
14
|
-
end
|
15
|
-
|
16
|
-
Regtest.sample 'metatest' do
|
17
|
-
sample 'sample works at toplevel' do
|
18
|
-
true
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
Regtest.sample 'combinations work at toplevel' do
|
23
|
-
combinations(x: %w(a b), y: [1,2]).map(&:to_h)
|
24
|
-
end
|
25
|
-
|
26
|
-
Regtest.sample 'log works at toplevel' do
|
27
|
-
f = rand.to_s
|
28
|
-
log f
|
29
|
-
File.read(__FILE__.sub(/\.rb$/, '.log')).chomp == f
|
30
|
-
end
|
data/regtest/toplevel.yml
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sample: Toplevel methods defined by 'extend Regtest'
|
3
|
-
result:
|
4
|
-
- combinations
|
5
|
-
- log
|
6
|
-
- sample
|
7
|
-
---
|
8
|
-
sample: sample works at toplevel
|
9
|
-
result: true
|
10
|
-
---
|
11
|
-
sample: metatest
|
12
|
-
result:
|
13
|
-
sample: sample works at toplevel
|
14
|
-
result: true
|
15
|
-
---
|
16
|
-
sample: combinations work at toplevel
|
17
|
-
result:
|
18
|
-
- :x: a
|
19
|
-
:y: 1
|
20
|
-
- :x: a
|
21
|
-
:y: 2
|
22
|
-
- :x: b
|
23
|
-
:y: 1
|
24
|
-
- :x: b
|
25
|
-
:y: 2
|
26
|
-
---
|
27
|
-
sample: log works at toplevel
|
28
|
-
result: true
|