judges 0.51.1 → 0.52.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: a0fd8b597a63a8c76873c87ae22e65aca5eb5d04c14b7420dbe0eb43401f59f1
4
- data.tar.gz: e55ff62e788bd8b7f9552b022be470ff43f9bbdf9ad0b78963e3a85da34e6a13
3
+ metadata.gz: 50ec9297bcf78cdacb7f57b46a8c7d8622f450c81816128a8dde263703563738
4
+ data.tar.gz: 9cb7c62c9d2eef9d682b12911b9b2f4ce08ba4f24aa6449c696304a0d671b6bf
5
5
  SHA512:
6
- metadata.gz: '015486b8adde507322fa3541e78ff86993f94e97033938e097b5d87d7fd2213d3999f73d0d58f44db5134114598202cd85ad0b1384c7298bc87f863380795066'
7
- data.tar.gz: 5f124df051302b4a022e2f7e42be78b75053ca23f0d21592201936a700f6fec342347de17d6745155e235892432c5f3c4a291ad41f16e804519234c050f835c2
6
+ metadata.gz: 405e06091477a5888985490ce86d69034c47c65011cbcc4ef2e72c08ab7163e7287a737bceb6fb3a9cea0a0c299347eb37c3f3bc4ecfe357fa9caaa34441f605
7
+ data.tar.gz: 61506eac6256b6b060108e8e98f8ccb530c2daca64fc2e165b488bd28e9fe1fba1e41a6a1bdc1f3cde1aadd5e03447fef83cc45f3b9616affe3c4e7855ef737e
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.0'
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
@@ -161,6 +168,7 @@ class Judges::Test
161
168
  def test_one(fb, opts, judge, tname, yaml, assert: true)
162
169
  options = Judges::Options.new(opts['option']) + Judges::Options.new(yaml['options'])
163
170
  runs = opts['runs'] || yaml['runs'] || 1
171
+ timeout = yaml['timeout']
164
172
  (1..runs).each do |r|
165
173
  fbx = fb
166
174
  if opts['log']
@@ -169,8 +177,16 @@ class Judges::Test
169
177
  end
170
178
  expected_failure = yaml['expected_failure']
171
179
  begin
172
- judge.run(fbx, {}, {}, options)
180
+ if timeout
181
+ Timeout.timeout(timeout) do
182
+ judge.run(fbx, {}, {}, options)
183
+ end
184
+ else
185
+ judge.run(fbx, {}, {}, options)
186
+ end
173
187
  raise 'Exception expected but not raised' if expected_failure
188
+ rescue Timeout::Error => e
189
+ raise "Test timed out after #{timeout} seconds"
174
190
  # rubocop:disable Lint/RescueException
175
191
  rescue Exception => e
176
192
  # 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.0' 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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko