tryouts 2.4.0 → 2.4.1

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: 17dda7b61be5923b407bd6e00c98c0ef3731897b3dd7afca88d00ed2bf240e5d
4
- data.tar.gz: 846fa9f79683f8ce9cd1e486653abfb6da44883e937fcd9edbeaece2c0ef0e4c
3
+ metadata.gz: 975acb3a790344e059de10c8eafae0a58de04e407f89a42af031d7a76c082ca2
4
+ data.tar.gz: a9d77fe3c5f15d2080999b93b7b42c3d16a465fbe31397338f806cd6d67bb253
5
5
  SHA512:
6
- metadata.gz: 9deedfac36285115ca643ddfa818ef5db33a1daf93906fadba8b49689390e0a020324f2fed638454ebee0b30e3600d48d2258b8213bc14cbcd25c0660d132a51
7
- data.tar.gz: 87d94a10b8500d2eb543f6c4c84be10f236a485bf4b94c79f12c8fc05ad6e2de6536087c43cd35ce5395ec8d38781006d67dafcd876c03d42cdca69f49cbf5d1
6
+ metadata.gz: 4c70927fb871e78c28d44a1b996844e76b84eb944d57c9943f5603b5227f6f18d38bcdc836fa504b4e4b1220683c5d1b9c02a7af5636f884e393697927d8fc68
7
+ data.tar.gz: 7ccb05deaf71afdb6ff239e312c6bba8c7ef371a8fe746b15a47cf84cc81652502a62bff704ea8d33e345fa9350bcaec90d3055860c71973f9e2d8ffe618412d
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :MAJOR: 2
3
3
  :MINOR: 4
4
- :PATCH: 0
4
+ :PATCH: 1
@@ -9,50 +9,53 @@ class Tryouts
9
9
  end
10
10
  attr_reader :path, :failed, :lines
11
11
 
12
- def initialize(p, l)
13
- @path = p
14
- @lines = l
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
- ret = self.select do |tc|
25
+ failed_tests = self.select do |tc|
24
26
  before_test.call(tc) unless before_test.nil?
25
27
  begin
26
- ret = !tc.run # returns true if test failed
28
+ testcase_score = tc.run # returns -1 for failed, 0 for skipped, 1 for passed
27
29
  rescue StandardError => e
28
- ret = true
29
- $stderr.puts Console.color(:red, "Error in test: #{tc.inspect}")
30
- $stderr.puts Console.color(:red, e.message)
31
- $stderr.puts e.backtrace.join($/), $/
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
- ret # select failed tests
36
+ testcase_score.negative? # select failed tests
35
37
  end
36
38
 
37
- @failed = ret.size
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
- $stderr.puts e.message, e.backtrace.join($/), $/
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 > 0
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 > 0
58
+ Tryouts.eval lines[0..start - 1].join, path, 0 if start.positive?
56
59
  end
57
60
 
58
61
  def clean
@@ -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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tryouts
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum