tryouts 2.4.0 → 2.4.1
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 +4 -4
- data/VERSION.yml +1 -1
- data/lib/tryouts/testbatch.rb +18 -15
- data/lib/tryouts/testcase.rb +2 -1
- data/lib/tryouts.rb +10 -0
- 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: 975acb3a790344e059de10c8eafae0a58de04e407f89a42af031d7a76c082ca2
|
4
|
+
data.tar.gz: a9d77fe3c5f15d2080999b93b7b42c3d16a465fbe31397338f806cd6d67bb253
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c70927fb871e78c28d44a1b996844e76b84eb944d57c9943f5603b5227f6f18d38bcdc836fa504b4e4b1220683c5d1b9c02a7af5636f884e393697927d8fc68
|
7
|
+
data.tar.gz: 7ccb05deaf71afdb6ff239e312c6bba8c7ef371a8fe746b15a47cf84cc81652502a62bff704ea8d33e345fa9350bcaec90d3055860c71973f9e2d8ffe618412d
|
data/VERSION.yml
CHANGED
data/lib/tryouts/testbatch.rb
CHANGED
@@ -9,50 +9,53 @@ class Tryouts
|
|
9
9
|
end
|
10
10
|
attr_reader :path, :failed, :lines
|
11
11
|
|
12
|
-
def initialize(
|
13
|
-
@path =
|
14
|
-
@lines =
|
12
|
+
def initialize(path, lines)
|
13
|
+
@path = path
|
14
|
+
@lines = lines
|
15
15
|
@container = Container.new.metaclass
|
16
16
|
@run = false
|
17
|
+
#super
|
17
18
|
end
|
18
19
|
|
19
20
|
def run(before_test, &after_test)
|
20
21
|
return if empty?
|
22
|
+
testcase_score = nil
|
21
23
|
|
22
24
|
setup
|
23
|
-
|
25
|
+
failed_tests = self.select do |tc|
|
24
26
|
before_test.call(tc) unless before_test.nil?
|
25
27
|
begin
|
26
|
-
|
28
|
+
testcase_score = tc.run # returns -1 for failed, 0 for skipped, 1 for passed
|
27
29
|
rescue StandardError => e
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
testcase_score = -1
|
31
|
+
warn Console.color(:red, "Error in test: #{tc.inspect}")
|
32
|
+
warn Console.color(:red, e.message)
|
33
|
+
warn e.backtrace.join($/), $/
|
32
34
|
end
|
33
35
|
after_test.call(tc) # runs the tallying code
|
34
|
-
|
36
|
+
testcase_score.negative? # select failed tests
|
35
37
|
end
|
36
38
|
|
37
|
-
|
39
|
+
warn Console.color(:red, "Failed tests: #{failed_tests.size}") if Tryouts.debug?
|
40
|
+
@failed = failed_tests.size
|
38
41
|
@run = true
|
39
42
|
clean
|
40
43
|
!failed?
|
41
44
|
|
42
45
|
rescue StandardError => e
|
43
|
-
@failed = 1
|
44
|
-
|
46
|
+
@failed = 1 # so that failed? returns true
|
47
|
+
warn e.message, e.backtrace.join($/), $/
|
45
48
|
end
|
46
49
|
|
47
50
|
def failed?
|
48
|
-
!@failed.nil? && @failed
|
51
|
+
!@failed.nil? && @failed.positive?
|
49
52
|
end
|
50
53
|
|
51
54
|
def setup
|
52
55
|
return if empty?
|
53
56
|
|
54
57
|
start = first.desc.nil? ? first.test.first : first.desc.first - 1
|
55
|
-
Tryouts.eval lines[0..start - 1].join, path, 0 if start
|
58
|
+
Tryouts.eval lines[0..start - 1].join, path, 0 if start.positive?
|
56
59
|
end
|
57
60
|
|
58
61
|
def clean
|
data/lib/tryouts/testcase.rb
CHANGED
@@ -59,13 +59,14 @@ class Tryouts
|
|
59
59
|
Tryouts.debug # extra newline
|
60
60
|
failed?
|
61
61
|
|
62
|
-
|
62
|
+
@test_result
|
63
63
|
rescue StandardError => e
|
64
64
|
Tryouts.debug "[testcaste.run] #{e.message}", e.backtrace.join($/), $/
|
65
65
|
# Continue raising the exception
|
66
66
|
raise e
|
67
67
|
ensure
|
68
68
|
$stdout = STDOUT # restore stdout
|
69
|
+
@test_result
|
69
70
|
end
|
70
71
|
|
71
72
|
def run?
|
data/lib/tryouts.rb
CHANGED
@@ -109,8 +109,14 @@ class Tryouts
|
|
109
109
|
# Reset the testcase IO buffer
|
110
110
|
testcase_io.truncate(0)
|
111
111
|
end
|
112
|
+
|
113
|
+
failed_tests += batch.failed
|
114
|
+
if Tryouts.debug?
|
115
|
+
msg "Batch failed_tests: #{batch.failed} (#{batch.failed?}) #{failed_tests}"
|
116
|
+
end
|
112
117
|
end
|
113
118
|
|
119
|
+
|
114
120
|
# Create a line of separation before the result summary
|
115
121
|
msg $INPUT_RECORD_SEPARATOR # newline
|
116
122
|
|
@@ -125,6 +131,9 @@ class Tryouts
|
|
125
131
|
success_count = tryouts_incr - failed_tests - skipped_tests
|
126
132
|
total_count = tryouts_incr - skipped_tests
|
127
133
|
msg cformat(success_count, total_count, suffix)
|
134
|
+
if Tryouts.debug?
|
135
|
+
msg "tryouts_incr: %d; failed: %d; skipped: %d" % [tryouts_incr, failed_tests, skipped_tests]
|
136
|
+
end
|
128
137
|
end
|
129
138
|
end
|
130
139
|
|
@@ -256,6 +265,7 @@ class Tryouts
|
|
256
265
|
|
257
266
|
def eval(str, path, line)
|
258
267
|
Kernel.eval str, @container.send(:binding), path, line
|
268
|
+
|
259
269
|
rescue SyntaxError, LoadError => e
|
260
270
|
Tryouts.err Console.color(:red, e.message),
|
261
271
|
Console.color(:red, e.backtrace.first)
|