judges 0.51.1 → 0.52.1

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: a0fd8b597a63a8c76873c87ae22e65aca5eb5d04c14b7420dbe0eb43401f59f1
4
- data.tar.gz: e55ff62e788bd8b7f9552b022be470ff43f9bbdf9ad0b78963e3a85da34e6a13
3
+ metadata.gz: 9054ddb48e4cb0b6ad9ae6b5592822774e6b3de681ea134b6a9a1669bb124992
4
+ data.tar.gz: d17a57ad4bed5e96d2c250f0b2d123a1bbab0fd28fe8e750d8e36ec1ab0d0711
5
5
  SHA512:
6
- metadata.gz: '015486b8adde507322fa3541e78ff86993f94e97033938e097b5d87d7fd2213d3999f73d0d58f44db5134114598202cd85ad0b1384c7298bc87f863380795066'
7
- data.tar.gz: 5f124df051302b4a022e2f7e42be78b75053ca23f0d21592201936a700f6fec342347de17d6745155e235892432c5f3c4a291ad41f16e804519234c050f835c2
6
+ metadata.gz: e2454dafa1e471817f495d56f828c402bbefaaf31038880ffad6593b597afeaf6b73c63d142f5b6ada34139111561ccc70a4d6c190b4084a1c4f2fe329748776
7
+ data.tar.gz: 6461936993185848078937618c2d72b848651c82209db8dfbd5a4a6ec48532ffe762a3c811101531de421e2aaf5109d4cb6c4e9b1f5447bf80dfa49ade59abd9
data/Gemfile CHANGED
@@ -22,7 +22,7 @@ gem 'rubocop-minitest', '~>0.0', require: false
22
22
  gem 'rubocop-performance', '~>1.25', require: false
23
23
  gem 'rubocop-rake', '~>0.0', require: false
24
24
  gem 'simplecov', '~>0.22', require: false
25
- gem 'simplecov-cobertura', '~>2.1', require: false
25
+ gem 'simplecov-cobertura', '~>3.0', require: false
26
26
  gem 'w3c_validators', '~>1.3', require: false
27
27
  gem 'webmock', '~>3.25', require: false
28
28
  gem 'yard', '~>0.9', require: false
data/Gemfile.lock CHANGED
@@ -116,7 +116,7 @@ GEM
116
116
  ostruct
117
117
  hashdiff (1.2.0)
118
118
  iri (0.11.2)
119
- json (2.12.2)
119
+ json (2.13.0)
120
120
  language_server-protocol (3.17.0.5)
121
121
  lint_roller (1.1.0)
122
122
  logger (1.7.0)
@@ -179,7 +179,7 @@ GEM
179
179
  regexp_parser (2.10.0)
180
180
  retries (0.0.5)
181
181
  rexml (3.4.1)
182
- rubocop (1.78.0)
182
+ rubocop (1.79.0)
183
183
  json (~> 2.3)
184
184
  language_server-protocol (~> 3.17.0.2)
185
185
  lint_roller (~> 1.1.0)
@@ -187,10 +187,11 @@ GEM
187
187
  parser (>= 3.3.0.2)
188
188
  rainbow (>= 2.2.2, < 4.0)
189
189
  regexp_parser (>= 2.9.3, < 3.0)
190
- rubocop-ast (>= 1.45.1, < 2.0)
190
+ rubocop-ast (>= 1.46.0, < 2.0)
191
191
  ruby-progressbar (~> 1.7)
192
+ tsort (>= 0.2.0)
192
193
  unicode-display_width (>= 2.4.0, < 4.0)
193
- rubocop-ast (1.45.1)
194
+ rubocop-ast (1.46.0)
194
195
  parser (>= 3.3.7.2)
195
196
  prism (~> 1.4)
196
197
  rubocop-minitest (0.38.1)
@@ -209,7 +210,7 @@ GEM
209
210
  docile (~> 1.1)
210
211
  simplecov-html (~> 0.11)
211
212
  simplecov_json_formatter (~> 0.1)
212
- simplecov-cobertura (2.1.0)
213
+ simplecov-cobertura (3.0.0)
213
214
  rexml
214
215
  simplecov (~> 0.19)
215
216
  simplecov-html (0.13.1)
@@ -219,6 +220,7 @@ GEM
219
220
  tago (0.1.0)
220
221
  timeout (0.4.3)
221
222
  total (0.4.1)
223
+ tsort (0.2.0)
222
224
  typhoeus (1.4.1)
223
225
  ethon (>= 0.9.0)
224
226
  unicode-display_width (3.1.4)
@@ -265,7 +267,7 @@ DEPENDENCIES
265
267
  rubocop-performance (~> 1.25)
266
268
  rubocop-rake (~> 0.0)
267
269
  simplecov (~> 0.22)
268
- simplecov-cobertura (~> 2.1)
270
+ simplecov-cobertura (~> 3.0)
269
271
  w3c_validators (~> 1.3)
270
272
  webmock (~> 3.25)
271
273
  yard (~> 0.9)
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.51.1'
12
+ s.version = '0.52.1'
13
13
  s.license = 'MIT'
14
14
  s.summary = 'Command-Line Tool for a Factbase'
15
15
  s.description =
@@ -8,6 +8,7 @@ require 'factbase'
8
8
  require 'backtrace'
9
9
  require 'factbase/to_xml'
10
10
  require 'elapsed'
11
+ require 'timeout'
11
12
  require_relative '../../judges'
12
13
  require_relative '../../judges/to_rel'
13
14
  require_relative '../../judges/judges'
@@ -79,7 +80,13 @@ class Judges::Test
79
80
  buf.info("Running #{rb} assertion script...")
80
81
  $fb = fb
81
82
  $loog = buf
82
- load(File.join(judge.dir, rb), true)
83
+ if yaml['timeout']
84
+ Timeout.timeout(yaml['timeout']) do
85
+ load(File.join(judge.dir, rb), true)
86
+ end
87
+ else
88
+ load(File.join(judge.dir, rb), true)
89
+ end
83
90
  end
84
91
  tests += 1
85
92
  rescue StandardError => e
@@ -133,6 +140,7 @@ class Judges::Test
133
140
  end
134
141
 
135
142
  def prepare(fb, yaml)
143
+ id = 1
136
144
  inputs = yaml['input']
137
145
  (yaml['repeat']&.to_i || 1).times do
138
146
  inputs&.each do |i|
@@ -143,6 +151,10 @@ class Judges::Test
143
151
  f.send(:"#{k}=", v)
144
152
  end
145
153
  else
154
+ if k == '_id'
155
+ vv = id
156
+ id += 1
157
+ end
146
158
  f.send(:"#{k}=", vv)
147
159
  end
148
160
  end
@@ -161,6 +173,7 @@ class Judges::Test
161
173
  def test_one(fb, opts, judge, tname, yaml, assert: true)
162
174
  options = Judges::Options.new(opts['option']) + Judges::Options.new(yaml['options'])
163
175
  runs = opts['runs'] || yaml['runs'] || 1
176
+ timeout = yaml['timeout']
164
177
  (1..runs).each do |r|
165
178
  fbx = fb
166
179
  if opts['log']
@@ -169,8 +182,16 @@ class Judges::Test
169
182
  end
170
183
  expected_failure = yaml['expected_failure']
171
184
  begin
172
- judge.run(fbx, {}, {}, options)
185
+ if timeout
186
+ Timeout.timeout(timeout) do
187
+ judge.run(fbx, {}, {}, options)
188
+ end
189
+ else
190
+ judge.run(fbx, {}, {}, options)
191
+ end
173
192
  raise 'Exception expected but not raised' if expected_failure
193
+ rescue Timeout::Error => e
194
+ raise "Test timed out after #{timeout} seconds"
174
195
  # rubocop:disable Lint/RescueException
175
196
  rescue Exception => e
176
197
  # rubocop:enable Lint/RescueException
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.51.1' unless const_defined?(:VERSION)
11
+ VERSION = '0.52.1' unless const_defined?(:VERSION)
12
12
  end
@@ -161,4 +161,57 @@ class TestTest < Minitest::Test
161
161
  assert_path_exists(d)
162
162
  end
163
163
  end
164
+
165
+ def test_with_timeout_success
166
+ Dir.mktmpdir do |d|
167
+ save_it(File.join(d, 'foo/foo.rb'), '$fb.insert.foo = 42')
168
+ save_it(
169
+ File.join(d, 'foo/x.yml'),
170
+ <<-YAML
171
+ input: []
172
+ timeout: 5
173
+ expected:
174
+ - /fb[count(f)=1]
175
+ - /fb/f[foo='42']
176
+ YAML
177
+ )
178
+ Judges::Test.new(Loog::NULL).run({}, [d])
179
+ assert_path_exists(d)
180
+ end
181
+ end
182
+
183
+ def test_with_timeout_failure
184
+ Dir.mktmpdir do |d|
185
+ save_it(File.join(d, 'foo/foo.rb'), 'sleep(10)')
186
+ save_it(
187
+ File.join(d, 'foo/x.yml'),
188
+ <<-YAML
189
+ input: []
190
+ timeout: 1
191
+ YAML
192
+ )
193
+ assert_raises(StandardError) do
194
+ Judges::Test.new(Loog::NULL).run({}, [d])
195
+ end
196
+ end
197
+ end
198
+
199
+ def test_with_timeout_in_after_script
200
+ Dir.mktmpdir do |d|
201
+ save_it(File.join(d, 'foo/foo.rb'), '$fb.insert.foo = 42')
202
+ save_it(File.join(d, 'foo/assert.rb'), 'sleep(10)')
203
+ save_it(
204
+ File.join(d, 'foo/x.yml'),
205
+ <<-YAML
206
+ input: []
207
+ timeout: 1
208
+ after:
209
+ - assert.rb
210
+ YAML
211
+ )
212
+ assert_raises(StandardError) do
213
+ Judges::Test.new(Loog::NULL).run({}, [d])
214
+ end
215
+ end
216
+ end
164
217
  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.51.1
4
+ version: 0.52.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko