judges 0.0.24 ā†’ 0.0.25

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
  SHA256:
3
- metadata.gz: ed5fca9c346d6f092bde73a242e8b347f2abba9f7330767db25edca3d1df1dd3
4
- data.tar.gz: cbb70db60a4dc7c953cfa6feea4d5955a27f76cf34b3c5403423e8e3b804db84
3
+ metadata.gz: 2326cabc04af248b0125f37645bd07fce0d9f19633f6ebaa10fdcf134da35b73
4
+ data.tar.gz: ede2d649e85f3d5f637daaa963bf56887b2150345ede96bb7fd4c53f7e5f1400
5
5
  SHA512:
6
- metadata.gz: c6d4dffa49971e1dc77788263b005d843223bf96faba1cb67333b773f411fdd9b6920577f1edaab9ae9e6fcb7191c37febc2b1ae0ee55d6fa272f45f36242aa2
7
- data.tar.gz: a0cde0d189d3ae6bf15da5252fb03dc530103de68adeb2379dc048a2354987bb5371863352640a64cc04663db5b4c099ff7ae474f793ce4ff7f6589f5f0b4da5
6
+ metadata.gz: 5ed7d4a0d763cd9f1a5a565033cd42e69e8d52b113f8b117832861ad8d9c22194667ef6759aa8c4c8806cc754435a3cb9583c9951183eba01c7cb3f4aa83f03e
7
+ data.tar.gz: f3bfaee1fe32ff3315a533dc67019edc9e6c7fbb22db758917a17c0a643dc0a60a69e2e3641d9a954c426e39c928bef098ff1309dad18ce14bd69cf77aa061b0
@@ -19,7 +19,7 @@
19
19
  # SOFTWARE.
20
20
  ---
21
21
  name: codecov
22
- on:
22
+ 'on':
23
23
  push:
24
24
  branches:
25
25
  - master
@@ -31,7 +31,8 @@ jobs:
31
31
  - uses: ruby/setup-ruby@v1
32
32
  with:
33
33
  ruby-version: 3.2
34
- - run: bundle update
34
+ bundler-cache: true
35
+ - run: bundle install
35
36
  - run: bundle exec rake
36
37
  - uses: codecov/codecov-action@v4.0.0-beta.3
37
38
  with:
@@ -31,7 +31,7 @@ jobs:
31
31
  name: test
32
32
  strategy:
33
33
  matrix:
34
- os: [ubuntu-20.04, macos-12]
34
+ os: [ubuntu-20.04, macos-12, windows-2022]
35
35
  ruby: [3.2]
36
36
  runs-on: ${{ matrix.os }}
37
37
  steps:
@@ -39,5 +39,6 @@ jobs:
39
39
  - uses: ruby/setup-ruby@v1
40
40
  with:
41
41
  ruby-version: ${{ matrix.ruby }}
42
- - run: bundle update
42
+ bundler-cache: true
43
+ - run: bundle install
43
44
  - run: bundle exec rake
data/.gitignore CHANGED
@@ -1,5 +1,4 @@
1
1
  coverage/
2
- Gemfile.lock
3
2
  .idea/
4
3
  *.gem
5
4
  .bundle/
data/.rubocop.yml CHANGED
@@ -22,6 +22,7 @@ AllCops:
22
22
  Exclude:
23
23
  - 'bin/**/*'
24
24
  - 'assets/**/*'
25
+ - 'vendor/**/*'
25
26
  DisplayCopNames: true
26
27
  TargetRubyVersion: 3.2
27
28
  SuggestExtensions: false
@@ -51,3 +52,5 @@ Layout/CaseIndentation:
51
52
  Enabled: false
52
53
  Naming/MethodParameterName:
53
54
  MinNameLength: 2
55
+ Layout/EndOfLine:
56
+ EnforcedStyle: lf
data/Gemfile CHANGED
@@ -28,6 +28,7 @@ gem 'minitest', '5.23.0', require: false
28
28
  gem 'rake', '13.2.1', require: false
29
29
  gem 'rspec-rails', '6.1.2', require: false
30
30
  gem 'rubocop', '1.63.5', require: false
31
+ gem 'rubocop-performance', '1.21.0', require: false
31
32
  gem 'rubocop-rspec', '2.29.2', require: false
32
33
  gem 'simplecov', '0.22.0', require: false
33
34
  gem 'simplecov-cobertura', '2.1.0', require: false
data/Gemfile.lock ADDED
@@ -0,0 +1,235 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ judges (0.0.0)
5
+ backtrace (~> 0.3)
6
+ factbase (~> 0.0.22)
7
+ gli (~> 2.21)
8
+ loog (~> 0.2)
9
+ nokogiri (~> 1.10)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ actionpack (7.1.3.3)
15
+ actionview (= 7.1.3.3)
16
+ activesupport (= 7.1.3.3)
17
+ nokogiri (>= 1.8.5)
18
+ racc
19
+ rack (>= 2.2.4)
20
+ rack-session (>= 1.0.1)
21
+ rack-test (>= 0.6.3)
22
+ rails-dom-testing (~> 2.2)
23
+ rails-html-sanitizer (~> 1.6)
24
+ actionview (7.1.3.3)
25
+ activesupport (= 7.1.3.3)
26
+ builder (~> 3.1)
27
+ erubi (~> 1.11)
28
+ rails-dom-testing (~> 2.2)
29
+ rails-html-sanitizer (~> 1.6)
30
+ activesupport (7.1.3.3)
31
+ base64
32
+ bigdecimal
33
+ concurrent-ruby (~> 1.0, >= 1.0.2)
34
+ connection_pool (>= 2.2.5)
35
+ drb
36
+ i18n (>= 1.6, < 2)
37
+ minitest (>= 5.1)
38
+ mutex_m
39
+ tzinfo (~> 2.0)
40
+ ast (2.4.2)
41
+ backtrace (0.4.0)
42
+ base64 (0.2.0)
43
+ bigdecimal (3.1.8)
44
+ builder (3.2.4)
45
+ concurrent-ruby (1.2.3)
46
+ connection_pool (2.4.1)
47
+ crass (1.0.6)
48
+ cucumber (9.2.0)
49
+ builder (~> 3.2)
50
+ cucumber-ci-environment (> 9, < 11)
51
+ cucumber-core (> 13, < 14)
52
+ cucumber-cucumber-expressions (~> 17.0)
53
+ cucumber-gherkin (> 24, < 28)
54
+ cucumber-html-formatter (> 20.3, < 22)
55
+ cucumber-messages (> 19, < 25)
56
+ diff-lcs (~> 1.5)
57
+ mini_mime (~> 1.1)
58
+ multi_test (~> 1.1)
59
+ sys-uname (~> 1.2)
60
+ cucumber-ci-environment (10.0.1)
61
+ cucumber-core (13.0.2)
62
+ cucumber-gherkin (>= 27, < 28)
63
+ cucumber-messages (>= 20, < 23)
64
+ cucumber-tag-expressions (> 5, < 7)
65
+ cucumber-cucumber-expressions (17.1.0)
66
+ bigdecimal
67
+ cucumber-gherkin (27.0.0)
68
+ cucumber-messages (>= 19.1.4, < 23)
69
+ cucumber-html-formatter (21.3.1)
70
+ cucumber-messages (> 19, < 25)
71
+ cucumber-messages (22.0.0)
72
+ cucumber-tag-expressions (6.1.0)
73
+ diff-lcs (1.5.1)
74
+ docile (1.4.0)
75
+ drb (2.2.1)
76
+ erubi (1.12.0)
77
+ factbase (0.0.22)
78
+ json (~> 2.7)
79
+ loog (~> 0.2)
80
+ nokogiri (~> 1.10)
81
+ yaml (~> 0.3)
82
+ ffi (1.16.3)
83
+ ffi (1.16.3-x64-mingw-ucrt)
84
+ gli (2.21.1)
85
+ i18n (1.14.5)
86
+ concurrent-ruby (~> 1.0)
87
+ io-console (0.7.2)
88
+ irb (1.13.1)
89
+ rdoc (>= 4.0.0)
90
+ reline (>= 0.4.2)
91
+ json (2.7.2)
92
+ language_server-protocol (3.17.0.3)
93
+ loofah (2.22.0)
94
+ crass (~> 1.0.2)
95
+ nokogiri (>= 1.12.0)
96
+ loog (0.5.1)
97
+ mini_mime (1.1.5)
98
+ minitest (5.23.0)
99
+ multi_test (1.1.0)
100
+ mutex_m (0.2.0)
101
+ nokogiri (1.16.5-arm64-darwin)
102
+ racc (~> 1.4)
103
+ nokogiri (1.16.5-x64-mingw-ucrt)
104
+ racc (~> 1.4)
105
+ nokogiri (1.16.5-x86_64-darwin)
106
+ racc (~> 1.4)
107
+ nokogiri (1.16.5-x86_64-linux)
108
+ racc (~> 1.4)
109
+ parallel (1.24.0)
110
+ parser (3.3.1.0)
111
+ ast (~> 2.4.1)
112
+ racc
113
+ psych (5.1.2)
114
+ stringio
115
+ racc (1.7.3)
116
+ rack (3.0.11)
117
+ rack-session (2.0.0)
118
+ rack (>= 3.0.0)
119
+ rack-test (2.1.0)
120
+ rack (>= 1.3)
121
+ rackup (2.1.0)
122
+ rack (>= 3)
123
+ webrick (~> 1.8)
124
+ rails-dom-testing (2.2.0)
125
+ activesupport (>= 5.0.0)
126
+ minitest
127
+ nokogiri (>= 1.6)
128
+ rails-html-sanitizer (1.6.0)
129
+ loofah (~> 2.21)
130
+ nokogiri (~> 1.14)
131
+ railties (7.1.3.3)
132
+ actionpack (= 7.1.3.3)
133
+ activesupport (= 7.1.3.3)
134
+ irb
135
+ rackup (>= 1.0.0)
136
+ rake (>= 12.2)
137
+ thor (~> 1.0, >= 1.2.2)
138
+ zeitwerk (~> 2.6)
139
+ rainbow (3.1.1)
140
+ rake (13.2.1)
141
+ rdoc (6.6.3.1)
142
+ psych (>= 4.0.0)
143
+ regexp_parser (2.9.2)
144
+ reline (0.5.7)
145
+ io-console (~> 0.5)
146
+ rexml (3.2.8)
147
+ strscan (>= 3.0.9)
148
+ rspec-core (3.13.0)
149
+ rspec-support (~> 3.13.0)
150
+ rspec-expectations (3.13.0)
151
+ diff-lcs (>= 1.2.0, < 2.0)
152
+ rspec-support (~> 3.13.0)
153
+ rspec-mocks (3.13.1)
154
+ diff-lcs (>= 1.2.0, < 2.0)
155
+ rspec-support (~> 3.13.0)
156
+ rspec-rails (6.1.2)
157
+ actionpack (>= 6.1)
158
+ activesupport (>= 6.1)
159
+ railties (>= 6.1)
160
+ rspec-core (~> 3.13)
161
+ rspec-expectations (~> 3.13)
162
+ rspec-mocks (~> 3.13)
163
+ rspec-support (~> 3.13)
164
+ rspec-support (3.13.1)
165
+ rubocop (1.63.5)
166
+ json (~> 2.3)
167
+ language_server-protocol (>= 3.17.0)
168
+ parallel (~> 1.10)
169
+ parser (>= 3.3.0.2)
170
+ rainbow (>= 2.2.2, < 4.0)
171
+ regexp_parser (>= 1.8, < 3.0)
172
+ rexml (>= 3.2.5, < 4.0)
173
+ rubocop-ast (>= 1.31.1, < 2.0)
174
+ ruby-progressbar (~> 1.7)
175
+ unicode-display_width (>= 2.4.0, < 3.0)
176
+ rubocop-ast (1.31.3)
177
+ parser (>= 3.3.1.0)
178
+ rubocop-capybara (2.20.0)
179
+ rubocop (~> 1.41)
180
+ rubocop-factory_bot (2.25.1)
181
+ rubocop (~> 1.41)
182
+ rubocop-performance (1.21.0)
183
+ rubocop (>= 1.48.1, < 2.0)
184
+ rubocop-ast (>= 1.31.1, < 2.0)
185
+ rubocop-rspec (2.29.2)
186
+ rubocop (~> 1.40)
187
+ rubocop-capybara (~> 2.17)
188
+ rubocop-factory_bot (~> 2.22)
189
+ rubocop-rspec_rails (~> 2.28)
190
+ rubocop-rspec_rails (2.28.3)
191
+ rubocop (~> 1.40)
192
+ ruby-progressbar (1.13.0)
193
+ simplecov (0.22.0)
194
+ docile (~> 1.1)
195
+ simplecov-html (~> 0.11)
196
+ simplecov_json_formatter (~> 0.1)
197
+ simplecov-cobertura (2.1.0)
198
+ rexml
199
+ simplecov (~> 0.19)
200
+ simplecov-html (0.12.3)
201
+ simplecov_json_formatter (0.1.4)
202
+ stringio (3.1.0)
203
+ strscan (3.1.0)
204
+ sys-uname (1.2.3)
205
+ ffi (~> 1.1)
206
+ thor (1.3.1)
207
+ tzinfo (2.0.6)
208
+ concurrent-ruby (~> 1.0)
209
+ unicode-display_width (2.5.0)
210
+ webrick (1.8.1)
211
+ yaml (0.3.0)
212
+ yard (0.9.36)
213
+ zeitwerk (2.6.14)
214
+
215
+ PLATFORMS
216
+ arm64-darwin-22
217
+ x64-mingw-ucrt
218
+ x86_64-darwin-20
219
+ x86_64-linux
220
+
221
+ DEPENDENCIES
222
+ cucumber (= 9.2.0)
223
+ judges!
224
+ minitest (= 5.23.0)
225
+ rake (= 13.2.1)
226
+ rspec-rails (= 6.1.2)
227
+ rubocop (= 1.63.5)
228
+ rubocop-performance (= 1.21.0)
229
+ rubocop-rspec (= 2.29.2)
230
+ simplecov (= 0.22.0)
231
+ simplecov-cobertura (= 2.1.0)
232
+ yard (= 0.9.36)
233
+
234
+ BUNDLED WITH
235
+ 2.4.22
data/README.md CHANGED
@@ -14,6 +14,41 @@
14
14
  A command line tool and a Ruby gem for running judges agains a
15
15
  [factbase](https://github.com/yegor256/factbase).
16
16
 
17
+ Every "judge" is a directory with a single `.rb` file and a number
18
+ of `.yml` files. A script in the Ruby file is executed with the following
19
+ global variables available to it:
20
+
21
+ * `$fb` ā€” an instance
22
+ of [`Factbase`](https://www.rubydoc.info/gems/factbase/0.0.22/Factbase),
23
+ where facts may be added/updated;
24
+ * `$loog` ā€” an instance
25
+ of [`Loog`](https://www.rubydoc.info/gems/loog/0.5.1/Loog),
26
+ where `.info` and `.debug` logs are welcome;
27
+ * `$options` ā€” a holder of options coming from `.yml` files;
28
+ * `$local` ā€” a hash map that is cleaned up when all tests
29
+ in the pack are finished;
30
+ * `$global` ā€” a hash map that is never cleaned up;
31
+ * `$judge` ā€” the name of the directory, where the `.rb` script is located.
32
+
33
+ Every `.yml` file must be formatted as such:
34
+
35
+ ```yaml
36
+ input:
37
+ -
38
+ foo: 42
39
+ bar: Hello, world!
40
+ options:
41
+ max: 100
42
+ expected:
43
+ - /fb[count(f)=1]
44
+ ```
45
+
46
+ Here, the `input` is an array of facts to be placed into the Factbase before
47
+ the test starts; the `options` is a hash map of options to be passed
48
+ via command line `--option` of the `update` command; and `expected` is
49
+ an array of XPath expressions that must be present in the XML of the Factbase
50
+ when the test is finished.
51
+
17
52
  ## How to contribute
18
53
 
19
54
  Read
data/bin/judges CHANGED
@@ -32,7 +32,7 @@ Encoding.default_internal = Encoding::UTF_8
32
32
  class App
33
33
  extend GLI::App
34
34
 
35
- ver = '0.0.24'
35
+ ver = '0.0.25'
36
36
 
37
37
  loog = Loog::REGULAR
38
38
 
@@ -47,7 +47,9 @@ end
47
47
 
48
48
  When(%r{^I run bin/judges with "([^"]*)"$}) do |arg|
49
49
  home = File.join(File.dirname(__FILE__), '../..')
50
- @stdout = `GLI_DEBUG=true ruby -I#{home}/lib #{home}/bin/judges #{arg}`
50
+ cmd = "ruby -I#{home}/lib #{home}/bin/judges #{arg}"
51
+ cmd = "GLI_DEBUG=true #{cmd}" unless Gem.win_platform?
52
+ @stdout = `#{cmd}`
51
53
  @exitstatus = $CHILD_STATUS.exitstatus
52
54
  end
53
55
 
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.0.24'
29
+ s.version = '0.0.25'
30
30
  s.license = 'MIT'
31
31
  s.summary = 'Command-Line Tool for a Factbase'
32
32
  s.description = '
@@ -44,14 +44,16 @@ class Judges::Test
44
44
  @loog.info("Testing judges in #{dir.to_rel}...")
45
45
  errors = []
46
46
  done = 0
47
+ global = {}
47
48
  Judges::Packs.new(dir, opts['lib'], @loog).each_with_index do |p, i|
49
+ local = {}
48
50
  next unless include?(opts, p.name)
49
51
  @loog.info("\nšŸ‘‰ Testing #{p.script} (##{i}) in #{p.dir.to_rel}...")
50
52
  p.tests.each do |f|
51
53
  yaml = YAML.load_file(f, permitted_classes: [Time])
52
54
  @loog.info("Testing #{f.to_rel}:")
53
55
  begin
54
- test_one(p, yaml)
56
+ test_one(p, global, local, yaml)
55
57
  rescue StandardError => e
56
58
  @loog.warn(Backtrace.new(e))
57
59
  errors << f
@@ -78,7 +80,7 @@ class Judges::Test
78
80
  packs.include?(name)
79
81
  end
80
82
 
81
- def test_one(pack, yaml)
83
+ def test_one(pack, global, local, yaml)
82
84
  fb = Factbase.new
83
85
  yaml['input'].each do |i|
84
86
  f = fb.insert
@@ -92,7 +94,7 @@ class Judges::Test
92
94
  end
93
95
  end
94
96
  end
95
- pack.run(Factbase::Looged.new(fb, @loog), Judges::Options.new(yaml['options']))
97
+ pack.run(Factbase::Looged.new(fb, @loog), global, local, Judges::Options.new(yaml['options']))
96
98
  xml = Nokogiri::XML.parse(fb.to_xml)
97
99
  yaml['expected'].each do |xp|
98
100
  raise "#{pack.script} doesn't match '#{xp}':\n#{xml}" if xml.xpath(xp).empty?
@@ -66,11 +66,13 @@ class Judges::Update
66
66
  def cycle(packs, fb, impex, options)
67
67
  errors = []
68
68
  diff = 0
69
+ global = {}
69
70
  done = packs.each_with_index do |p, i|
71
+ local = {}
70
72
  @loog.info("šŸ‘‰ Running #{p.name} (##{i}) at #{p.dir.to_rel}...")
71
73
  before = fb.size
72
74
  begin
73
- p.run(fb, options)
75
+ p.run(fb, global, local, options)
74
76
  rescue StandardError => e
75
77
  @loog.warn(Backtrace.new(e))
76
78
  errors << p.script
data/lib/judges/pack.rb CHANGED
@@ -39,11 +39,13 @@ class Judges::Pack
39
39
  end
40
40
 
41
41
  # Run it with the given Factbase and environment variables.
42
- def run(fbase, options)
42
+ def run(fbase, global, local, options)
43
43
  $fb = fbase
44
44
  $judge = File.basename(@dir)
45
45
  $options = options
46
46
  $loog = @loog
47
+ $global = global
48
+ $local = local
47
49
  unless @lib.nil?
48
50
  raise "Lib dir #{@lib.to_rel} is absent" unless File.exist?(@lib)
49
51
  raise "Lib #{@lib.to_rel} is not a directory" unless File.directory?(@lib)
data/test/test_pack.rb CHANGED
@@ -37,7 +37,7 @@ class TestPack < Minitest::Test
37
37
  File.write(File.join(d, 'foo.rb'), '$fb.insert')
38
38
  pack = Judges::Pack.new(d, nil, Loog::VERBOSE)
39
39
  fb = Factbase.new
40
- pack.run(fb, {})
40
+ pack.run(fb, {}, {}, {})
41
41
  assert_equal(1, fb.size)
42
42
  end
43
43
  end
@@ -47,10 +47,10 @@ class TestPack < Minitest::Test
47
47
  File.write(File.join(d, 'bar.rb'), '$fb.insert')
48
48
  pack = Judges::Pack.new(d, nil, Loog::VERBOSE)
49
49
  fb1 = Factbase.new
50
- pack.run(fb1, {})
50
+ pack.run(fb1, {}, {}, {})
51
51
  assert_equal(1, fb1.size)
52
52
  fb2 = Factbase.new
53
- pack.run(fb2, {})
53
+ pack.run(fb2, {}, {}, {})
54
54
  assert_equal(1, fb2.size)
55
55
  end
56
56
  end
@@ -59,7 +59,25 @@ class TestPack < Minitest::Test
59
59
  Dir.mktmpdir do |d|
60
60
  File.write(File.join(d, 'x.rb'), 'once($fb).insert')
61
61
  pack = Judges::Pack.new(d, nil, Loog::VERBOSE)
62
- pack.run(Factbase.new, {})
62
+ pack.run(Factbase.new, {}, {}, {})
63
+ end
64
+ end
65
+
66
+ def test_passes_local_vars_between_tests
67
+ Dir.mktmpdir do |d|
68
+ File.write(
69
+ File.join(d, 'x.rb'),
70
+ '
71
+ $local[:foo] = 42 if $local[:foo].nil?
72
+ $local[:foo] = $local[:foo] + 1
73
+ '
74
+ )
75
+ pack = Judges::Pack.new(d, nil, Loog::NULL)
76
+ local = {}
77
+ pack.run(Factbase.new, {}, local, {})
78
+ pack.run(Factbase.new, {}, local, {})
79
+ pack.run(Factbase.new, {}, local, {})
80
+ assert_equal(45, local[:foo])
63
81
  end
64
82
  end
65
83
 
@@ -70,7 +88,7 @@ class TestPack < Minitest::Test
70
88
  FileUtils.mkdir(dir)
71
89
  File.write(File.join(dir, 'foo.rb'), '$loog.info("judge=" + $judge)')
72
90
  log = Loog::Buffer.new
73
- Judges::Pack.new(dir, nil, log).run(Factbase.new, {})
91
+ Judges::Pack.new(dir, nil, log).run(Factbase.new, {}, {}, {})
74
92
  assert(log.to_s.include?("judge=#{j}"))
75
93
  end
76
94
  end
@@ -85,7 +103,7 @@ class TestPack < Minitest::Test
85
103
  File.write(File.join(lib, 'y.rb'), '$foo = 42')
86
104
  pack = Judges::Pack.new(dir, lib, Loog::VERBOSE)
87
105
  fb = Factbase.new
88
- pack.run(fb, {})
106
+ pack.run(fb, {}, {}, {})
89
107
  assert_equal(42, fb.query('()').each.to_a.first.bar)
90
108
  end
91
109
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: judges
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.24
4
+ version: 0.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -107,6 +107,7 @@ files:
107
107
  - ".rultor.yml"
108
108
  - ".simplecov"
109
109
  - Gemfile
110
+ - Gemfile.lock
110
111
  - LICENSE.txt
111
112
  - README.md
112
113
  - Rakefile