judges 0.0.31 → 0.0.32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c9e50999193ddf009d02379799add455856fae20b4f47e67a1760d56d7de3b0
4
- data.tar.gz: af70fa8273042c07df059589181795769518c94d54c4430cf9fe9d2999da799a
3
+ metadata.gz: cf26642d3989b5d0097e54b224bd8c8b431f5e488f04a6c6cc778f9a914e0ad6
4
+ data.tar.gz: 79974f0a047a19f499e8b9b69566ded6b9b78d3bf6f470bfc67e9aead9988dc9
5
5
  SHA512:
6
- metadata.gz: ce9ee17c4b5cf1aadc125678bde1e0a7b4bd07a6e1cb2e54696e5e478a68371f9e4c7a6c18f7961be77f056903a1e49eb943d4c9d949fedb96db71ed2f23350e
7
- data.tar.gz: fbadf8ca9127b21114b483b7a7f5e6b109d8c804f101a27fe6140c6a77e68a0f522bda5b32a366415b946d1c59c01130ab509a22e9f5c95037dbf605414d7667
6
+ metadata.gz: f7af589ce71752db5991f3838ea4e6b0e13969f3caab954f21d991d692d75b592c5f3bbe5d42e26cdc9a5d2c68a8ed3fcbe87401c34b1d6daa92c380f6fc7688
7
+ data.tar.gz: 25a4cc8aa470fb2f457c9f00b1581d5e4c05ab07d8580da124fd59d92c768796b4548948cb03abfc88256936b3ad8a2ae2fa4dd0edd66a7f1ae69a8530176fcf
@@ -0,0 +1,57 @@
1
+ # Copyright (c) 2024 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+ ---
21
+ name: license
22
+ 'on':
23
+ push:
24
+ branches:
25
+ - master
26
+ pull_request:
27
+ branches:
28
+ - master
29
+ jobs:
30
+ license:
31
+ runs-on: ubuntu-22.04
32
+ steps:
33
+ - uses: actions/checkout@v4
34
+ - shell: bash
35
+ run: |
36
+ header="Copyright (c) $(date +%Y) Yegor Bugayenko"
37
+ failed="false"
38
+ while IFS= read -r file; do
39
+ if ! grep -q "${header}" "${file}"; then
40
+ failed="true"
41
+ echo "⚠️ Copyright header is not found in: ${file}"
42
+ else
43
+ echo "File looks good: ${file}"
44
+ fi
45
+ done < <(find . -type f \( \
46
+ -name "Dockerfile" -o \
47
+ -name "LICENSE.txt" -o \
48
+ -name "Makefile" -o \
49
+ -name "Rakefile" -o \
50
+ -name "*.sh" -o \
51
+ -name "*.rb" -o \
52
+ -name "*.fe" -o \
53
+ -name "*.yml" \
54
+ \) -print)
55
+ if [ "${failed}" = "true" ]; then
56
+ exit 1
57
+ fi
data/Gemfile CHANGED
@@ -24,10 +24,10 @@ source 'https://rubygems.org'
24
24
  gemspec
25
25
 
26
26
  gem 'cucumber', '9.2.0', require: false
27
- gem 'minitest', '5.23.0', require: false
27
+ gem 'minitest', '5.23.1', require: false
28
28
  gem 'rake', '13.2.1', require: false
29
29
  gem 'rspec-rails', '6.1.2', require: false
30
- gem 'rubocop', '1.63.5', require: false
30
+ gem 'rubocop', '1.64.0', require: false
31
31
  gem 'rubocop-performance', '1.21.0', require: false
32
32
  gem 'rubocop-rspec', '2.29.2', require: false
33
33
  gem 'simplecov', '0.22.0', require: false
data/Gemfile.lock CHANGED
@@ -95,7 +95,7 @@ GEM
95
95
  nokogiri (>= 1.12.0)
96
96
  loog (0.5.1)
97
97
  mini_mime (1.1.5)
98
- minitest (5.23.0)
98
+ minitest (5.23.1)
99
99
  multi_test (1.1.0)
100
100
  mutex_m (0.2.0)
101
101
  nokogiri (1.16.5-arm64-darwin)
@@ -138,7 +138,7 @@ GEM
138
138
  zeitwerk (~> 2.6)
139
139
  rainbow (3.1.1)
140
140
  rake (13.2.1)
141
- rdoc (6.6.3.1)
141
+ rdoc (6.7.0)
142
142
  psych (>= 4.0.0)
