judges 0.53.1 → 0.53.3

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: 60345e60cca92c8891851f29e255831796747e5451a14934538f52c764c3322e
4
- data.tar.gz: 27ecf7b216dc3a1f66267168b8bd77c76531067246716765ee3158f6cd1ae00e
3
+ metadata.gz: 30206b0fdcdc39f9e4fcbb9aa44cc6377aa63d707600c912813e39dbcc08649f
4
+ data.tar.gz: a90eb5d5bd333faf95484e7f6c114422831245c17175a05c0f82a2ed33caf896
5
5
  SHA512:
6
- metadata.gz: 87e466051c31be7106a95670c4508789fac2a790627135e26afeef970306c3e7f9762e20c13641277048929e0e8f430343427da49dac387d5a2f09e9f0cde625
7
- data.tar.gz: 9aa334a66a192dc65a1e6f7533d6a539c91c72dcbcb7506a0d85ccd01065d7446d58abdd0174dc15c428079078914bf67f08b5aa43a0222155653f82c643799f
6
+ metadata.gz: f52536f181c8172e6a869c8ce0dfb01b30f62fe31d64c9bfaf775d7bc47bd5e57b8efd7808afd8641e2f888b8447e3899181b5ca2c54aff4c9314345de31afb1
7
+ data.tar.gz: b51aa8226d7494c97521392fd6e1b2aac6bbb8b60a762af72f0b0ec93d09827e29a36a39ba8a166facba7a047704706576582a0b53fdcfe701671037491958a6
@@ -14,7 +14,7 @@ jobs:
14
14
  rake:
15
15
  strategy:
16
16
  matrix:
17
- os: [ubuntu-24.04, macos-15]
17
+ os: [ubuntu-24.04, macos-15, windows-2022]
18
18
  ruby: [3.3]
19
19
  runs-on: ${{ matrix.os }}
20
20
  steps:
@@ -16,4 +16,4 @@ jobs:
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
18
  - uses: actions/checkout@v5
19
- - uses: crate-ci/typos@v1.35.4
19
+ - uses: crate-ci/typos@v1.35.5
data/Gemfile CHANGED
@@ -12,7 +12,6 @@ gem 'diff-lcs', '1.6.2', require: false # GPL
12
12
  gem 'minitest', '~>5.25', require: false
13
13
  gem 'minitest-reporters', '~>1.7', require: false
14
14
  gem 'minitest-retry', '~>0.2', require: false
15
- gem 'net-ping', '~>2.0', require: false
16
15
  gem 'online', '~>0.0', require: false
17
16
  gem 'os', '~>1.1', require: false
18
17
  gem 'qbash', '~>0.4', require: false
data/Gemfile.lock CHANGED
@@ -46,7 +46,7 @@ GEM
46
46
  crack (1.0.0)
47
47
  bigdecimal
48
48
  rexml
49
- cucumber (10.0.0)
49
+ cucumber (10.1.0)
50
50
  base64 (~> 0.2)
51
51
  builder (~> 3.2)
52
52
  cucumber-ci-environment (> 9, < 11)
@@ -59,7 +59,7 @@ GEM
59
59
  multi_test (~> 1.1)
60
60
  sys-uname (~> 1.3)
61
61
  cucumber-ci-environment (10.0.1)
62
- cucumber-core (15.2.0)
62
+ cucumber-core (15.2.1)
63
63
  cucumber-gherkin (> 27, < 33)
64
64
  cucumber-messages (> 26, < 30)
65
65
  cucumber-tag-expressions (> 5, < 7)
@@ -78,18 +78,18 @@ GEM
78
78
  loog (~> 0.6)
79
79
  tago (~> 0.1)
80
80
  ellipsized (0.3.0)
81
- ethon (0.16.0)
81
+ ethon (0.17.0)
82
82
  ffi (>= 1.15.0)
83
- factbase (0.15.0)
83
+ factbase (0.15.6)
84
84
  backtrace (~> 0.4)
85
- decoor (~> 0.0)
85
+ decoor (~> 0.1)
86
86
  ellipsized (~> 0.3)
87
87
  json (~> 2.7)
88
88
  logger (~> 1.0)
89
89
  loog (~> 0.6)
90
90
  nokogiri (~> 1.10)
91
- others (~> 0.0)
92
- tago (~> 0.0)
91
+ others (~> 0.1)
92
+ tago (~> 0.1)
93
93
  yaml (~> 0.3)
94
94
  faraday (2.13.4)
95
95
  faraday-net_http (>= 2.0, < 3.5)
@@ -136,7 +136,6 @@ GEM
136
136
  multipart-post (2.4.1)
137
137
  net-http (0.6.0)
138
138
  uri
139
- net-ping (2.0.8)
140
139
  nokogiri (1.18.9-aarch64-linux-gnu)
141
140
  racc (~> 1.4)
142
141
  nokogiri (1.18.9-aarch64-linux-musl)
@@ -179,7 +178,7 @@ GEM
179
178
  regexp_parser (2.11.2)
180
179
  retries (0.0.5)
181
180
  rexml (3.4.1)
182
- rubocop (1.79.2)
181
+ rubocop (1.80.0)
183
182
  json (~> 2.3)
184
183
  language_server-protocol (~> 3.17.0.2)
185
184
  lint_roller (~> 1.1.0)
@@ -255,7 +254,6 @@ DEPENDENCIES
255
254
  minitest (~> 5.25)
256
255
  minitest-reporters (~> 1.7)
257
256
  minitest-retry (~> 0.2)
258
- net-ping (~> 2.0)
259
257
  online (~> 0.0)
260
258
  os (~> 1.1)
261
259
  qbash (~> 0.4)
@@ -16,9 +16,9 @@ Feature: Test
16
16
  And Exit code is zero
17
17
 
18
18
  Scenario: Factbase version can be set
19
- When I run bin/judges with "--factbase 0.15.0 --verbose test --judge guess ./fixtures"
19
+ When I run bin/judges with "--factbase 0.15.6 --verbose test --judge guess ./fixtures"
20
20
  Then Exit code is zero
21
- And Stdout contains "Factbase version to be used: '0.15.0'"
21
+ And Stdout contains "Factbase version to be used: '0.15.6'"
22
22
 
23
23
  Scenario: Simple test of no judges
24
24
  Given I run bin/judges with "test --judge absent_for_sure ./fixtures"
@@ -55,15 +55,15 @@ Feature: Update
55
55
  """
56
56
  n = $fb.insert
57
57
  n.type = 'first'
58
- sleep 0.9
58
+ sleep 1.9
59
59
  """
60
60
  Then I have a "second/second.rb" file with content:
61
61
  """
62
62
  n = $fb.insert
63
63
  n.type = 'second'
64
64
  """
65
- Then I run bin/judges with "--verbose update --lifetime 1 --max-cycles 5 . simple.fb"
66
- Then Stdout contains "Update completed in 1 cycle(s), did 2i/0d/2a"
65
+ Then I run bin/judges with "--verbose update --quiet --lifetime 2 --timeout 1 --max-cycles 5 . simple.fb"
66
+ Then Stdout contains "Update completed in 2 cycle(s), did 3i/0d/3a"
67
67
  And Exit code is zero
68
68
 
69
69
  Scenario: Use options from a file
@@ -93,7 +93,6 @@ Feature: Update
93
93
  """
94
94
  Then I run bin/judges with "--verbose update --timeout 1 --quiet . foo.fb"
95
95
  Then Stdout contains "execution expired"
96
- Then Stdout contains "judge timed out after"
97
96
  Then Stdout contains "1 judge(s) processed"
98
97
  Then Stdout contains "Update completed in 1 cycle(s), did 0i/0d/0a"
99
98
  And Exit code is zero
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.53.1'
12
+ s.version = '0.53.3'
13
13
  s.license = 'MIT'
14
14
  s.summary = 'Command-Line Tool for a Factbase'
15
15
  s.description =
@@ -45,7 +45,10 @@ class Judges::Update
45
45
  impex = Judges::Impex.new(@loog, args[1])
46
46
  fb = impex.import(strict: false)
47
47
  fb = Factbase::Logged.new(fb, @loog) if opts['log']
48
- options = Judges::Options.new(timeout: opts['timeout'], lifetime: opts['lifetime'])
48
+ options = Judges::Options.new(timeout: opts['timeout']&.to_i, lifetime: opts['lifetime']&.to_i)
49
+ if options.lifetime && options.timeout && options.lifetime < options.timeout * 1.1
50
+ raise "The --timeout=#{options.timeout} must be at least 10 percent smaller than --lifetime=#{options.lifetime}"
51
+ end
49
52
  options += Judges::Options.new(opts['option'])
50
53
  if opts['options-file']
51
54
  options += Judges::Options.new(
@@ -212,6 +215,7 @@ class Judges::Update
212
215
  def one_judge(opts, fb, judge, global, options, errors)
213
216
  local = {}
214
217
  start = Time.now
218
+ fb = Factbase::Tallied.new(fb)
215
219
  begin
216
220
  if opts['lifetime'] && Time.now - @start > opts['lifetime']
217
221
  throw :"👎 The '#{judge.name}' judge skipped, no time left"
@@ -221,8 +225,8 @@ class Judges::Update
221
225
  end
222
226
  rescue Timeout::Error, Timeout::ExitException => e
223
227
  errors << "Judge #{judge.name} stopped by timeout after #{start.ago}: #{e.message}"
224
- throw :"👎 The '#{judge.name}' judge timed out after #{start.ago}: #{e.message}"
225
228
  end
229
+ fb.churn
226
230
  end
227
231
 
228
232
  def include?(opts, name)
data/lib/judges/judge.rb CHANGED
@@ -53,10 +53,10 @@ class Judges::Judge
53
53
  # @param [Hash] global Global configuration options shared across all judges
54
54
  # @param [Hash] local Local configuration options specific to this judge
55
55
  # @param [Judges::Options] options Command-line options object
56
- # @return [Factbase::Churn] Object containing statistics about the changes made to the factbase
56
+ # @return [nil] Nothing
57
57
  # @raise [RuntimeError] If the lib directory doesn't exist, the script can't be loaded, or execution fails
58
58
  def run(fb, global, local, options)
59
- $fb = Factbase::Tallied.new(fb)
59
+ $fb = fb
60
60
  $judge = File.basename(@dir)
61
61
  $options = options
62
62
  $loog = @loog
@@ -76,7 +76,7 @@ class Judges::Judge
76
76
  raise "Can't load '#{s}'" unless File.exist?(s)
77
77
  elapsed(@loog, good: "#{$judge} completed", level: Logger::INFO) do
78
78
  load(s, true)
79
- $fb.churn
79
+ nil
80
80
  # rubocop:disable Lint/RescueException
81
81
  rescue Exception => e
82
82
  # rubocop:enable Lint/RescueException
@@ -127,6 +127,7 @@ class Judges::Options
127
127
  end
128
128
  pp
129
129
  .reject { |k, _| k.nil? }
130
+ .compact
130
131
  .reject { |k, _| k.is_a?(String) && k.empty? }
131
132
  .to_h
132
133
  .transform_values { |v| v.nil? ? 'true' : v }
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.53.1' unless const_defined?(:VERSION)
11
+ VERSION = '0.53.3' unless const_defined?(:VERSION)
12
12
  end
@@ -51,6 +51,39 @@ class TestUpdate < Minitest::Test
51
51
  end
52
52
  end
53
53
 
54
+ def test_accepts_changes_from_slow_judge
55
+ Dir.mktmpdir do |d|
56
+ save_it(File.join(d, 'foo/foo.rb'), '$fb.insert.foo = 1; sleep 10')
57
+ file = File.join(d, 'base.fb')
58
+ Judges::Update.new(Loog::NULL).run(
59
+ { 'timeout' => 0.1, 'quiet' => true, 'fail-fast' => true },
60
+ [d, file]
61
+ )
62
+ fb = Factbase.new
63
+ fb.import(File.binread(file))
64
+ xml = Nokogiri::XML.parse(Factbase::ToXML.new(fb).xml)
65
+ refute_empty(xml.xpath('/fb/f[foo]'), xml)
66
+ end
67
+ end
68
+
69
+ def test_reports_changes_from_slow_judge
70
+ Dir.mktmpdir do |d|
71
+ save_it(File.join(d, 'foo/foo.rb'), '$fb.insert.foo = 1; sleep 10')
72
+ file = File.join(d, 'base.fb')
73
+ log = Loog::Buffer.new
74
+ Judges::Update.new(Loog::Tee.new(log, Loog::NULL)).run(
75
+ { 'timeout' => 0.1, 'quiet' => true, 'fail-fast' => true },
76
+ [d, file]
77
+ )
78
+ assert_includes(log.to_s, 'did 1i/0d/1a')
79
+ assert_includes(log.to_s, 'Update completed in 1 cycle(s), did 1i/0d/1a')
80
+ fb = Factbase.new
81
+ fb.import(File.binread(file))
82
+ xml = Nokogiri::XML.parse(Factbase::ToXML.new(fb).xml)
83
+ refute_empty(xml.xpath('/fb/f[foo]'), xml)
84
+ end
85
+ end
86
+
54
87
  def test_extend_existing_factbase
55
88
  Dir.mktmpdir do |d|
56
89
  file = File.join(d, 'base.fb')
data/test/test_judge.rb CHANGED
@@ -25,30 +25,6 @@ class TestJudge < Minitest::Test
25
25
  end
26
26
  end
27
27
 
28
- def test_counts_churn
29
- Dir.mktmpdir do |d|
30
- save_it(File.join(d, "#{File.basename(d)}.rb"), '$fb.insert.foo = 42')
31
- judge = Judges::Judge.new(d, nil, Loog::NULL)
32
- fb = Factbase.new
33
- c = judge.run(fb, {}, {}, {})
34
- assert_equal(1, c.inserted)
35
- assert_equal(0, c.deleted)
36
- assert_equal(1, c.added)
37
- end
38
- end
39
-
40
- def test_counts_churn_after_txn
41
- Dir.mktmpdir do |d|
42
- save_it(File.join(d, "#{File.basename(d)}.rb"), '$fb.txn { |fbt| fbt.insert.foo = 42 }')
43
- judge = Judges::Judge.new(d, nil, Loog::NULL)
44
- fb = Factbase.new
45
- c = judge.run(fb, {}, {}, {})
46
- assert_equal(1, c.inserted)
47
- assert_equal(0, c.deleted)
48
- assert_equal(1, c.added)
49
- end
50
- end
51
-
52
28
  def test_run_isolated
53
29
  Dir.mktmpdir do |d|
54
30
  save_it(File.join(d, "#{File.basename(d)}.rb"), '$fb.insert')
data/test/test_options.rb CHANGED
@@ -60,6 +60,11 @@ class TestOptions < Minitest::Test
60
60
  assert_nil(opts.xxx)
61
61
  end
62
62
 
63
+ def test_with_nil_values
64
+ opts = Judges::Options.new('foo' => nil)
65
+ assert_nil(opts.foo)
66
+ end
67
+
63
68
  def test_converts_to_string
64
69
  opts = Judges::Options.new('foo' => 44, 'bar' => 'long-string-maybe-secret')
65
70
  s = opts.to_s
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.53.1
4
+ version: 0.53.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko