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 +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +8 -6
- data/judges.gemspec +1 -1
- data/lib/judges/commands/test.rb +23 -2
- data/lib/judges.rb +1 -1
- data/test/commands/test_test.rb +53 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9054ddb48e4cb0b6ad9ae6b5592822774e6b3de681ea134b6a9a1669bb124992
|
4
|
+
data.tar.gz: d17a57ad4bed5e96d2c250f0b2d123a1bbab0fd28fe8e750d8e36ec1ab0d0711
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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', '~>
|
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.
|
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.
|
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.
|
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.
|
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 (
|
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 (~>
|
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.
|
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 =
|
data/lib/judges/commands/test.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
data/test/commands/test_test.rb
CHANGED
@@ -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
|