143
143
  regexp_parser (2.9.2)
144
144
  reline (0.5.7)
@@ -162,7 +162,7 @@ GEM
162
162
  rspec-mocks (~> 3.13)
163
163
  rspec-support (~> 3.13)
164
164
  rspec-support (3.13.1)
165
- rubocop (1.63.5)
165
+ rubocop (1.64.0)
166
166
  json (~> 2.3)
167
167
  language_server-protocol (>= 3.17.0)
168
168
  parallel (~> 1.10)
@@ -221,10 +221,10 @@ PLATFORMS
221
221
  DEPENDENCIES
222
222
  cucumber (= 9.2.0)
223
223
  judges!
224
- minitest (= 5.23.0)
224
+ minitest (= 5.23.1)
225
225
  rake (= 13.2.1)
226
226
  rspec-rails (= 6.1.2)
227
- rubocop (= 1.63.5)
227
+ rubocop (= 1.64.0)
228
228
  rubocop-performance (= 1.21.0)
229
229
  rubocop-rspec (= 2.29.2)
230
230
  simplecov (= 0.22.0)
data/bin/judges CHANGED
@@ -32,7 +32,7 @@ Encoding.default_internal = Encoding::UTF_8
32
32
  class App
33
33
  extend GLI::App
34
34
 
35
- ver = '0.0.31'
35
+ ver = '0.0.32'
36
36
 
37
37
  loog = Loog::REGULAR
38
38
 
@@ -49,7 +49,7 @@ When(%r{^I run bin/judges with "([^"]*)"$}) do |arg|
49
49
  home = File.join(File.dirname(__FILE__), '../..')
50
50
  cmd = "ruby -I#{home}/lib #{home}/bin/judges #{arg}"
51
51
  cmd = "GLI_DEBUG=true #{cmd}" unless Gem.win_platform?
52
- @stdout = `#{cmd}`
52
+ @stdout = `#{cmd} 2>&1`
53
53
  @exitstatus = $CHILD_STATUS.exitstatus
54
54
  end
55
55
 
@@ -8,7 +8,7 @@ Feature: Test
8
8
  And Exit code is zero
9
9
 
10
10
  Scenario: Simple test of just one pack
11
- Given I run bin/judges with "test --pack reward_for_good_bug ./fixtures"
11
+ Given I run bin/judges with "test --pack guess ./fixtures"
12
12
  Then Stdout contains "judge(s) tested successfully"
13
13
  And Exit code is zero
14
14
 
@@ -30,3 +30,23 @@ Feature: Update
30
30
  Then Stdout contains "1 judge(s) processed"
31
31
  Then Stdout contains "Update finished: 1 cycles"
32
32
  And Exit code is zero
33
+
34
+ Scenario: The update fails when a bug in a judge
35
+ Given I make a temp directory
36
+ Then I have a "mypacks/mypack/broken.rb" file with content:
37
+ """
38
+ a < 1
39
+ """
40
+ Then I run bin/judges with "update mypacks simple.fb"
41
+ Then Stdout contains "Failed to update correctly"
42
+ And Exit code is not zero
43
+
44
+ Scenario: The update fails when a broken Ruby syntax in a judge
45
+ Given I make a temp directory
46
+ Then I have a "mypacks/mypack/broken.rb" file with content:
47
+ """
48
+ invalid$ruby$syntax$here
49
+ """
50
+ Then I run bin/judges with "update mypacks simple.fb"
51
+ Then Stdout contains "Failed to update correctly"
52
+ And Exit code is not zero
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2024 Yegor Bugayenko
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the 'Software'), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ $loog.info("Trying to guess a number (judge=#{$judge})...")
24
+ $fb.txn do |fbt|
25
+ n = fbt.insert
26
+ n.number = Random.rand(100)
27
+ n.time = Time.now
28
+ end
@@ -18,17 +18,8 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
19
  # SOFTWARE.
20
20
  ---
21
- input:
22
- -
23
- kind: bug was accepted
24
- reporter: yegor256
25
- time: 2024-01-01T03:15:45
26
- seen:
27
- - one
28
- - two
29
- - three
21
+ input: []
30
22
  expected:
31
- - /fb[count(f)=2]
32
- - /fb/f[kind='nominate for good bug']
33
- - /fb/f[payee='yegor256']
34
- - /fb/f[amount='15']
23
+ - /fb[count(f)=1]
24
+ - /fb/f/number
25
+ - /fb/f/time
@@ -0,0 +1,24 @@
1
+ # Copyright (c) 2024 Yegor Bugayenko
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the 'Software'), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+ ---
21
+ skip: true
22
+ input: []
23
+ expected:
24
+ - /should-never-reach-this-point
@@ -20,12 +20,8 @@
20
20
  ---
21
21
  input:
22
22
  -
23
- kind: bug was accepted
24
- reporter: yegor256
23
+ number: 42
25
24
  time: 2024-01-01T03:15:45
26
- seen:
27
- - one
28
- - reward_for_good_bug
29
- - two
30
25
  expected:
31
- - /fb[count(f)=1]
26
+ - /fb[count(f)=2]
27
+ - /fb/f/guess
@@ -20,13 +20,7 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  # SOFTWARE.
22
22
 
23
- $loog.info("Trying to reward a good reported bug (judge=#{$judge})...")
24
-
25
- once($fb).query("(eq kind 'bug was accepted')").each do |f|
26
- $loog.info('Good candidate found!')
23
+ once($fb).query("(and (exists number) (lt time #{Time.now.utc.iso8601}))").each do |f|
27
24
  n = $fb.insert
28
- n.kind = 'nominate for good bug'
29
- n.payee = f.reporter
30
- n.amount = 15
31
- n.message = 'thanks for reporting a bug; you get +15 points for this'
25
+ n.guess = f.number
32
26
  end
data/judges.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
27
27
  s.required_ruby_version = '>=3.2'
28
28
  s.name = 'judges'
29
- s.version = '0.0.31'
29
+ s.version = '0.0.32'
30
30
  s.license = 'MIT'
31
31
  s.summary = 'Command-Line Tool for a Factbase'
32
32
  s.description = '
@@ -46,17 +46,19 @@ class Judges::Test
46
46
  @loog.info("Testing judges in #{dir.to_rel}...")
47
47
  errors = []
48
48
  done = 0
49
- global = {}
50
49
  elapsed(@loog) do
51
50
  Judges::Packs.new(dir, opts['lib'], @loog).each_with_index do |p, i|
52
- local = {}
53
51
  next unless include?(opts, p.name)
54
52
  @loog.info("\n👉 Testing #{p.script} (##{i}) in #{p.dir.to_rel}...")
55
53
  p.tests.each do |f|
56
54
  yaml = YAML.load_file(f, permitted_classes: [Time])
55
+ if yaml['skip']
56
+ @loog.info("Skippped #{f.to_rel}")
57
+ next
58
+ end
57
59
  @loog.info("Testing #{f.to_rel}:")
58
60
  begin
59
- test_one(p, global, local, yaml)
61
+ test_one(p, yaml)
60
62
  rescue StandardError => e
61
63
  @loog.warn(Backtrace.new(e))
62
64
  errors << f
@@ -80,7 +82,7 @@ class Judges::Test
80
82
  packs.include?(name)
81
83
  end
82
84
 
83
- def test_one(pack, global, local, yaml)
85
+ def test_one(pack, yaml)
84
86
  fb = Factbase.new
85
87
  yaml['input'].each do |i|
86
88
  f = fb.insert
@@ -94,7 +96,7 @@ class Judges::Test
94
96
  end
95
97
  end
96
98
  end
97
- pack.run(Factbase::Looged.new(fb, @loog), global, local, Judges::Options.new(yaml['options']))
99
+ pack.run(Factbase::Looged.new(fb, @loog), {}, {}, Judges::Options.new(yaml['options']))
98
100
  xml = Nokogiri::XML.parse(Factbase::ToXML.new(fb).xml)
99
101
  yaml['expected'].each do |xp|
100
102
  raise "#{pack.script} doesn't match '#{xp}':\n#{xml}" if xml.xpath(xp).empty?
@@ -85,7 +85,7 @@ class Judges::Update
85
85
  before = fb.size
86
86
  begin
87
87
  p.run(fb, global, local, options)
88
- rescue StandardError => e
88
+ rescue StandardError, SyntaxError => e
89
89
  @loog.warn(Backtrace.new(e))
90
90
  errors << p.script
91
91
  end
@@ -96,7 +96,10 @@ class Judges::Update
96
96
  throw :"👍 #{done} judge(s) processed" if errors.empty?
97
97
  throw :"❌ #{done} judge(s) processed with #{errors.size} errors"
98
98
  end
99
- raise "Failed to update correctly (#{errors.size} errors)" unless errors.empty? || opts['quiet']
99
+ unless errors.empty?
100
+ raise "Failed to update correctly (#{errors.size} errors)" unless opts['quiet']
101
+ @loog.info('Not failing because of the --quiet flag provided')
102
+ end
100
103
  diff
101
104
  end
102
105
  end
@@ -62,9 +62,19 @@ class TestUpdate < Minitest::Test
62
62
 
63
63
  def test_update_with_error
64
64
  Dir.mktmpdir do |d|
65
- File.write(File.join(d, 'foo.rb'), 'this is a broken Ruby script')
65
+ File.write(File.join(d, 'foo.rb'), 'this$is$a$broken$Ruby$script')
66
66
  file = File.join(d, 'base.fb')
67
67
  Judges::Update.new(Loog::NULL).run({ 'quiet' => true }, [d, file])
68
68
  end
69
69
  end
70
+
71
+ def test_update_with_error_no_quiet
72
+ assert_raises do
73
+ Dir.mktmpdir do |d|
74
+ File.write(File.join(d, 'foo.rb'), 'a < 1')
75
+ file = File.join(d, 'base.fb')
76
+ Judges::Update.new(Loog::NULL).run({ 'quiet' => false }, [d, file])
77
+ end
78
+ end
79
+ end
70
80
  end
data/test/test_pack.rb CHANGED
@@ -107,4 +107,28 @@ class TestPack < Minitest::Test
107
107
  assert_equal(42, fb.query('()').each.to_a.first.bar)
108
108
  end
109
109
  end
110
+
111
+ def test_with_broken_ruby_syntax
112
+ assert_raises do
113
+ Dir.mktmpdir do |d|
114
+ dir = File.join(d, 'packs')
115
+ FileUtils.mkdir_p(dir)
116
+ File.write(File.join(dir, 'x.rb'), 'this$is$broken$syntax')
117
+ pack = Judges::Pack.new(dir, lib, Loog::NULL)
118
+ pack.run(Factbase.new, {}, {}, {})
119
+ end
120
+ end
121
+ end
122
+
123
+ def test_with_runtime_ruby_error
124
+ assert_raises do
125
+ Dir.mktmpdir do |d|
126
+ dir = File.join(d, 'packs')
127
+ FileUtils.mkdir_p(dir)
128
+ File.write(File.join(dir, 'x.rb'), 'a < 1')
129
+ pack = Judges::Pack.new(dir, lib, Loog::NULL)
130
+ pack.run(Factbase.new, {}, {}, {})
131
+ end
132
+ end
133
+ end
110
134
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: judges
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.31
4
+ version: 0.0.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-21 00:00:00.000000000 Z
11
+ date: 2024-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -96,6 +96,7 @@ files:
96
96
  - ".gitattributes"
97
97
  - ".github/workflows/actionlint.yml"
98
98
  - ".github/workflows/codecov.yml"
99
+ - ".github/workflows/license.yml"
99
100
  - ".github/workflows/markdown-lint.yml"
100
101
  - ".github/workflows/pdd.yml"
101
102
  - ".github/workflows/rake.yml"
@@ -123,10 +124,11 @@ files:
123
124
  - features/test.feature
124
125
  - features/trim.feature
125
126
  - features/update.feature
126
- - fixtures/reward_for_good_bug/README.md
127
- - fixtures/reward_for_good_bug/no-reward.yml
128
- - fixtures/reward_for_good_bug/reward_it.rb
129
- - fixtures/reward_for_good_bug/simple-reward.yml
127
+ - fixtures/guess/guess.rb
128
+ - fixtures/guess/guess_made.yml
129
+ - fixtures/guess/skipped.yml
130
+ - fixtures/try/tried.yml
131
+ - fixtures/try/try.rb
130
132
  - judges.gemspec
131
133
  - lib/judges.rb
132
134
  - lib/judges/commands/eval.rb
@@ -1,8 +0,0 @@
1
- # Why bugs reports are rewarded?
2
-
3
- Every bug reported and accepted deserves a reward, which
4
- are given to the reporter of the bug. A bug is considered as
5
- "accepted" only if it has the `bug`, `enhancement`, or `question` label
6
- attached to it. Such a reward encourages programmers to report
7
- more bugs, thus revealing problems that will be fixed before they
8
- are shipped to a customer.