judges 0.0.37 → 0.1.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: 9e81cc6dc7d8235244b8b4ae58c481e023a7bca24b1867d534182eb271848d96
4
- data.tar.gz: b8c6db7f004f69f6a36a823c84847edc56cc3bbbac182509c313885d25682369
3
+ metadata.gz: 1710eb1662145157d37aafb92efec07fdf207e16bf173ba7844e34680b03708d
4
+ data.tar.gz: 10c1d1c04977466b6992cf250a26d237c07439c5814f9e27c183760a806a906f
5
5
  SHA512:
6
- metadata.gz: fb9ac6b946a3ebde4df93b170ebc47caccd0d903d38dd48d2825fc625c1d6577300ba3b2d6867485a871820f8e323e1014debe5dca447fe4a1a3a096d53020e4
7
- data.tar.gz: fd0614960a2ce36d0ea2ae84a3dd4c7053f11d06945f712c00400e182dfc322196609b0bd21cfa61eedab7908090686bc1f86ed1cb4aab6cfde6ed534a4cd117
6
+ metadata.gz: 4d49ad9a36777767322fd57797701fd2094bc5d6dad6f34be377ca6f588832f2ec2339bb8365c71022e6c246b77728df5fe45213c97282929a9cf41bc65ce628
7
+ data.tar.gz: 13660477add02b68ba5909c5df06e65827aca2a7261a69b801bef96fdc639ca8a7f88b67af16da969d1ba52cd328a9eb2db32e3ba7ce5d6c4fb1ca25004a58d6
data/Gemfile.lock CHANGED
@@ -84,13 +84,12 @@ GEM
84
84
  erubi (1.12.0)
85
85
  ethon (0.16.0)
86
86
  ffi (>= 1.15.0)
87
- factbase (0.0.38)
87
+ factbase (0.0.40)
88
88
  json (~> 2.7)
89
89
  loog (~> 0.2)
90
90
  nokogiri (~> 1.10)
91
91
  yaml (~> 0.3)
92
92
  ffi (1.16.3)
93
- ffi (1.16.3-x64-mingw-ucrt)
94
93
  gli (2.21.1)
95
94
  hashdiff (1.1.0)
96
95
  i18n (1.14.5)
@@ -111,16 +110,20 @@ GEM
111
110
  multi_test (1.1.0)
112
111
  mutex_m (0.2.0)
113
112
  net-ping (2.0.8)
113
+ nokogiri (1.16.5-aarch64-linux)
114
+ racc (~> 1.4)
115
+ nokogiri (1.16.5-arm-linux)
116
+ racc (~> 1.4)
114
117
  nokogiri (1.16.5-arm64-darwin)
115
118
  racc (~> 1.4)
116
- nokogiri (1.16.5-x64-mingw-ucrt)
119
+ nokogiri (1.16.5-x86-linux)
117
120
  racc (~> 1.4)
118
121
  nokogiri (1.16.5-x86_64-darwin)
119
122
  racc (~> 1.4)
120
123
  nokogiri (1.16.5-x86_64-linux)
121
124
  racc (~> 1.4)
122
125
  parallel (1.24.0)
123
- parser (3.3.1.0)
126
+ parser (3.3.2.0)
124
127
  ast (~> 2.4.1)
125
128
  racc
126
129
  psych (5.1.2)
@@ -233,9 +236,11 @@ GEM
233
236
  zeitwerk (2.6.15)
234
237
 
235
238
  PLATFORMS
236
- arm64-darwin-22
237
- x64-mingw-ucrt
238
- x86_64-darwin-20
239
+ aarch64-linux
240
+ arm-linux
241
+ arm64-darwin
242
+ x86-linux
243
+ x86_64-darwin
239
244
  x86_64-linux
240
245
 
241
246
  DEPENDENCIES
@@ -254,4 +259,4 @@ DEPENDENCIES
254
259
  yard (= 0.9.36)
255
260
 
256
261
  BUNDLED WITH
257
- 2.4.22
262
+ 2.5.6
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Judges
1
+ # Judges over a Factbase Executor
2
2
 
3
3
  [![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/judges)](http://www.rultor.com/p/yegor256/judges)
4
4
  [![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
@@ -11,7 +11,7 @@
11
11
  [![Hits-of-Code](https://hitsofcode.com/github/yegor256/judges)](https://hitsofcode.com/view/github/yegor256/judges)
12
12
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/judges/blob/master/LICENSE.txt)
13
13
 
14
- A command line tool and a Ruby gem for running judges agains a
14
+ A command line tool and a Ruby gem for running so called judges against a
15
15
  [factbase](https://github.com/yegor256/factbase).
16
16
 
17
17
  Every "judge" is a directory with a single `.rb` file and a number
@@ -24,19 +24,22 @@ global variables available to it:
24
24
  * `$loog` — an instance
25
25
  of [`Loog`](https://www.rubydoc.info/gems/loog/0.5.1/Loog),
26
26
  where `.info` and `.debug` logs are welcome;
27
- * `$options` — a holder of options coming from `.yml` files;
28
- * `$local` a hash map that is cleaned up when all tests
29
- in the pack are finished;
27
+ * `$options` — a holder of options coming from either the `--option` command
28
+ line flag or the `.yml` file during testing;
29
+ * `$local` — a hash map that is cleaned up when the execution of
30
+ a judge is finished;
30
31
  * `$global` — a hash map that is never cleaned up;
31
- * `$judge` — the name of the directory, where the `.rb` script is located.
32
+ * `$judge` — the basename of the directory, where the `.rb` script is located.
32
33
 
33
34
  Every `.yml` file must be formatted as such:
34
35
 
35
36
  ```yaml
37
+ skip: false
36
38
  input:
37
39
  -
38
40
  foo: 42
39
41
  bar: Hello, world!
42
+ many: [1, 2, -10]
40
43
  options:
41
44
  max: 100
42
45
  expected:
@@ -44,8 +47,8 @@ expected:
44
47
  ```
45
48
 
46
49
  Here, the `input` is an array of facts to be placed into the Factbase before
47
- the test starts; the `options` is a hash map of options to be passed
48
- via command line `--option` of the `update` command; and `expected` is
50
+ the test starts; the `options` is a hash map of options as if they are passed
51
+ via the command line `--option` flag of the `update` command; and `expected` is
49
52
  an array of XPath expressions that must be present in the XML of the Factbase
50
53
  when the test is finished.
51
54
 
@@ -55,7 +58,7 @@ Read
55
58
  [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
56
59
  Make sure you build is green before you contribute
57
60
  your pull request. You will need to have
58
- [Ruby](https://www.ruby-lang.org/en/) 2.3+ and
61
+ [Ruby](https://www.ruby-lang.org/en/) 3.0+ and
59
62
  [Bundler](https://bundler.io/) installed. Then:
60
63
 
61
64
  ```bash
data/bin/judges CHANGED
@@ -136,8 +136,8 @@ class App
136
136
  c.flag([:disable], multiple: true)
137
137
  c.desc 'Categories of tests to enable'
138
138
  c.flag([:enable], multiple: true)
139
- c.desc 'Name of the test pack to run'
140
- c.flag([:pack], multiple: true)
139
+ c.desc 'Name of the judge to run (directory name)'
140
+ c.flag([:judge], multiple: true)
141
141
  c.desc 'The location of a Ruby library (directory with .rb files to include)'
142
142
  c.flag([:lib])
143
143
  c.desc 'Stay quiet even if some tests fail or simply no tests executed?'
@@ -1,8 +1,8 @@
1
1
  Feature: Gem Package
2
2
  As a source code writer I want to be able to
3
- package the Gem into .gem file
3
+ judgeage the Gem into .gem file
4
4
 
5
- Scenario: Gem can be packaged
5
+ Scenario: Gem can be judgeaged
6
6
  Given I make a temp directory
7
7
  Then I have a "execs.rb" file with content:
8
8
  """
@@ -7,18 +7,18 @@ Feature: Test
7
7
  Then Stdout contains "All 2 judge(s) and 2 tests passed"
8
8
  And Exit code is zero
9
9
 
10
- Scenario: Simple test of just one pack
11
- Given I run bin/judges with "test --pack guess ./fixtures"
10
+ Scenario: Simple test of just one judge
11
+ Given I run bin/judges with "test --judge guess ./fixtures"
12
12
  Then Stdout contains "All 1 judge(s) and 1 tests passed"
13
13
  And Exit code is zero
14
14
 
15
- Scenario: Simple test of no packs
16
- Given I run bin/judges with "test --pack absent_for_sure ./fixtures"
15
+ Scenario: Simple test of no judges
16
+ Given I run bin/judges with "test --judge absent_for_sure ./fixtures"
17
17
  Then Exit code is not zero
18
18
 
19
19
  Scenario: Simple test of a few judges, with a lib
20
20
  Given I make a temp directory
21
- Then I have a "mypacks/mypack/simple_judge.rb" file with content:
21
+ Then I have a "myjudges/myjudge/simple_judge.rb" file with content:
22
22
  """
23
23
  n = $fb.insert
24
24
  n.foo = $foo
@@ -27,37 +27,37 @@ Feature: Test
27
27
  """
28
28
  $foo = 42
29
29
  """
30
- Then I run bin/judges with "test --lib mylib mypacks"
30
+ Then I run bin/judges with "test --lib mylib myjudges"
31
31
  Then Stdout contains "All 1 judge(s) but no tests passed"
32
32
  And Exit code is zero
33
33
 
34
34
  Scenario: Enable only one category
35
35
  Given I make a temp directory
36
- Then I have a "mypacks/good/good.rb" file with content:
36
+ Then I have a "mine/good/good.rb" file with content:
37
37
  """
38
38
  n = $fb.insert
39
39
  """
40
- Then I have a "mypacks/good/good.yml" file with content:
40
+ Then I have a "mine/good/good.yml" file with content:
41
41
  """
42
42
  ---
43
43
  category: good
44
44
  input: []
45
45
  """
46
- Then I have a "mypacks/bad/bad.rb" file with content:
46
+ Then I have a "mine/bad/bad.rb" file with content:
47
47
  """
48
48
  broken$ruby$syntax
49
49
  """
50
- Then I have a "mypacks/bad/bad.yml" file with content:
50
+ Then I have a "mine/bad/bad.yml" file with content:
51
51
  """
52
52
  ---
53
53
  category: bad
54
54
  """
55
- Then I run bin/judges with "test --enable good mypacks"
55
+ Then I run bin/judges with "test --enable good mine"
56
56
  Then Stdout contains "All 2 judge(s) and 1 tests passed"
57
57
  And Exit code is zero
58
- Then I run bin/judges with "test --disable bad mypacks"
58
+ Then I run bin/judges with "test --disable bad mine"
59
59
  Then Stdout contains "All 2 judge(s) and 1 tests passed"
60
60
  And Exit code is zero
61
- Then I run bin/judges with "test --enable bad mypacks"
62
- Then Stdout contains "Testing mypacks/bad/bad.yml"
61
+ Then I run bin/judges with "test --enable bad mine"
62
+ Then Stdout contains "Testing mine/bad/bad.yml"
63
63
  And Exit code is not zero
@@ -17,7 +17,7 @@ Feature: Update
17
17
 
18
18
  Scenario: Simple run of a few judges, with a lib
19
19
  Given I make a temp directory
20
- Then I have a "mypacks/mypack/simple_judge.rb" file with content:
20
+ Then I have a "mine/judge1/simple_judge.rb" file with content:
21
21
  """
22
22
  n = $fb.insert
23
23
  n.foo = $foo
@@ -26,27 +26,27 @@ Feature: Update
26
26
  """
27
27
  $foo = 42
28
28
  """
29
- Then I run bin/judges with "update --lib mylib --max-cycles 1 mypacks simple.fb"
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
31
  Then Stdout contains "Update finished: 1 cycles"
32
32
  And Exit code is zero
33
33
 
34
34
  Scenario: The update fails when a bug in a judge
35
35
  Given I make a temp directory
36
- Then I have a "mypacks/mypack/broken.rb" file with content:
36
+ Then I have a "mine/judge1/broken.rb" file with content:
37
37
  """
38
38
  a < 1
39
39
  """
40
- Then I run bin/judges with "update mypacks simple.fb"
40
+ Then I run bin/judges with "update mine simple.fb"
41
41
  Then Stdout contains "Failed to update correctly"
42
42
  And Exit code is not zero
43
43
 
44
44
  Scenario: The update fails when a broken Ruby syntax in a judge
45
45
  Given I make a temp directory
46
- Then I have a "mypacks/mypack/broken.rb" file with content:
46
+ Then I have a "mine/judge1/broken.rb" file with content:
47
47
  """
48
48
  invalid$ruby$syntax$here
49
49
  """
50
- Then I run bin/judges with "update mypacks simple.fb"
50
+ Then I run bin/judges with "update mine simple.fb"
51
51
  Then Stdout contains "Failed to update correctly"
52
52
  And Exit code is not zero
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.37'
29
+ s.version = '0.1.0'
30
30
  s.license = 'MIT'
31
31
  s.summary = 'Command-Line Tool for a Factbase'
32
32
  s.description =
@@ -27,7 +27,7 @@ require 'factbase/looged'
27
27
  require 'factbase/to_xml'
28
28
  require_relative '../../judges'
29
29
  require_relative '../../judges/to_rel'
30
- require_relative '../../judges/packs'
30
+ require_relative '../../judges/judges'
31
31
  require_relative '../../judges/options'
32
32
  require_relative '../../judges/categories'
33
33
  require_relative '../../judges/elapsed'
@@ -46,10 +46,10 @@ class Judges::Test
46
46
  dir = args[0]
47
47
  @loog.info("Testing judges in #{dir.to_rel}...")
48
48
  errors = []
49
- packs = 0
49
+ judges = 0
50
50
  tests = 0
51
51
  elapsed(@loog) do
52
- Judges::Packs.new(dir, opts['lib'], @loog).each_with_index do |p, i|
52
+ Judges::Judges.new(dir, opts['lib'], @loog).each_with_index do |p, i|
53
53
  next unless include?(opts, p.name)
54
54
  @loog.info("\n👉 Testing #{p.script} (##{i}) in #{p.dir.to_rel}...")
55
55
  p.tests.each do |f|
@@ -71,18 +71,18 @@ class Judges::Test
71
71
  errors << f
72
72
  end
73
73
  end
74
- packs += 1
74
+ judges += 1
75
75
  end
76
- throw :'👍 No judges tested' if packs.zero?
77
- throw :"👍 All #{packs} judge(s) but no tests passed" if tests.zero?
78
- throw :"👍 All #{packs} judge(s) and #{tests} tests passed" if errors.empty?
79
- throw :"❌ #{packs} judge(s) tested, #{errors.size} of them failed"
76
+ throw :'👍 No judges tested' if judges.zero?
77
+ throw :"👍 All #{judges} judge(s) but no tests passed" if tests.zero?
78
+ throw :"👍 All #{judges} judge(s) and #{tests} tests passed" if errors.empty?
79
+ throw :"❌ #{judges} judge(s) tested, #{errors.size} of them failed"
80
80
  end
81
81
  unless errors.empty?
82
82
  raise "#{errors.size} tests failed" unless opts['quiet']
83
83
  @loog.debug('Not failing the build with tests failures, due to the --quiet option')
84
84
  end
85
- return unless packs.zero?
85
+ return unless judges.zero?
86
86
  raise 'No judges tested :(' unless opts['quiet']
87
87
  @loog.debug('Not failing the build with no judges tested, due to the --quiet option')
88
88
  end
@@ -90,12 +90,12 @@ class Judges::Test
90
90
  private
91
91
 
92
92
  def include?(opts, name)
93
- packs = opts['pack'] || []
94
- return true if packs.empty?
95
- packs.include?(name)
93
+ judges = opts['judge'] || []
94
+ return true if judges.empty?
95
+ judges.include?(name)
96
96
  end
97
97
 
98
- def test_one(opts, pack, yaml)
98
+ def test_one(opts, judge, yaml)
99
99
  fb = Factbase.new
100
100
  inputs = yaml['input']
101
101
  inputs&.each do |i|
@@ -111,12 +111,12 @@ class Judges::Test
111
111
  end
112
112
  end
113
113
  options = Judges::Options.new(opts['option']) + Judges::Options.new(yaml['options'])
114
- pack.run(Factbase::Looged.new(fb, @loog), {}, {}, options)
114
+ judge.run(Factbase::Looged.new(fb, @loog), {}, {}, options)
115
115
  xpaths = yaml['expected']
116
116
  return if xpaths.nil?
117
117
  xml = Nokogiri::XML.parse(Factbase::ToXML.new(fb).xml)
118
118
  xpaths.each do |xp|
119
- raise "#{pack.script} doesn't match '#{xp}':\n#{xml}" if xml.xpath(xp).empty?
119
+ raise "#{judge.script} doesn't match '#{xp}':\n#{xml}" if xml.xpath(xp).empty?
120
120
  end
121
121
  end
122
122
  end
@@ -24,7 +24,7 @@ require 'backtrace'
24
24
  require 'factbase/looged'
25
25
  require_relative '../../judges'
26
26
  require_relative '../../judges/to_rel'
27
- require_relative '../../judges/packs'
27
+ require_relative '../../judges/judges'
28
28
  require_relative '../../judges/options'
29
29
  require_relative '../../judges/impex'
30
30
  require_relative '../../judges/elapsed'
@@ -47,7 +47,7 @@ class Judges::Update
47
47
  fb = Factbase::Looged.new(fb, @loog)
48
48
  options = Judges::Options.new(opts['option'])
49
49
  @loog.debug("The following options provided:\n\t#{options.to_s.gsub("\n", "\n\t")}")
50
- packs = Judges::Packs.new(dir, opts['lib'], @loog)
50
+ judges = Judges::Judges.new(dir, opts['lib'], @loog)
51
51
  c = 0
52
52
  elapsed(@loog) do
53
53
  loop do
@@ -55,7 +55,7 @@ class Judges::Update
55
55
  if c > 1
56
56
  @loog.info("\n\nStarting cycle ##{c}#{opts['max-cycles'] ? " (out of #{opts['max-cycles']})" : ''}...")
57
57
  end
58
- diff = cycle(opts, packs, fb, options)
58
+ diff = cycle(opts, judges, fb, options)
59
59
  impex.export(fb)
60
60
  if diff.zero?
61
61
  @loog.info("The update cycle ##{c} has made no changes to the factbase, let's stop")
@@ -77,12 +77,12 @@ class Judges::Update
77
77
 
78
78
  private
79
79
 
80
- def cycle(opts, packs, fb, options)
80
+ def cycle(opts, judges, fb, options)
81
81
  errors = []
82
82
  diff = 0
83
83
  global = {}
84
84
  elapsed(@loog) do
85
- done = packs.each_with_index do |p, i|
85
+ done = judges.each_with_index do |p, i|
86
86
  local = {}
87
87
  @loog.info("👉 Running #{p.name} (##{i}) at #{p.dir.to_rel}...")
88
88
  before = fb.size
@@ -26,11 +26,11 @@ require_relative '../judges/elapsed'
26
26
  require_relative '../judges/fb/once'
27
27
  require_relative '../judges/fb/if_absent'
28
28
 
29
- # A single pack.
29
+ # A single judge.
30
30
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
31
31
  # Copyright:: Copyright (c) 2024 Yegor Bugayenko
32
32
  # License:: MIT
33
- class Judges::Pack
33
+ class Judges::Judge
34
34
  attr_reader :dir
35
35
 
36
36
  def initialize(dir, lib, loog)
@@ -63,12 +63,12 @@ class Judges::Pack
63
63
  end
64
64
  end
65
65
 
66
- # Get the name of the pack.
66
+ # Get the name of the judge.
67
67
  def name
68
68
  File.basename(@dir)
69
69
  end
70
70
 
71
- # Get the name of the .rb script in the pack.
71
+ # Get the name of the .rb script in the judge.
72
72
  def script
73
73
  s = Dir.glob(File.join(@dir, '*.rb')).first
74
74
  raise "No *.rb scripts in #{@dir.to_rel}" if s.nil?
@@ -21,13 +21,13 @@
21
21
  # SOFTWARE.
22
22
 
23
23
  require_relative '../judges'
24
- require_relative 'pack'
24
+ require_relative 'judge'
25
25
 
26
- # Collection of all packs to run.
26
+ # Collection of all judges to run.
27
27
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
28
  # Copyright:: Copyright (c) 2024 Yegor Bugayenko
29
29
  # License:: MIT
30
- class Judges::Packs
30
+ class Judges::Judges
31
31
  def initialize(dir, lib, loog)
32
32
  @dir = dir
33
33
  @lib = lib
@@ -39,7 +39,7 @@ class Judges::Packs
39
39
  def each
40
40
  Dir.glob(File.join(@dir, '**/*.rb')).each do |f|
41
41
  d = File.dirname(File.absolute_path(f))
42
- yield Judges::Pack.new(d, @lib, @loog)
42
+ yield Judges::Judge.new(d, @lib, @loog)
43
43
  end
44
44
  end
45
45
 
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.0.37'
28
+ VERSION = '0.1.0'
29
29
  end
@@ -88,7 +88,7 @@ class TestTest < Minitest::Test
88
88
  end
89
89
  end
90
90
 
91
- def test_one_pack_negative
91
+ def test_one_judge_negative
92
92
  Dir.mktmpdir do |d|
93
93
  File.write(File.join(d, 'foo.rb'), '')
94
94
  File.write(
@@ -100,7 +100,7 @@ class TestTest < Minitest::Test
100
100
  YAML
101
101
  )
102
102
  assert_raises do
103
- Judges::Test.new(Loog::NULL).run({ 'pack' => [File.basename(dir)] }, [d])
103
+ Judges::Test.new(Loog::NULL).run({ 'judge' => [File.basename(dir)] }, [d])
104
104
  end
105
105
  end
106
106
  end
@@ -25,7 +25,7 @@ require 'tmpdir'
25
25
  require 'loog'
26
26
  require 'factbase'
27
27
  require_relative '../lib/judges'
28
- require_relative '../lib/judges/pack'
28
+ require_relative '../lib/judges/judge'
29
29
 
30
30
  # Test.
31
31
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -35,9 +35,9 @@ class TestPack < Minitest::Test
35
35
  def test_basic_run
36
36
  Dir.mktmpdir do |d|
37
37
  File.write(File.join(d, 'foo.rb'), '$fb.insert')
38
- pack = Judges::Pack.new(d, nil, Loog::NULL)
38
+ judge = Judges::Judge.new(d, nil, Loog::NULL)
39
39
  fb = Factbase.new
40
- pack.run(fb, {}, {}, {})
40
+ judge.run(fb, {}, {}, {})
41
41
  assert_equal(1, fb.size)
42
42
  end
43
43
  end
@@ -45,12 +45,12 @@ class TestPack < Minitest::Test
45
45
  def test_run_isolated
46
46
  Dir.mktmpdir do |d|
47
47
  File.write(File.join(d, 'bar.rb'), '$fb.insert')
48
- pack = Judges::Pack.new(d, nil, Loog::NULL)
48
+ judge = Judges::Judge.new(d, nil, Loog::NULL)
49
49
  fb1 = Factbase.new
50
- pack.run(fb1, {}, {}, {})
50
+ judge.run(fb1, {}, {}, {})
51
51
  assert_equal(1, fb1.size)
52
52
  fb2 = Factbase.new
53
- pack.run(fb2, {}, {}, {})
53
+ judge.run(fb2, {}, {}, {})
54
54
  assert_equal(1, fb2.size)
55
55
  end
56
56
  end
@@ -58,8 +58,8 @@ class TestPack < Minitest::Test
58
58
  def test_with_supplemenary_functions
59
59
  Dir.mktmpdir do |d|
60
60
  File.write(File.join(d, 'x.rb'), 'each_once($fb, "(always)").to_a')
61
- pack = Judges::Pack.new(d, nil, Loog::NULL)
62
- pack.run(Factbase.new, {}, {}, {})
61
+ judge = Judges::Judge.new(d, nil, Loog::NULL)
62
+ judge.run(Factbase.new, {}, {}, {})
63
63
  end
64
64
  end
65
65
 
@@ -72,11 +72,11 @@ class TestPack < Minitest::Test
72
72
  $local[:foo] = $local[:foo] + 1
73
73
  '
74
74
  )
75
- pack = Judges::Pack.new(d, nil, Loog::NULL)
75
+ judge = Judges::Judge.new(d, nil, Loog::NULL)
76
76
  local = {}
77
- pack.run(Factbase.new, {}, local, {})
78
- pack.run(Factbase.new, {}, local, {})
79
- pack.run(Factbase.new, {}, local, {})
77
+ judge.run(Factbase.new, {}, local, {})
78
+ judge.run(Factbase.new, {}, local, {})
79
+ judge.run(Factbase.new, {}, local, {})
80
80
  assert_equal(45, local[:foo])
81
81
  end
82
82
  end
@@ -88,22 +88,22 @@ class TestPack < Minitest::Test
88
88
  FileUtils.mkdir(dir)
89
89
  File.write(File.join(dir, 'foo.rb'), '$loog.info("judge=" + $judge)')
90
90
  log = Loog::Buffer.new
91
- Judges::Pack.new(dir, nil, log).run(Factbase.new, {}, {}, {})
91
+ Judges::Judge.new(dir, nil, log).run(Factbase.new, {}, {}, {})
92
92
  assert(log.to_s.include?("judge=#{j}"))
93
93
  end
94
94
  end
95
95
 
96
96
  def test_with_library
97
97
  Dir.mktmpdir do |d|
98
- dir = File.join(d, 'packs')
98
+ dir = File.join(d, 'judges')
99
99
  FileUtils.mkdir_p(dir)
100
100
  File.write(File.join(dir, 'x.rb'), '$fb.insert.bar = $foo; each_once($fb, "(always)").to_a')
101
101
  lib = File.join(d, 'lib')
102
102
  FileUtils.mkdir_p(lib)
103
103
  File.write(File.join(lib, 'y.rb'), '$foo = 42')
104
- pack = Judges::Pack.new(dir, lib, Loog::NULL)
104
+ judge = Judges::Judge.new(dir, lib, Loog::NULL)
105
105
  fb = Factbase.new
106
- pack.run(fb, {}, {}, {})
106
+ judge.run(fb, {}, {}, {})
107
107
  assert_equal(42, fb.query('(always)').each.to_a.first.bar)
108
108
  end
109
109
  end
@@ -111,11 +111,11 @@ class TestPack < Minitest::Test
111
111
  def test_with_broken_ruby_syntax
112
112
  assert_raises do
113
113
  Dir.mktmpdir do |d|
114
- dir = File.join(d, 'packs')
114
+ dir = File.join(d, 'judges')
115
115
  FileUtils.mkdir_p(dir)
116
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, {}, {}, {})
117
+ judge = Judges::Judge.new(dir, lib, Loog::NULL)
118
+ judge.run(Factbase.new, {}, {}, {})
119
119
  end
120
120
  end
121
121
  end
@@ -123,11 +123,11 @@ class TestPack < Minitest::Test
123
123
  def test_with_runtime_ruby_error
124
124
  assert_raises do
125
125
  Dir.mktmpdir do |d|
126
- dir = File.join(d, 'packs')
126
+ dir = File.join(d, 'judges')
127
127
  FileUtils.mkdir_p(dir)
128
128
  File.write(File.join(dir, 'x.rb'), 'a < 1')
129
- pack = Judges::Pack.new(dir, lib, Loog::NULL)
130
- pack.run(Factbase.new, {}, {}, {})
129
+ judge = Judges::Judge.new(dir, lib, Loog::NULL)
130
+ judge.run(Factbase.new, {}, {}, {})
131
131
  end
132
132
  end
133
133
  end
data/test/test_judges.rb CHANGED
@@ -21,13 +21,27 @@
21
21
  # SOFTWARE.
22
22
 
23
23
  require 'minitest/autorun'
24
+ require 'tmpdir'
25
+ require 'loog'
26
+ require_relative '../lib/judges'
27
+ require_relative '../lib/judges/judges'
24
28
 
25
29
  # Test.
26
30
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
27
31
  # Copyright:: Copyright (c) 2024 Yegor Bugayenko
28
32
  # License:: MIT
29
- class TestJudges < Minitest::Test
33
+ class TestPacks < Minitest::Test
30
34
  def test_basic
31
- # Nothing yet
35
+ Dir.mktmpdir do |d|
36
+ File.write(File.join(d, 'foo.rb'), 'hey')
37
+ File.write(File.join(d, 'something.yml'), "---\nfoo: 42")
38
+ found = 0
39
+ Judges::Judges.new(d, nil, Loog::NULL).each do |p|
40
+ assert_equal('foo.rb', p.script)
41
+ found += 1
42
+ assert_equal('something.yml', File.basename(p.tests.first))
43
+ end
44
+ assert_equal(1, found)
45
+ end
32
46
  end
33
47
  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.37
4
+ version: 0.1.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-30 00:00:00.000000000 Z
11
+ date: 2024-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace
@@ -190,9 +190,9 @@ files:
190
190
  - lib/judges/fb/if_absent.rb
191
191
  - lib/judges/fb/once.rb
192
192
  - lib/judges/impex.rb
193
+ - lib/judges/judge.rb
194
+ - lib/judges/judges.rb
193
195
  - lib/judges/options.rb
194
- - lib/judges/pack.rb
195
- - lib/judges/packs.rb
196
196
  - lib/judges/to_rel.rb
197
197
  - renovate.json
198
198
  - test/commands/test_eval.rb
@@ -211,10 +211,9 @@ files:
211
211
  - test/test_baza.rb
212
212
  - test/test_categories.rb
213
213
  - test/test_impex.rb
214
+ - test/test_judge.rb
214
215
  - test/test_judges.rb
215
216
  - test/test_options.rb
216
- - test/test_pack.rb
217
- - test/test_packs.rb
218
217
  - test/test_to_rel.rb
219
218
  homepage: http://github.com/yegor256/judges
220
219
  licenses:
data/test/test_packs.rb DELETED
@@ -1,47 +0,0 @@
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
- require 'minitest/autorun'
24
- require 'tmpdir'
25
- require 'loog'
26
- require_relative '../lib/judges'
27
- require_relative '../lib/judges/packs'
28
-
29
- # Test.
30
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
31
- # Copyright:: Copyright (c) 2024 Yegor Bugayenko
32
- # License:: MIT
33
- class TestPacks < Minitest::Test
34
- def test_basic
35
- Dir.mktmpdir do |d|
36
- File.write(File.join(d, 'foo.rb'), 'hey')
37
- File.write(File.join(d, 'something.yml'), "---\nfoo: 42")
38
- found = 0
39
- Judges::Packs.new(d, nil, Loog::NULL).each do |p|
40
- assert_equal('foo.rb', p.script)
41
- found += 1
42
- assert_equal('something.yml', File.basename(p.tests.first))
43
- end
44
- assert_equal(1, found)
45
- end
46
- end
47
- end