judges 0.6.0 ā 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/copyrights.yml +1 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/README.md +8 -0
- data/features/test.feature +19 -0
- data/judges.gemspec +1 -1
- data/lib/judges/churn.rb +60 -0
- data/lib/judges/commands/test.rb +1 -1
- data/lib/judges/commands/update.rb +8 -28
- data/lib/judges.rb +1 -1
- data/test/test_churn.rb +38 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c525e90c9ec78d8d7b745c026e07d033427b6193e185bd28d2edc153f254c863
|
4
|
+
data.tar.gz: bff22a2e3f8d9813261f76df90a7087454e393e66f997822717422d4ddfdc084
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a490f1f175fdf0e663ae3f104c2901b86eed9e6d9b16192e59829802a821ae0cec67dc9a72400d7d40f2be228e3c8323508c8e7a210c1f562db0055d4e1a762
|
7
|
+
data.tar.gz: 3ec540d2d05fae0b620a3ee89ac4c1dad8d06cd3387cca7a4076490b9710bedcece3a373500208517ac47f0d14469444c60c783f810227045e7ae831a404aaa5
|
data/Gemfile
CHANGED
@@ -30,7 +30,7 @@ gem 'rake', '13.2.1', require: false
|
|
30
30
|
gem 'rspec-rails', '6.1.2', require: false
|
31
31
|
gem 'rubocop', '1.64.1', require: false
|
32
32
|
gem 'rubocop-performance', '1.21.0', require: false
|
33
|
-
gem 'rubocop-rspec', '2.
|
33
|
+
gem 'rubocop-rspec', '2.31.0', require: false
|
34
34
|
gem 'simplecov', '0.22.0', require: false
|
35
35
|
gem 'simplecov-cobertura', '2.1.0', require: false
|
36
36
|
gem 'webmock', '3.23.1', require: false
|
data/Gemfile.lock
CHANGED
@@ -209,7 +209,7 @@ GEM
|
|
209
209
|
rubocop-performance (1.21.0)
|
210
210
|
rubocop (>= 1.48.1, < 2.0)
|
211
211
|
rubocop-ast (>= 1.31.1, < 2.0)
|
212
|
-
rubocop-rspec (2.
|
212
|
+
rubocop-rspec (2.31.0)
|
213
213
|
rubocop (~> 1.40)
|
214
214
|
rubocop-capybara (~> 2.17)
|
215
215
|
rubocop-factory_bot (~> 2.22)
|
@@ -263,7 +263,7 @@ DEPENDENCIES
|
|
263
263
|
rspec-rails (= 6.1.2)
|
264
264
|
rubocop (= 1.64.1)
|
265
265
|
rubocop-performance (= 1.21.0)
|
266
|
-
rubocop-rspec (= 2.
|
266
|
+
rubocop-rspec (= 2.31.0)
|
267
267
|
simplecov (= 0.22.0)
|
268
268
|
simplecov-cobertura (= 2.1.0)
|
269
269
|
webmock (= 3.23.1)
|
data/README.md
CHANGED
@@ -34,6 +34,8 @@ global variables available to it:
|
|
34
34
|
Every `.yml` file must be formatted as such:
|
35
35
|
|
36
36
|
```yaml
|
37
|
+
category: slow
|
38
|
+
runs: 1
|
37
39
|
skip: false
|
38
40
|
input:
|
39
41
|
-
|
@@ -52,6 +54,12 @@ via the command line `--option` flag of the `update` command; and `expected` is
|
|
52
54
|
an array of XPath expressions that must be present in the XML of the Factbase
|
53
55
|
when the test is finished.
|
54
56
|
|
57
|
+
The `category` (default: `[]`) may have one or an array of categories,
|
58
|
+
which then may be turned on via the `--category` command line flag.
|
59
|
+
|
60
|
+
The `runs` (default: `1`) is the number of times the `.rb` script should
|
61
|
+
be executed. After each execution, all expected XPath expressions are validated.
|
62
|
+
|
55
63
|
## How to contribute
|
56
64
|
|
57
65
|
Read
|
data/features/test.feature
CHANGED
@@ -47,6 +47,25 @@ Feature: Test
|
|
47
47
|
Then Stdout contains "All 1 judge(s) and 1 tests passed"
|
48
48
|
And Exit code is zero
|
49
49
|
|
50
|
+
Scenario: Simple test with two runs
|
51
|
+
Given I make a temp directory
|
52
|
+
Then I have a "foo/simple.rb" file with content:
|
53
|
+
"""
|
54
|
+
n = $fb.insert
|
55
|
+
n.foo = $fb.size
|
56
|
+
"""
|
57
|
+
Then I have a "foo/good.yml" file with content:
|
58
|
+
"""
|
59
|
+
---
|
60
|
+
runs: 3
|
61
|
+
input: []
|
62
|
+
expected:
|
63
|
+
- /fb/f[foo=count(/fb/f)]
|
64
|
+
"""
|
65
|
+
Then I run bin/judges with "test ."
|
66
|
+
Then Stdout contains "All 1 judge(s) and 1 tests passed"
|
67
|
+
And Exit code is zero
|
68
|
+
|
50
69
|
Scenario: Enable only one category
|
51
70
|
Given I make a temp directory
|
52
71
|
Then I have a "mine/good/good.rb" file with content:
|
data/judges.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
27
27
|
s.required_ruby_version = '>=3.2'
|
28
28
|
s.name = 'judges'
|
29
|
-
s.version = '0.
|
29
|
+
s.version = '0.7.0'
|
30
30
|
s.license = 'MIT'
|
31
31
|
s.summary = 'Command-Line Tool for a Factbase'
|
32
32
|
s.description =
|
data/lib/judges/churn.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
|
23
|
+
require_relative '../judges'
|
24
|
+
|
25
|
+
# How many facts were modified.
|
26
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
27
|
+
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
28
|
+
# License:: MIT
|
29
|
+
class Judges::Churn
|
30
|
+
attr_reader :added, :removed
|
31
|
+
|
32
|
+
def initialize(added, removed)
|
33
|
+
@added = added
|
34
|
+
@removed = removed
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_s
|
38
|
+
"#{@added}/#{@removed}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def zero?
|
42
|
+
@added.zero? && @removed.zero?
|
43
|
+
end
|
44
|
+
|
45
|
+
def +(other)
|
46
|
+
if other.is_a?(Judges::Churn)
|
47
|
+
Judges::Churn.new(@added + other.added, @removed + other.removed)
|
48
|
+
else
|
49
|
+
Judges::Churn.new(@added + other, @removed)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def -(other)
|
54
|
+
if other.is_a?(Judges::Churn)
|
55
|
+
Judges::Churn.new(@added - other.added, @removed - other.removed)
|
56
|
+
else
|
57
|
+
Judges::Churn.new(@added, @removed + other)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/judges/commands/test.rb
CHANGED
@@ -122,7 +122,7 @@ class Judges::Test
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
options = Judges::Options.new(opts['option']) + Judges::Options.new(yaml['options'])
|
125
|
-
(1..(opts['runs'] || 1)).each do
|
125
|
+
(1..(opts['runs'] || yaml['runs'] || 1)).each do
|
126
126
|
judge.run(Factbase::Looged.new(fb, @loog), {}, {}, options)
|
127
127
|
end
|
128
128
|
xpaths = yaml['expected']
|
@@ -25,6 +25,7 @@ require 'factbase/looged'
|
|
25
25
|
require_relative '../../judges'
|
26
26
|
require_relative '../../judges/to_rel'
|
27
27
|
require_relative '../../judges/judges'
|
28
|
+
require_relative '../../judges/churn'
|
28
29
|
require_relative '../../judges/options'
|
29
30
|
require_relative '../../judges/impex'
|
30
31
|
require_relative '../../judges/elapsed'
|
@@ -72,42 +73,21 @@ class Judges::Update
|
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
75
|
-
# How many facts were modified.
|
76
|
-
class Churn
|
77
|
-
attr_reader :added, :removed
|
78
|
-
|
79
|
-
def initialize(added, removed)
|
80
|
-
@added = added
|
81
|
-
@removed = removed
|
82
|
-
end
|
83
|
-
|
84
|
-
def to_s
|
85
|
-
"#{@added}/-#{@removed}"
|
86
|
-
end
|
87
|
-
|
88
|
-
def zero?
|
89
|
-
@added.zero? && @removed.zero?
|
90
|
-
end
|
91
|
-
|
92
|
-
def +(other)
|
93
|
-
Churn.new(@added + other.added, @removed + other.removed)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
76
|
private
|
98
77
|
|
99
78
|
# Run all judges in a full cycle, one by one.
|
100
79
|
# @return [Churn] How many modifications have been made
|
101
80
|
def cycle(opts, judges, fb, options)
|
102
81
|
errors = []
|
103
|
-
churn = Churn.new(0, 0)
|
82
|
+
churn = Judges::Churn.new(0, 0)
|
104
83
|
global = {}
|
105
84
|
elapsed(@loog) do
|
106
85
|
done = judges.each_with_index do |p, i|
|
107
|
-
@loog.info("\nš Running #{p.name} (##{i}) at #{p.dir.to_rel}...")
|
86
|
+
@loog.info("\n\nš Running #{p.name} (##{i}) at #{p.dir.to_rel}...")
|
108
87
|
elapsed(@loog) do
|
109
|
-
|
110
|
-
|
88
|
+
c = one_judge(fb, p, global, options)
|
89
|
+
churn += c
|
90
|
+
throw :"š The judge #{p.name} modified #{c} facts"
|
111
91
|
end
|
112
92
|
rescue StandardError, SyntaxError => e
|
113
93
|
@loog.warn(Backtrace.new(e))
|
@@ -132,9 +112,9 @@ class Judges::Update
|
|
132
112
|
after = fb.size
|
133
113
|
diff = after - before
|
134
114
|
if diff.positive?
|
135
|
-
Churn.new(diff, 0)
|
115
|
+
Judges::Churn.new(diff, 0)
|
136
116
|
else
|
137
|
-
Churn.new(0, -diff)
|
117
|
+
Judges::Churn.new(0, -diff)
|
138
118
|
end
|
139
119
|
end
|
140
120
|
end
|
data/lib/judges.rb
CHANGED
data/test/test_churn.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2024 Yegor Bugayenko
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
|
23
|
+
require 'minitest/autorun'
|
24
|
+
require_relative '../lib/judges'
|
25
|
+
require_relative '../lib/judges/churn'
|
26
|
+
|
27
|
+
# Test.
|
28
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
29
|
+
# Copyright:: Copyright (c) 2024 Yegor Bugayenko
|
30
|
+
# License:: MIT
|
31
|
+
class TestChurn < Minitest::Test
|
32
|
+
def test_basic
|
33
|
+
churn = Judges::Churn.new(0, 0)
|
34
|
+
assert_equal('0/0', churn.to_s)
|
35
|
+
assert_equal('42/0', (churn + 42).to_s)
|
36
|
+
assert_equal('0/17', (churn - 17).to_s)
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: judges
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- lib/judges.rb
|
191
191
|
- lib/judges/baza.rb
|
192
192
|
- lib/judges/categories.rb
|
193
|
+
- lib/judges/churn.rb
|
193
194
|
- lib/judges/commands/eval.rb
|
194
195
|
- lib/judges/commands/import.rb
|
195
196
|
- lib/judges/commands/inspect.rb
|
@@ -220,6 +221,7 @@ files:
|
|
220
221
|
- test/test__helper.rb
|
221
222
|
- test/test_baza.rb
|
222
223
|
- test/test_categories.rb
|
224
|
+
- test/test_churn.rb
|
223
225
|
- test/test_impex.rb
|
224
226
|
- test/test_judge.rb
|
225
227
|
- test/test_judges.rb
|