judges 0.0.16 ā 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/judges +4 -2
- data/features/cli.feature +8 -3
- data/judges.gemspec +1 -1
- data/lib/judges/commands/test.rb +11 -2
- data/test/commands/test_test.rb +20 -3
- 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: 7312c2f398cbad4906226fbc64c489a95428281003dcab21988185b214bea734
|
4
|
+
data.tar.gz: 7ecf453fcef5028bb43219ddfde277bd1e0e3633059afa69bafe895c8b9fa52a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8000605816940bd197b284921b1a8218e51537c77f98fd7a932f5f47bac5c366dbe48fa3da0113dfa2db0c3760070d943a5d07a189f29ee87ddb3e0f6cedb18f
|
7
|
+
data.tar.gz: 9692dc49019dab0d0573cec9a95bbdd611328a7e2d95b3efc12ae5cc2e6a250d1ed2801d0c54b954872f53cf5d00139bf12c514612b8a86be72d18cf6dfd3d5e
|
data/bin/judges
CHANGED
@@ -29,7 +29,7 @@ require 'factbase'
|
|
29
29
|
Encoding.default_external = Encoding::UTF_8
|
30
30
|
Encoding.default_internal = Encoding::UTF_8
|
31
31
|
|
32
|
-
ver = '0.0.
|
32
|
+
ver = '0.0.17'
|
33
33
|
|
34
34
|
include GLI::App
|
35
35
|
|
@@ -96,7 +96,9 @@ end
|
|
96
96
|
desc 'Run automated tests for all judges'
|
97
97
|
command :test do |c|
|
98
98
|
c.desc 'Name of the test pack to run'
|
99
|
-
c.flag([:pack],
|
99
|
+
c.flag([:pack], multiple: true)
|
100
|
+
c.desc 'Fail if no judges tested?'
|
101
|
+
c.flag([:quiet], default_value: false)
|
100
102
|
c.action do |global, options, args|
|
101
103
|
require_relative '../lib/judges/commands/test'
|
102
104
|
Judges::Test.new(loog).run(options, args)
|
data/features/cli.feature
CHANGED
@@ -27,14 +27,19 @@ Feature: Simple Run
|
|
27
27
|
|
28
28
|
Scenario: Simple test of a few judges
|
29
29
|
Given I run bin/judges with "test ./fixtures"
|
30
|
-
Then Stdout contains "
|
30
|
+
Then Stdout contains "š Testing"
|
31
|
+
Then Stdout contains "judges tested successfully"
|
31
32
|
And Exit code is zero
|
32
33
|
|
33
34
|
Scenario: Simple test of just one pack
|
34
|
-
Given I run bin/judges with "test --pack
|
35
|
-
Then Stdout contains "judges tested"
|
35
|
+
Given I run bin/judges with "test --pack reward_for_good_bug ./fixtures"
|
36
|
+
Then Stdout contains "judges tested successfully"
|
36
37
|
And Exit code is zero
|
37
38
|
|
39
|
+
Scenario: Simple test of no packs
|
40
|
+
Given I run bin/judges with "test --pack absent_for_sure ./fixtures"
|
41
|
+
Then Exit code is not zero
|
42
|
+
|
38
43
|
Scenario: Simple trimming of a factbase
|
39
44
|
Given I make a temp directory
|
40
45
|
Then I have a "simple/simple_judge.rb" file with content:
|
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.
|
29
|
+
s.version = '0.0.17'
|
30
30
|
s.license = 'MIT'
|
31
31
|
s.summary = 'Command-Line Tool for a Factbase'
|
32
32
|
s.description = '
|
data/lib/judges/commands/test.rb
CHANGED
@@ -42,8 +42,9 @@ class Judges::Test
|
|
42
42
|
dir = args[0]
|
43
43
|
@loog.info("Testing judges in #{dir.to_rel}...")
|
44
44
|
errors = []
|
45
|
-
done =
|
46
|
-
|
45
|
+
done = 0
|
46
|
+
Judges::Packs.new(dir, @loog).each_with_index do |p, i|
|
47
|
+
next unless include?(opts, p.name)
|
47
48
|
@loog.info("\nš Testing #{p.script} (##{i}) in #{p.dir.to_rel}...")
|
48
49
|
p.tests.each do |f|
|
49
50
|
yaml = YAML.load_file(f, permitted_classes: [Time])
|
@@ -55,7 +56,9 @@ class Judges::Test
|
|
55
56
|
errors << f
|
56
57
|
end
|
57
58
|
end
|
59
|
+
done += 1
|
58
60
|
end
|
61
|
+
raise 'No judges tested :(' if done.zero? && !opts['quiet']
|
59
62
|
if errors.empty?
|
60
63
|
@loog.info("\nAll #{done} judges tested successfully")
|
61
64
|
else
|
@@ -66,6 +69,12 @@ class Judges::Test
|
|
66
69
|
|
67
70
|
private
|
68
71
|
|
72
|
+
def include?(opts, name)
|
73
|
+
packs = opts['pack'] || []
|
74
|
+
return true if packs.empty?
|
75
|
+
packs.include?(name)
|
76
|
+
end
|
77
|
+
|
69
78
|
def test_one(pack, yaml)
|
70
79
|
fb = Factbase.new
|
71
80
|
yaml['input'].each do |i|
|
data/test/commands/test_test.rb
CHANGED
@@ -45,7 +45,7 @@ class TestTest < Minitest::Test
|
|
45
45
|
- /fb/f[bar='4']
|
46
46
|
YAML
|
47
47
|
)
|
48
|
-
Judges::Test.new(Loog::
|
48
|
+
Judges::Test.new(Loog::NULL).run({}, [d])
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -65,7 +65,7 @@ class TestTest < Minitest::Test
|
|
65
65
|
YAML
|
66
66
|
)
|
67
67
|
assert_raises do
|
68
|
-
Judges::Test.new(Loog::
|
68
|
+
Judges::Test.new(Loog::NULL).run({}, [d])
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
@@ -84,7 +84,24 @@ class TestTest < Minitest::Test
|
|
84
84
|
- /fb/f[foo='42']
|
85
85
|
YAML
|
86
86
|
)
|
87
|
-
Judges::Test.new(Loog::
|
87
|
+
Judges::Test.new(Loog::NULL).run({}, [d])
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_one_pack_negative
|
92
|
+
Dir.mktmpdir do |d|
|
93
|
+
File.write(File.join(d, 'foo.rb'), '')
|
94
|
+
File.write(
|
95
|
+
File.join(d, 'x.yml'),
|
96
|
+
<<-YAML
|
97
|
+
input: []
|
98
|
+
expected:
|
99
|
+
- /fb[count(f)=1]
|
100
|
+
YAML
|
101
|
+
)
|
102
|
+
assert_raises do
|
103
|
+
Judges::Test.new(Loog::NULL).run({ 'pack' => [File.basename(dir)] }, [d])
|
104
|
+
end
|
88
105
|
end
|
89
106
|
end
|
90
107
|
end
|