judges 0.53.2 → 0.53.4
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.lock +2 -2
- data/features/update.feature +1 -2
- data/judges.gemspec +1 -1
- data/lib/judges/commands/update.rb +9 -3
- data/lib/judges/judge.rb +3 -3
- data/lib/judges.rb +1 -1
- data/test/commands/test_update.rb +36 -1
- data/test/test_judge.rb +0 -24
- 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: 8ee9872053ac43a975675a9eaed91b496bdb91ba0d3dc5595f956073c5ba2a13
|
4
|
+
data.tar.gz: 67e1409f8793c1fa9ad634d732f3596ef4ff08e9d587a14dc0a8b1ce3490622c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca7c356028c05c6bfdab1e6d7e826865dfe6f4e3ca5bec43718465a2ec03f39ba7823fb2fee05982e95c1ca0312003b3856f65a9e3e737d48ad3613c1afcb5b7
|
7
|
+
data.tar.gz: 692e4a5de4b92d85fcc15a22b7004dc72e5ebf83c339c34e5a8d4ac9bce08e62327f57ad1e96e50f3ddc4ce98fb149caadf567a9fe13943150fa1fda67ec667c
|
data/Gemfile.lock
CHANGED
@@ -177,7 +177,7 @@ GEM
|
|
177
177
|
tago (> 0)
|
178
178
|
regexp_parser (2.11.2)
|
179
179
|
retries (0.0.5)
|
180
|
-
rexml (3.4.
|
180
|
+
rexml (3.4.2)
|
181
181
|
rubocop (1.80.0)
|
182
182
|
json (~> 2.3)
|
183
183
|
language_server-protocol (~> 3.17.0.2)
|
@@ -208,7 +208,7 @@ GEM
|
|
208
208
|
docile (~> 1.1)
|
209
209
|
simplecov-html (~> 0.11)
|
210
210
|
simplecov_json_formatter (~> 0.1)
|
211
|
-
simplecov-cobertura (3.
|
211
|
+
simplecov-cobertura (3.1.0)
|
212
212
|
rexml
|
213
213
|
simplecov (~> 0.19)
|
214
214
|
simplecov-html (0.13.2)
|
data/features/update.feature
CHANGED
@@ -63,7 +63,7 @@ Feature: Update
|
|
63
63
|
n.type = 'second'
|
64
64
|
"""
|
65
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
|
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.
|
12
|
+
s.version = '0.53.4'
|
13
13
|
s.license = 'MIT'
|
14
14
|
s.summary = 'Command-Line Tool for a Factbase'
|
15
15
|
s.description =
|
@@ -69,8 +69,13 @@ class Judges::Update
|
|
69
69
|
start: @start, shuffle: opts['shuffle'], boost: opts['boost'],
|
70
70
|
demote: opts['demote']
|
71
71
|
)
|
72
|
-
|
73
|
-
|
72
|
+
begin
|
73
|
+
Timeout.timeout(opts['lifetime']) do
|
74
|
+
loop_them(impex, judges, fb, opts, options)
|
75
|
+
end
|
76
|
+
rescue Timeout::Error, Timeout::ExitException => e
|
77
|
+
raise e unless opts['quiet']
|
78
|
+
@loog.info("Had to stop due to the --lifetime=#{opts['lifetime']}")
|
74
79
|
end
|
75
80
|
end
|
76
81
|
|
@@ -215,6 +220,7 @@ class Judges::Update
|
|
215
220
|
def one_judge(opts, fb, judge, global, options, errors)
|
216
221
|
local = {}
|
217
222
|
start = Time.now
|
223
|
+
fb = Factbase::Tallied.new(fb)
|
218
224
|
begin
|
219
225
|
if opts['lifetime'] && Time.now - @start > opts['lifetime']
|
220
226
|
throw :"👎 The '#{judge.name}' judge skipped, no time left"
|
@@ -224,8 +230,8 @@ class Judges::Update
|
|
224
230
|
end
|
225
231
|
rescue Timeout::Error, Timeout::ExitException => e
|
226
232
|
errors << "Judge #{judge.name} stopped by timeout after #{start.ago}: #{e.message}"
|
227
|
-
throw :"👎 The '#{judge.name}' judge timed out after #{start.ago}: #{e.message}"
|
228
233
|
end
|
234
|
+
fb.churn
|
229
235
|
end
|
230
236
|
|
231
237
|
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 [
|
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 =
|
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
|
-
|
79
|
+
nil
|
80
80
|
# rubocop:disable Lint/RescueException
|
81
81
|
rescue Exception => e
|
82
82
|
# rubocop:enable Lint/RescueException
|
data/lib/judges.rb
CHANGED
@@ -39,6 +39,20 @@ class TestUpdate < Minitest::Test
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
def test_cancels_slow_execution
|
43
|
+
Dir.mktmpdir do |d|
|
44
|
+
10.times do |i|
|
45
|
+
save_it(File.join(d, "foo-#{i}/foo-#{i}.rb"), '$fb.insert.foo = 0.05; sleep 2;')
|
46
|
+
end
|
47
|
+
file = File.join(d, 'base.fb')
|
48
|
+
Judges::Update.new(Loog::NULL).run({ 'lifetime' => 0.12, 'timeout' => 0.1, 'quiet' => true }, [d, file])
|
49
|
+
fb = Factbase.new
|
50
|
+
fb.import(File.binread(file))
|
51
|
+
xml = Nokogiri::XML.parse(Factbase::ToXML.new(fb).xml)
|
52
|
+
refute_empty(xml.xpath('/fb/f[foo]'), xml)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
42
56
|
def test_cancels_slow_judge
|
43
57
|
Dir.mktmpdir do |d|
|
44
58
|
save_it(File.join(d, 'foo/foo.rb'), 'sleep 10; $fb.insert.foo = 1')
|
@@ -55,7 +69,28 @@ class TestUpdate < Minitest::Test
|
|
55
69
|
Dir.mktmpdir do |d|
|
56
70
|
save_it(File.join(d, 'foo/foo.rb'), '$fb.insert.foo = 1; sleep 10')
|
57
71
|
file = File.join(d, 'base.fb')
|
58
|
-
Judges::Update.new(Loog::NULL).run(
|
72
|
+
Judges::Update.new(Loog::NULL).run(
|
73
|
+
{ 'timeout' => 0.1, 'quiet' => true, 'fail-fast' => true },
|
74
|
+
[d, file]
|
75
|
+
)
|
76
|
+
fb = Factbase.new
|
77
|
+
fb.import(File.binread(file))
|
78
|
+
xml = Nokogiri::XML.parse(Factbase::ToXML.new(fb).xml)
|
79
|
+
refute_empty(xml.xpath('/fb/f[foo]'), xml)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_reports_changes_from_slow_judge
|
84
|
+
Dir.mktmpdir do |d|
|
85
|
+
save_it(File.join(d, 'foo/foo.rb'), '$fb.insert.foo = 1; sleep 10')
|
86
|
+
file = File.join(d, 'base.fb')
|
87
|
+
log = Loog::Buffer.new
|
88
|
+
Judges::Update.new(Loog::Tee.new(log, Loog::NULL)).run(
|
89
|
+
{ 'timeout' => 0.1, 'quiet' => true, 'fail-fast' => true },
|
90
|
+
[d, file]
|
91
|
+
)
|
92
|
+
assert_includes(log.to_s, 'did 1i/0d/1a')
|
93
|
+
assert_includes(log.to_s, 'Update completed in 1 cycle(s), did 1i/0d/1a')
|
59
94
|
fb = Factbase.new
|
60
95
|
fb.import(File.binread(file))
|
61
96
|
xml = Nokogiri::XML.parse(Factbase::ToXML.new(fb).xml)
|
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')
|