judges 0.1.0 → 0.2.0

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: 1710eb1662145157d37aafb92efec07fdf207e16bf173ba7844e34680b03708d
4
- data.tar.gz: 10c1d1c04977466b6992cf250a26d237c07439c5814f9e27c183760a806a906f
3
+ metadata.gz: f36d80279b095db31b037136ab951bbc395bd5b5d74922149706ab8fe404381b
4
+ data.tar.gz: c0e1c403f0857e5c1764c8a0cf620761c36bf9e92dbcf9f4c4f2dbc420755651
5
5
  SHA512:
6
- metadata.gz: 4d49ad9a36777767322fd57797701fd2094bc5d6dad6f34be377ca6f588832f2ec2339bb8365c71022e6c246b77728df5fe45213c97282929a9cf41bc65ce628
7
- data.tar.gz: 13660477add02b68ba5909c5df06e65827aca2a7261a69b801bef96fdc639ca8a7f88b67af16da969d1ba52cd328a9eb2db32e3ba7ce5d6c4fb1ca25004a58d6
6
+ metadata.gz: d729a939b8a4b5894122d3e899487b8838dc92db04176f7ab3cb843d401b05edfd081744c5979c9169d98f78070ab0637f54b1f6d3623c60086e70b8666398f7
7
+ data.tar.gz: 15246686f5279034d4a57d0050931d93ebe6546c807e30e2d1bc0dd8611b7b8edfe6cd552272db3103f1001947078aa2b49b8a58935b1831fde503e509eef3ec
data/Gemfile CHANGED
@@ -28,9 +28,9 @@ gem 'minitest', '5.23.1', require: false
28
28
  gem 'net-ping', '2.0.8', require: false
29
29
  gem 'rake', '13.2.1', require: false
30
30
  gem 'rspec-rails', '6.1.2', require: false
31
- gem 'rubocop', '1.64.0', require: false
31
+ gem 'rubocop', '1.64.1', require: false
32
32
  gem 'rubocop-performance', '1.21.0', require: false
33
- gem 'rubocop-rspec', '2.29.2', require: false
33
+ gem 'rubocop-rspec', '2.30.0', require: false
34
34
  gem 'simplecov', '0.22.0', require: false
35
35
  gem 'simplecov-cobertura', '2.1.0', require: false
36
36
  gem 'webmock', '3.23.1', require: false
data/Gemfile.lock CHANGED
@@ -4,7 +4,7 @@ PATH
4
4
  judges (0.0.0)
5
5
  backtrace (~> 0.3)
6
6
  concurrent-ruby (= 1.2.3)
7
- factbase (~> 0.0.38)
7
+ factbase (~> 0.0)
8
8
  gli (~> 2.21)
9
9
  iri (~> 0.8)
10
10
  loog (~> 0.2)
@@ -84,12 +84,17 @@ GEM
84
84
  erubi (1.12.0)
85
85
  ethon (0.16.0)
86
86
  ffi (>= 1.15.0)
87
- factbase (0.0.40)
87
+ factbase (0.0.41)
88
88
  json (~> 2.7)
89
89
  loog (~> 0.2)
90
90
  nokogiri (~> 1.10)
91
91
  yaml (~> 0.3)
92
- ffi (1.16.3)
92
+ ffi (1.17.0-aarch64-linux-gnu)
93
+ ffi (1.17.0-arm-linux-gnu)
94
+ ffi (1.17.0-arm64-darwin)
95
+ ffi (1.17.0-x86-linux-gnu)
96
+ ffi (1.17.0-x86_64-darwin)
97
+ ffi (1.17.0-x86_64-linux-gnu)
93
98
  gli (2.21.1)
94
99
  hashdiff (1.1.0)
95
100
  i18n (1.14.5)
@@ -179,7 +184,7 @@ GEM
179
184
  rspec-mocks (~> 3.13)
180
185
  rspec-support (~> 3.13)
181
186
  rspec-support (3.13.1)
182
- rubocop (1.64.0)
187
+ rubocop (1.64.1)
183
188
  json (~> 2.3)
184
189
  language_server-protocol (>= 3.17.0)
185
190
  parallel (~> 1.10)
@@ -199,7 +204,7 @@ GEM
199
204
  rubocop-performance (1.21.0)
200
205
  rubocop (>= 1.48.1, < 2.0)
201
206
  rubocop-ast (>= 1.31.1, < 2.0)
202
- rubocop-rspec (2.29.2)
207
+ rubocop-rspec (2.30.0)
203
208
  rubocop (~> 1.40)
204
209
  rubocop-capybara (~> 2.17)
205
210
  rubocop-factory_bot (~> 2.22)
@@ -250,9 +255,9 @@ DEPENDENCIES
250
255
  net-ping (= 2.0.8)
251
256
  rake (= 13.2.1)
252
257
  rspec-rails (= 6.1.2)
253
- rubocop (= 1.64.0)
258
+ rubocop (= 1.64.1)
254
259
  rubocop-performance (= 1.21.0)
255
- rubocop-rspec (= 2.29.2)
260
+ rubocop-rspec (= 2.30.0)
256
261
  simplecov (= 0.22.0)
257
262
  simplecov-cobertura (= 2.1.0)
258
263
  webmock (= 3.23.1)
@@ -14,6 +14,16 @@ Feature: Test
14
14
 
15
15
  Scenario: Simple test of no judges
16
16
  Given I run bin/judges with "test --judge absent_for_sure ./fixtures"
17
+ Then Exit code is zero
18
+
19
+ Scenario: Simple test of no judges at all
20
+ Given I make a temp directory
21
+ Given I run bin/judges with "test ."
22
+ Then Exit code is not zero
23
+
24
+ Scenario: Simple test of no judges at all
25
+ Given I make a temp directory
26
+ Given I run bin/judges with "test --judge some ."
17
27
  Then Exit code is not zero
18
28
 
19
29
  Scenario: Simple test of a few judges, with a lib
@@ -23,12 +33,18 @@ Feature: Test
23
33
  n = $fb.insert
24
34
  n.foo = $foo
25
35
  """
36
+ Then I have a "myjudges/myjudge/good.yml" file with content:
37
+ """
38
+ ---
39
+ category: good
40
+ input: []
41
+ """
26
42
  Then I have a "mylib/foo.rb" file with content:
27
43
  """
28
44
  $foo = 42
29
45
  """
30
46
  Then I run bin/judges with "test --lib mylib myjudges"
31
- Then Stdout contains "All 1 judge(s) but no tests passed"
47
+ Then Stdout contains "All 1 judge(s) and 1 tests passed"
32
48
  And Exit code is zero
33
49
 
34
50
  Scenario: Enable only one category
@@ -12,7 +12,7 @@ Feature: Update
12
12
  Then Stdout contains "foo → "
13
13
  Then Stdout contains "bar → "
14
14
  Then Stdout contains "1 judge(s) processed"
15
- Then Stdout contains "Update finished: 3 cycles"
15
+ Then Stdout contains "Update finished in 3 cycle(s), +3 fact(s)"
16
16
  And Exit code is zero
17
17
 
18
18
  Scenario: Simple run of a few judges, with a lib
@@ -28,7 +28,7 @@ Feature: Update
28
28
  """
29
29
  Then I run bin/judges with "update --lib mylib --max-cycles 1 mine simple.fb"
30
30
  Then Stdout contains "1 judge(s) processed"
31
- Then Stdout contains "Update finished: 1 cycles"
31
+ Then Stdout contains "Update finished in 1 cycle(s)"
32
32
  And Exit code is zero
33
33
 
34
34
  Scenario: The update fails when a bug in a judge
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.1.0'
29
+ s.version = '0.2.0'
30
30
  s.license = 'MIT'
31
31
  s.summary = 'Command-Line Tool for a Factbase'
32
32
  s.description =
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
44
44
  s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
45
45
  s.add_runtime_dependency 'backtrace', '~> 0.3'
46
46
  s.add_runtime_dependency 'concurrent-ruby', '1.2.3'
47
- s.add_runtime_dependency 'factbase', '~>0.0.38'
47
+ s.add_runtime_dependency 'factbase', '~>0.0'
48
48
  s.add_runtime_dependency 'gli', '~>2.21'
49
49
  s.add_runtime_dependency 'iri', '~>0.8'
50
50
  s.add_runtime_dependency 'loog', '~>0.2'
@@ -48,11 +48,16 @@ class Judges::Test
48
48
  errors = []
49
49
  judges = 0
50
50
  tests = 0
51
+ visible = []
51
52
  elapsed(@loog) do
52
53
  Judges::Judges.new(dir, opts['lib'], @loog).each_with_index do |p, i|
54
+ visible << p.name
53
55
  next unless include?(opts, p.name)
54
56
  @loog.info("\n👉 Testing #{p.script} (##{i}) in #{p.dir.to_rel}...")
55
57
  p.tests.each do |f|
58
+ tname = File.basename(f).gsub(/\.yml$/, '')
59
+ visible << " #{p.name}/#{tname}"
60
+ next unless include?(opts, p.name, tname)
56
61
  yaml = YAML.load_file(f, permitted_classes: [Time])
57
62
  if yaml['skip']
58
63
  @loog.info("Skippped #{f.to_rel}")
@@ -82,17 +87,23 @@ class Judges::Test
82
87
  raise "#{errors.size} tests failed" unless opts['quiet']
83
88
  @loog.debug('Not failing the build with tests failures, due to the --quiet option')
84
89
  end
85
- return unless judges.zero?
86
- raise 'No judges tested :(' unless opts['quiet']
87
- @loog.debug('Not failing the build with no judges tested, due to the --quiet option')
90
+ return unless judges.zero? || tests.zero?
91
+ if opts['judge'].nil?
92
+ raise 'There are seems to be no judges' unless opts['quiet']
93
+ @loog.debug('Not failing the build with no judges tested, due to the --quiet option')
94
+ else
95
+ raise 'There are seems to be no judges' if visible.empty?
96
+ @loog.info("The following judges are available to use with the --judge option:\n #{visible.join("\n ")}")
97
+ end
88
98
  end
89
99
 
90
100
  private
91
101
 
92
- def include?(opts, name)
102
+ def include?(opts, name, tname = nil)
93
103
  judges = opts['judge'] || []
94
104
  return true if judges.empty?
95
- judges.include?(name)
105
+ tre = tname.nil? ? '.+' : tname
106
+ judges.any? { |n| n.match?(%r{^#{name}(/#{tre})?$}) }
96
107
  end
97
108
 
98
109
  def test_one(opts, judge, yaml)
@@ -45,6 +45,7 @@ class Judges::Update
45
45
  impex = Judges::Impex.new(@loog, args[1])
46
46
  fb = impex.import(strict: false)
47
47
  fb = Factbase::Looged.new(fb, @loog)
48
+ before = fb.size
48
49
  options = Judges::Options.new(opts['option'])
49
50
  @loog.debug("The following options provided:\n\t#{options.to_s.gsub("\n", "\n\t")}")
50
51
  judges = Judges::Judges.new(dir, opts['lib'], @loog)
@@ -66,12 +67,12 @@ class Judges::Update
66
67
  break
67
68
  end
68
69
  @loog.info(
69
- "By #{diff} facts the factbase " \
70
+ "By #{diff.abs} fact(s) the factbase " \
70
71
  "#{diff.positive? ? 'increased' : 'decreased'} " \
71
72
  "its size at the cycle ##{c}"
72
73
  )
73
74
  end
74
- throw :"Update finished: #{c} cycles"
75
+ throw :"Update finished in #{c} cycle(s), #{format('+%d', fb.size - before)} fact(s)"
75
76
  end
76
77
  end
77
78
 
data/lib/judges.rb CHANGED
@@ -25,5 +25,5 @@
25
25
  # Copyright:: Copyright (c) 2024 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Judges
28
- VERSION = '0.1.0'
28
+ VERSION = '0.2.0'
29
29
  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.1.0
4
+ version: 0.2.0
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-31 00:00:00.000000000 Z
11
+ date: 2024-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.0.38
47
+ version: '0.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.0.38
54
+ version: '0.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: gli
57
57
  requirement: !ruby/object:Gem::Requirement