judges 0.24.0 → 0.25.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: 74277f9de605e20cfe84fc6e5de877d8c5ac5724ec208a2c5c0dc35114dfa4df
4
- data.tar.gz: 310b9c2a0222e8df9bd9b9fee5fc762cf0236f3cf46e1d84f39e37b40d275aec
3
+ metadata.gz: 864078e89f5d4c966698d554864af0c76867423811bd8e8888c935873cf2040e
4
+ data.tar.gz: 28ba277b76e781eee992fd0eb49af944576329d9d761bc40a496e97dcbece222
5
5
  SHA512:
6
- metadata.gz: 33e90cba95d84e25b0755ef3724385226574f29117ebab2f815efd7fe1ecd697735c224832f753292387dc2b7c0ba62cd8fc84cc1bed488e4b527095175d97a0
7
- data.tar.gz: 53432cf8694784cb28ee374676398b3f7bc0a47b248cb9c02b25b50e735ffeaf18f240d4bab35be2b81bbdb0f0d75321a2d9c21411242967e631bf09bd9224ec
6
+ metadata.gz: abd995369192cce4656db009c16126908d3246387a405726027a47d2bab09f8e9f4edbb8f66f44c0593b9db8ad8b8da05b1e489fc8310785f7100932807a7949
7
+ data.tar.gz: 4156be82ef0bf1d1061efa41054f21dbab4c2114eeb356da6e0a54b530a9745a0246c942e0139e179485d442bdbbf544db150bc65c0d1ccda12ef8a60720680d
data/Gemfile.lock CHANGED
@@ -53,7 +53,7 @@ GEM
53
53
  ast (2.4.2)
54
54
  backtrace (0.4.0)
55
55
  base64 (0.2.0)
56
- baza.rb (0.0.3)
56
+ baza.rb (0.0.4)
57
57
  backtrace (> 0)
58
58
  faraday (> 0)
59
59
  faraday-http-cache (> 0)
@@ -175,7 +175,7 @@ GEM
175
175
  nokogiri (1.16.7-x86_64-linux)
176
176
  racc (~> 1.4)
177
177
  others (0.0.3)
178
- parallel (1.26.1)
178
+ parallel (1.26.2)
179
179
  parser (3.3.4.2)
180
180
  ast (~> 2.4.1)
181
181
  racc
@@ -215,7 +215,7 @@ GEM
215
215
  reline (0.5.9)
216
216
  io-console (~> 0.5)
217
217
  retries (0.0.5)
218
- rexml (3.3.4)
218
+ rexml (3.3.5)
219
219
  strscan
220
220
  rspec-core (3.13.0)
221
221
  rspec-support (~> 3.13.0)
data/README.md CHANGED
@@ -48,6 +48,8 @@ options:
48
48
  max: 100
49
49
  expected:
50
50
  - /fb[count(f)=1]
51
+ expected_failure:
52
+ - 'file not found'
51
53
  after:
52
54
  - first.rb
53
55
  - second.rb
@@ -72,6 +74,9 @@ The `after` (default: `[]`) is a list of relative file names
72
74
  of Ruby scripts that are executed after the judge
73
75
  (`$fb` and `$loog` are passed into them).
74
76
 
77
+ The `expected_failure (default: `[]`) is a list of strings that must
78
+ be present in the message of the exception being raised.
79
+
75
80
  ## How to contribute
76
81
 
77
82
  Read
data/assets/index.xsl CHANGED
@@ -162,13 +162,13 @@ SOFTWARE.
162
162
  <xsl:param name="cols"/>
163
163
  <xsl:choose>
164
164
  <xsl:when test="string-length($cols) &gt; 0">
165
- <col style="width: 10em;"/>
165
+ <col style=""/>
166
166
  <xsl:call-template name="col">
167
167
  <xsl:with-param name="cols" select="substring-after($cols, ',')"/>
168
168
  </xsl:call-template>
169
169
  </xsl:when>
170
170
  <xsl:otherwise>
171
- <col style=""/>
171
+ <col style="width: 50%;"/>
172
172
  </xsl:otherwise>
173
173
  </xsl:choose>
174
174
  </xsl:template>
data/bin/judges CHANGED
@@ -118,7 +118,7 @@ class JudgesGLI extend GLI::App
118
118
  c.desc 'Comma separated list of columns to show in HTML output (no spaces!)'
119
119
  c.flag([:columns], default_value: 'when,what')
120
120
  c.desc 'Comma separated list of hidden columns, not to be rendered (no spaces!)'
121
- c.flag([:hidden], default_value: '_id,_time,_version')
121
+ c.flag([:hidden], default_value: '_id,_time,_version,_job')
122
122
  c.desc 'Print even if target file already exists and is older than the factbase'
123
123
  c.switch([:force], default_value: false)
124
124
  run_it(c, 'print')
@@ -163,3 +163,18 @@ Feature: Test
163
163
  """
164
164
  Then I run bin/judges with "test mine"
165
165
  And Exit code is zero
166
+
167
+ Scenario: Test with exception
168
+ Given I make a temp directory
169
+ Then I have a "mine/foo/foo.rb" file with content:
170
+ """
171
+ raise 'this is a joke'
172
+ """
173
+ Then I have a "mine/foo/simple.yml" file with content:
174
+ """
175
+ ---
176
+ expected_failure:
177
+ - a joke
178
+ """
179
+ Then I run bin/judges with "test mine"
180
+ And Exit code is 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.24.0'
29
+ s.version = '0.25.0'
30
30
  s.license = 'MIT'
31
31
  s.summary = 'Command-Line Tool for a Factbase'
32
32
  s.description =
@@ -95,7 +95,7 @@ class Judges::Print
95
95
  'title' => opts['title'],
96
96
  'date' => Time.now.utc.iso8601,
97
97
  'columns' => opts['columns'] || 'when,what,who',
98
- 'hidden' => opts['hidden'] || '_id,_version,_time',
98
+ 'hidden' => opts['hidden'] || '_id,_version,_time,_job',
99
99
  'version' => Judges::VERSION
100
100
  )
101
101
  )
@@ -146,7 +146,18 @@ class Judges::Test
146
146
  (1..runs).each do |r|
147
147
  fbx = fb
148
148
  fbx = Factbase::Looged.new(fb, @loog) if opts['log']
149
- judge.run(fbx, {}, {}, options)
149
+ expected_failure = yaml['expected_failure']
150
+ begin
151
+ judge.run(fbx, {}, {}, options)
152
+ raise 'Exception expected but not raised' if expected_failure
153
+ # rubocop:disable Lint/RescueException
154
+ rescue Exception => e
155
+ # rubocop:enable Lint/RescueException
156
+ raise e unless expected_failure
157
+ if expected_failure.is_a?(Array) && expected_failure.none? { |s| e.message.include?(s) }
158
+ raise "Exception #{e.class} raised with #{e.message.inspect}, but this is not what was expected"
159
+ end
160
+ end
150
161
  next unless assert
151
162
  assert(judge, tname, fb, yaml) if r == runs || opts['assert_once'].is_a?(FalseClass)
152
163
  end
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.24.0'
28
+ VERSION = '0.25.0'
29
29
  end
@@ -24,6 +24,7 @@ require 'minitest/autorun'
24
24
  require 'loog'
25
25
  require 'nokogiri'
26
26
  require 'factbase/to_xml'
27
+ require_relative '../test__helper'
27
28
  require_relative '../../lib/judges'
28
29
  require_relative '../../lib/judges/commands/eval'
29
30
 
@@ -24,6 +24,7 @@ require 'minitest/autorun'
24
24
  require 'loog'
25
25
  require 'nokogiri'
26
26
  require 'factbase/to_xml'
27
+ require_relative '../test__helper'
27
28
  require_relative '../../lib/judges'
28
29
  require_relative '../../lib/judges/commands/import'
29
30
 
@@ -22,6 +22,7 @@
22
22
 
23
23
  require 'minitest/autorun'
24
24
  require 'loog'
25
+ require_relative '../test__helper'
25
26
  require_relative '../../lib/judges'
26
27
  require_relative '../../lib/judges/commands/test'
27
28
 
@@ -143,4 +144,33 @@ class TestTest < Minitest::Test
143
144
  Judges::Test.new(Loog::NULL).run({}, [d])
144
145
  end
145
146
  end
147
+
148
+ def test_with_expected_failure
149
+ Dir.mktmpdir do |d|
150
+ save_it(File.join(d, 'foo/foo.rb'), 'raise "this is intentional";')
151
+ save_it(
152
+ File.join(d, 'foo/x.yml'),
153
+ <<-YAML
154
+ input: []
155
+ expected_failure:
156
+ - intentional
157
+ YAML
158
+ )
159
+ Judges::Test.new(Loog::NULL).run({}, [d])
160
+ end
161
+ end
162
+
163
+ def test_with_expected_failure_no_string
164
+ Dir.mktmpdir do |d|
165
+ save_it(File.join(d, 'foo/foo.rb'), 'raise "this is intentional";')
166
+ save_it(
167
+ File.join(d, 'foo/x.yml'),
168
+ <<-YAML
169
+ input: []
170
+ expected_failure: true
171
+ YAML
172
+ )
173
+ Judges::Test.new(Loog::VERBOSE).run({}, [d])
174
+ end
175
+ end
146
176
  end
@@ -24,6 +24,7 @@ require 'minitest/autorun'
24
24
  require 'loog'
25
25
  require 'nokogiri'
26
26
  require 'factbase/to_xml'
27
+ require_relative '../test__helper'
27
28
  require_relative '../../lib/judges'
28
29
  require_relative '../../lib/judges/commands/update'
29
30
 
data/test/test_judge.rb CHANGED
@@ -24,6 +24,7 @@ require 'minitest/autorun'
24
24
  require 'tmpdir'
25
25
  require 'loog'
26
26
  require 'factbase'
27
+ require_relative 'test__helper'
27
28
  require_relative '../lib/judges'
28
29
  require_relative '../lib/judges/judge'
29
30
 
@@ -105,4 +106,15 @@ class TestJudge < Minitest::Test
105
106
  end
106
107
  end
107
108
  end
109
+
110
+ def test_with_standard_error
111
+ assert_raises do
112
+ Dir.mktmpdir do |d|
113
+ dir = File.join(d, 'judges')
114
+ save_it(File.join(dir, "#{File.basename(d)}.rb"), 'raise "intentional"')
115
+ judge = Judges::Judge.new(dir, lib, Loog::NULL)
116
+ judge.run(Factbase.new, {}, {}, {})
117
+ end
118
+ end
119
+ end
108
120
  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.24.0
4
+ version: 0.25.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-08-11 00:00:00.000000000 Z
11
+ date: 2024-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace