judges 0.33.0 ā†’ 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 988900140e36f573e7a9f04872cd372ec145a9bf77d567cde10ae307a51e0490
4
- data.tar.gz: 0c4abf1c34f895a214d3d9a8e9d7cf53be74887fb6842e37b545d32c332ce86c
3
+ metadata.gz: c6ea5b0cb2d8ad5e54b8fe3dc642b389b9fbca98f9f4d28924ecd8d4c8f85fb4
4
+ data.tar.gz: 35fba3154528724481be97f23bce59ff30761f100c6d056a6514a72c5f660b02
5
5
  SHA512:
6
- metadata.gz: 7adc13f872f4b1de6421f855df6fe65f5e74c8e45007fa25e63144f4aebe15adf1e0f56ec42a9645fa7c6247a6beb97fc89274bbdc0d235d8a0de87d05647aae
7
- data.tar.gz: bc06cfbcfa67a52e897b499d17c07bbd27139cfc768369dc5d6a6b58021dfd360304156520a0e4f81f76beaad62aa259f0675862b4d928fdadbe5ca0cc3ba125
6
+ metadata.gz: 402a83df023ef0428007ff704a910491c6ad382b1285bb376dc85cc127772be58cac9d60cb447a585556b5578cda3c9b36e15c09bb166063d24834be1e27ee8b
7
+ data.tar.gz: e88e01844ae33059d03b030c893d5d3f8dbb2ed9e654c8a78f87c3da9c21cbebde989cffb43bee8944e82f08d6774cab85d428da8c694aba49b28860bcd41249
data/.gitignore CHANGED
@@ -1,10 +1,11 @@
1
- coverage/
2
- .idea/
3
1
  *.gem
4
- .bundle/
5
2
  .DS_Store
6
- rdoc/
7
- doc/
3
+ .bundle/
4
+ .idea/
8
5
  .yardoc/
6
+ coverage/
7
+ doc/
8
+ node_modules/
9
+ rdoc/
9
10
  temp/
10
11
  vendor/
data/.rultor.yml CHANGED
@@ -3,7 +3,7 @@
3
3
  ---
4
4
  # yamllint disable rule:line-length
5
5
  docker:
6
- image: yegor256/rultor-ruby
6
+ image: yegor256/ruby
7
7
  assets:
8
8
  rubygems.yml: yegor256/home#assets/rubygems.yml
9
9
  install: |
data/Gemfile CHANGED
@@ -12,7 +12,7 @@ gem 'minitest-reporters', '1.7.1', require: false
12
12
  gem 'rake', '13.2.1', require: false
13
13
  gem 'random-port', '~>0.0', require: false
14
14
  gem 'rspec-rails', '7.1.1', require: false
15
- gem 'rubocop', '1.72.2', require: false
15
+ gem 'rubocop', '1.73.1', require: false
16
16
  gem 'rubocop-minitest', '>0', require: false
17
17
  gem 'rubocop-performance', '>0', require: false
18
18
  gem 'rubocop-rake', '>0', require: false
data/Gemfile.lock CHANGED
@@ -113,7 +113,7 @@ GEM
113
113
  erubi (1.13.1)
114
114
  ethon (0.16.0)
115
115
  ffi (>= 1.15.0)
116
- factbase (0.7.3)
116
+ factbase (0.7.4)
117
117
  backtrace (> 0)
118
118
  decoor (> 0)
119
119
  json (~> 2.7)
@@ -253,7 +253,7 @@ GEM
253
253
  rspec-mocks (~> 3.13)
254
254
  rspec-support (~> 3.13)
255
255
  rspec-support (3.13.2)
256
- rubocop (1.72.2)
256
+ rubocop (1.73.1)
257
257
  json (~> 2.3)
258
258
  language_server-protocol (~> 3.17.0.2)
259
259
  lint_roller (~> 1.1.0)
@@ -264,7 +264,7 @@ GEM
264
264
  rubocop-ast (>= 1.38.0, < 2.0)
265
265
  ruby-progressbar (~> 1.7)
266
266
  unicode-display_width (>= 2.4.0, < 4.0)
267
- rubocop-ast (1.38.0)
267
+ rubocop-ast (1.38.1)
268
268
  parser (>= 3.3.1.0)
269
269
  rubocop-minitest (0.37.1)
270
270
  lint_roller (~> 1.1)
@@ -304,7 +304,7 @@ GEM
304
304
  unicode-display_width (3.1.4)
305
305
  unicode-emoji (~> 4.0, >= 4.0.4)
306
306
  unicode-emoji (4.0.4)
307
- uri (1.0.2)
307
+ uri (1.0.3)
308
308
  useragent (0.16.11)
309
309
  w3c_validators (1.3.7)
310
310
  json (>= 1.8)
@@ -336,7 +336,7 @@ DEPENDENCIES
336
336
  rake (= 13.2.1)
337
337
  random-port (~> 0.0)
338
338
  rspec-rails (= 7.1.1)
339
- rubocop (= 1.72.2)
339
+ rubocop (= 1.73.1)
340
340
  rubocop-minitest (> 0)
341
341
  rubocop-performance (> 0)
342
342
  rubocop-rake (> 0)
data/README.md CHANGED
@@ -40,6 +40,7 @@ before:
40
40
  category: slow
41
41
  runs: 1
42
42
  skip: false
43
+ repeat: 20
43
44
  input:
44
45
  -
45
46
  foo: 42
@@ -65,6 +66,9 @@ when the test is finished.
65
66
  The `category` (default: `[]`) may have one or an array of categories,
66
67
  which then may be turned on via the `--category` command line flag.
67
68
 
69
+ The `repeat` (default: `1`) makes `input` to be repeated multiple times
70
+ (mostly useful for speed measuring on big data inputs).
71
+
68
72
  The `runs` (default: `1`) is the number of times the `.rb` script should
69
73
  be executed. After each execution, all expected XPath expressions are validated.
70
74
 
@@ -82,7 +86,7 @@ be present in the message of the exception being raised.
82
86
 
83
87
  Read
84
88
  [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
85
- Make sure you build is green before you contribute
89
+ Make sure your build is green before you contribute
86
90
  your pull request. You will need to have
87
91
  [Ruby](https://www.ruby-lang.org/en/) 3.0+ and
88
92
  [Bundler](https://bundler.io/) installed. Then:
data/bin/judges CHANGED
@@ -55,6 +55,8 @@ class JudgesGLI extend GLI::App
55
55
  c.flag([:o, :option], multiple: true, arg_name: '<key=value>')
56
56
  c.desc 'File with options, one k=v pair per line'
57
57
  c.flag([:'options-file'])
58
+ c.desc 'Name of the judge to run (directory name)'
59
+ c.flag([:judge], multiple: true)
58
60
  c.desc 'The location of a Ruby library (directory with .rb files to include)'
59
61
  c.flag([:lib])
60
62
  c.desc 'Maximum time in seconds to spend on every judge (forcefully terminate if over time)'
@@ -7,7 +7,7 @@ Feature: Test
7
7
  Scenario: Simple test of a few judges
8
8
  Given I run bin/judges with "test ./fixtures"
9
9
  Then Stdout contains "šŸ‘‰ Testing"
10
- Then Stdout contains "All 2 judge(s) and 2 tests passed"
10
+ Then Stdout contains "All 3 judge(s) and 3 tests passed"
11
11
  And Exit code is zero
12
12
 
13
13
  Scenario: Simple test of just one judge
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
5
+
6
+ # nothing to do here
@@ -0,0 +1,9 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ repeat: 10
5
+ input:
6
+ -
7
+ foo: 1
8
+ expected:
9
+ - /fb[count(f)=10]
data/judges.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
10
10
  s.required_ruby_version = '>=3.2'
11
11
  s.name = 'judges'
12
- s.version = '0.33.0'
12
+ s.version = '0.35.0'
13
13
  s.license = 'MIT'
14
14
  s.summary = 'Command-Line Tool for a Factbase'
15
15
  s.description =
@@ -92,7 +92,9 @@ class Judges::Test
92
92
  'Time summaries:',
93
93
  format(fmt, 'Script', 'Seconds'),
94
94
  format(fmt, '---', '---'),
95
- times.map { |script, sec| format(fmt, script, format('%.3f', sec)) }.join("\n ")
95
+ times.sort_by { |_, v| v }.reverse.map do |script, sec|
96
+ format(fmt, script, format('%.3f', sec))
97
+ end.join("\n ")
96
98
  ].join("\n ")
97
99
  )
98
100
  end
@@ -126,15 +128,17 @@ class Judges::Test
126
128
 
127
129
  def prepare(fb, yaml)
128
130
  inputs = yaml['input']
129
- inputs&.each do |i|
130
- f = fb.insert
131
- i.each do |k, vv|
132
- if vv.is_a?(Array)
133
- vv.each do |v|
134
- f.send(:"#{k}=", v)
131
+ (yaml['repeat']&.to_i || 1).times do
132
+ inputs&.each do |i|
133
+ f = fb.insert
134
+ i.each do |k, vv|
135
+ if vv.is_a?(Array)
136
+ vv.each do |v|
137
+ f.send(:"#{k}=", v)
138
+ end
139
+ else
140
+ f.send(:"#{k}=", vv)
135
141
  end
136
- else
137
- f.send(:"#{k}=", vv)
138
142
  end
139
143
  end
140
144
  end
@@ -111,12 +111,13 @@ class Judges::Update
111
111
  global = {}
112
112
  elapsed(@loog, level: Logger::INFO) do
113
113
  done =
114
- judges.each_with_index do |p, i|
115
- @loog.info("\nšŸ‘‰ Running #{p.name} (##{i}) at #{p.dir.to_rel} (#{start.ago} already)...")
114
+ judges.each_with_index do |judge, i|
115
+ next unless include?(opts, judge.name)
116
+ @loog.info("\nšŸ‘‰ Running #{judge.name} (##{i}) at #{judge.dir.to_rel} (#{start.ago} already)...")
116
117
  elapsed(@loog, level: Logger::INFO) do
117
- c = one_judge(opts, fb, p, global, options, errors)
118
+ c = one_judge(opts, fb, judge, global, options, errors)
118
119
  churn += c
119
- throw :"šŸ‘ The '#{p.name}' judge #{c} out of #{fb.size}"
120
+ throw :"šŸ‘ The '#{judge.name}' judge #{c} out of #{fb.size}"
120
121
  end
121
122
  rescue StandardError, SyntaxError => e
122
123
  @loog.warn(Backtrace.new(e))
@@ -152,4 +153,10 @@ class Judges::Update
152
153
  throw :"šŸ‘Ž The '#{judge.name}' judge timed out: #{e.message}"
153
154
  end
154
155
  end
156
+
157
+ def include?(opts, name)
158
+ judges = opts['judge'] || []
159
+ return true if judges.empty?
160
+ judges.any?(name)
161
+ end
155
162
  end
data/lib/judges.rb CHANGED
@@ -8,5 +8,5 @@
8
8
  # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
9
9
  # License:: MIT
10
10
  module Judges
11
- VERSION = '0.33.0'
11
+ VERSION = '0.35.0'
12
12
  end
@@ -28,6 +28,17 @@ class TestUpdate < Minitest::Test
28
28
  end
29
29
  end
30
30
 
31
+ def test_with_only_one_judge
32
+ Dir.mktmpdir do |d|
33
+ save_it(File.join(d, 'foo/foo.rb'), 'return if $fb.size > 2; $fb.insert')
34
+ save_it(File.join(d, 'bar/bar.rb'), '-&- bug here -&-')
35
+ file = File.join(d, 'base.fb')
36
+ Judges::Update.new(Loog::NULL).run({ 'judge' => ['foo'] }, [d, file])
37
+ assert_path_exists(file)
38
+ assert_raises(StandardError) { Judges::Update.new(Loog::NULL).run({}, [d, file]) }
39
+ end
40
+ end
41
+
31
42
  def test_cancels_slow_judge
32
43
  Dir.mktmpdir do |d|
33
44
  save_it(File.join(d, 'foo/foo.rb'), 'sleep 10; $fb.insert.foo = 1')
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: judges
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.33.0
4
+ version: 0.35.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-02-25 00:00:00.000000000 Z
10
+ date: 2025-03-03 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: backtrace
@@ -272,6 +271,8 @@ files:
272
271
  - fixtures/guess/guess.rb
273
272
  - fixtures/guess/guess_made.yml
274
273
  - fixtures/guess/skipped.yml
274
+ - fixtures/repeat/repeat.rb
275
+ - fixtures/repeat/repeated.yml
275
276
  - fixtures/try/tried.yml
276
277
  - fixtures/try/try.rb
277
278
  - judges.gemspec
@@ -316,7 +317,6 @@ licenses:
316
317
  - MIT
317
318
  metadata:
318
319
  rubygems_mfa_required: 'true'
319
- post_install_message:
320
320
  rdoc_options:
321
321
  - "--charset=UTF-8"
322
322
  require_paths:
@@ -332,8 +332,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
332
332
  - !ruby/object:Gem::Version
333
333
  version: '0'
334
334
  requirements: []
335
- rubygems_version: 3.4.10
336
- signing_key:
335
+ rubygems_version: 3.6.2
337
336
  specification_version: 4
338
337
  summary: Command-Line Tool for a Factbase
339
338
  test_files: []