dohtest 0.1.21 → 0.1.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dohtest/stream_output.rb +23 -22
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e47f88244a0039b34c8ea5904841c5d2e238b4e6
4
- data.tar.gz: 8f48928e629f204d697f23a8f90b0dba60b9e6d2
3
+ metadata.gz: 0a8810bc10cada22cebe376aec68b3a9fa3978c4
4
+ data.tar.gz: 78a667851be530ea26572040613b03aa3588936e
5
5
  SHA512:
6
- metadata.gz: 441f22bc4860b091ddd9ffeab3bd7b7503930cdaf95ddf6c56745b05b445a2e6860e6e44a8bb8a3a5270e6fc9ded344dc53291c0da202e1fd200c5b8b5fdd1e7
7
- data.tar.gz: 2f8744d2a17f0d4fa573116fc9dd2d362f6b63922aa31972632e2623f97c6120a6449a2aef94d2a015d9ad4ca0a929089a03ecb6e4f84066507d54afb937cb38
6
+ metadata.gz: 4313b4256be9e2aef4a349535d9b9f701b2e1d3bcf764aa2ca4ec0c573e9f1d421cc0d2799a9ee99959befe52518b1bd91f7d5c8b6df53c1bae56bacfd54c049
7
+ data.tar.gz: f399a567a5a2c7e2566e45104c53a3d4ad0c9a15c566c3467d872c9fa6f389b11f40fb12534572968570cc1b1abd2aca0ae8f2d77b56153a3894ecf9f56cb530
@@ -7,18 +7,19 @@ module DohTest
7
7
  class StreamOutput
8
8
  DEFAULT_COLORS = {:failure => :red, :error => :magenta, :info => :blue, :success => :green}.freeze
9
9
 
10
- def initialize(ios = nil)
10
+ def initialize(std_ios = nil, err_ios = nil)
11
11
  @error_count = @groups_ran = @groups_skipped = @tests_ran = @tests_skipped = @assertions_failed = @assertions_passed = 0
12
12
  @callback_succeeded = true
13
13
  @badness = Set.new
14
- @ios = ios || $stdout
14
+ @std_ios = ios || $stdout
15
+ @err_ios = ios || $stderr
15
16
  end
16
17
 
17
18
  def run_begin(config)
18
19
  @config = config
19
- @ios.puts "running tests with config: #{config}"
20
+ @std_ios.puts "running tests with config: #{config}"
20
21
 
21
- has_terminal = @ios.tty?
22
+ has_terminal = @std_ios.tty?
22
23
  @no_color = !has_terminal || @config[:no_color]
23
24
  @verbose = (has_terminal && !@config[:quiet]) || @config[:verbose]
24
25
  end
@@ -29,9 +30,9 @@ class StreamOutput
29
30
  if duration >= 1
30
31
  tests_per_second = (@tests_ran / duration).round(2)
31
32
  assertions_per_second = (total_assertions / duration).round(2)
32
- @ios.puts "\n\ncompleted in #{duration.round(2)}s, #{tests_per_second} tests/s, #{assertions_per_second} assertions/s"
33
+ @std_ios.puts "\n\ncompleted in #{duration.round(2)}s, #{tests_per_second} tests/s, #{assertions_per_second} assertions/s"
33
34
  else
34
- @ios.puts "\n\ncompleted in #{duration.round(2)}s"
35
+ @std_ios.puts "\n\ncompleted in #{duration.round(2)}s"
35
36
  end
36
37
 
37
38
  if @error_count == 0
@@ -67,7 +68,7 @@ class StreamOutput
67
68
 
68
69
  msg = "#{error_str}; #{group_str}; #{test_str}; #{assertion_str}"
69
70
  msg = colorize(:success, msg) if success
70
- @ios.puts msg
71
+ @std_ios.puts msg
71
72
 
72
73
  # this is to generate an exit code; true translates to 0, false to 1
73
74
  success
@@ -82,7 +83,7 @@ class StreamOutput
82
83
  if tests_skipped > 0
83
84
  @groups_skipped += 1
84
85
  else
85
- @ios.puts colorize(:info, "no tests defined in #{group_name}")
86
+ @std_ios.puts colorize(:info, "no tests defined in #{group_name}")
86
87
  end
87
88
  return
88
89
  end
@@ -91,7 +92,7 @@ class StreamOutput
91
92
  total_assertions = assertions_passed + assertions_failed
92
93
  if @verbose
93
94
  skipped_str = if tests_skipped > 0 then ": #{tests_ran} ran, #{tests_skipped} skipped" else '' end
94
- @ios.puts "success in #{group_name}: #{total_tests} tests#{skipped_str}; #{total_assertions} assertions" unless @badness.include?(group_name)
95
+ @std_ios.puts "success in #{group_name}: #{total_tests} tests#{skipped_str}; #{total_assertions} assertions" unless @badness.include?(group_name)
95
96
  end
96
97
  end
97
98
 
@@ -116,7 +117,7 @@ class StreamOutput
116
117
 
117
118
  def callback_failed(test_name)
118
119
  @callback_succeeded = false
119
- warn colorize(:error, "callback #{test_name} failed")
120
+ @err_ios.puts colorize(:error, "callback #{test_name} failed")
120
121
  end
121
122
 
122
123
  def assertion_passed(group_name, test_name)
@@ -133,12 +134,12 @@ private
133
134
  def display_badness(group_name, test_name, excpt)
134
135
  badness_type = if excpt.is_a?(DohTest::Failure) then :failure else :error end
135
136
  parser = DohTest::BacktraceParser.new(excpt.backtrace)
136
- warn colorize(badness_type, "#{badness_type} in #{group_name}.#{test_name} at:")
137
+ @err_ios.puts colorize(badness_type, "#{badness_type} in #{group_name}.#{test_name} at:")
137
138
  parser.relevant_stack.each do |path, line|
138
- warn "#{path}:#{line}"
139
+ @err_ios.puts "#{path}:#{line}"
139
140
  end
140
141
  if badness_type == :error
141
- warn colorize(:info, "#{excpt.class}: #{excpt.message}")
142
+ @err_ios.puts colorize(:info, "#{excpt.class}: #{excpt.message}")
142
143
  else
143
144
  display_failure_message(excpt)
144
145
  end
@@ -148,40 +149,40 @@ private
148
149
  if failure.message.empty?
149
150
  send("display_#{failure.assert}_failure", failure)
150
151
  else
151
- warn colorize(:info, failure.message)
152
+ @err_ios.puts colorize(:info, failure.message)
152
153
  end
153
154
  end
154
155
 
155
156
  def display_boolean_failure(failure)
156
- warn colorize(:info, "assertion failed")
157
+ @err_ios.puts colorize(:info, "assertion failed")
157
158
  end
158
159
 
159
160
  def display_equal_failure(failure)
160
- warn colorize(:info, "expected: #{failure.expected.inspect}\n actual: #{failure.actual.inspect}")
161
+ @err_ios.puts colorize(:info, "expected: #{failure.expected.inspect}\n actual: #{failure.actual.inspect}")
161
162
  end
162
163
 
163
164
  def display_raises_failure(failure)
164
165
  if failure.actual
165
166
  expected_str = if (failure.expected.size == 1) then failure.expected.first else "one of #{failure.expected.join(',')}" end
166
- warn colorize(:info, "expected: #{expected_str}; actual: #{failure.actual.class}: #{failure.actual.message}")
167
+ @err_ios.puts colorize(:info, "expected: #{expected_str}; actual: #{failure.actual.class}: #{failure.actual.message}")
167
168
  DohTest::BacktraceParser.new(failure.actual.backtrace).relevant_stack.each do |path, line|
168
- warn "#{path}:#{line}"
169
+ @err_ios.puts "#{path}:#{line}"
169
170
  end
170
171
  else
171
- warn colorize(:info, "expected: #{failure.expected}, but no exception was raised")
172
+ @err_ios.puts colorize(:info, "expected: #{failure.expected}, but no exception was raised")
172
173
  end
173
174
  end
174
175
 
175
176
  def display_instance_of_failure(failure)
176
- warn colorize(:info, "expected class: #{failure.expected}; actual class: #{failure.actual.class}, object: #{failure.actual}")
177
+ @err_ios.puts colorize(:info, "expected class: #{failure.expected}; actual class: #{failure.actual.class}, object: #{failure.actual}")
177
178
  end
178
179
 
179
180
  def display_match_failure(failure)
180
- warn colorize(:info, "expected regex #{failure.expected} to match str: #{failure.actual}")
181
+ @err_ios.puts colorize(:info, "expected regex #{failure.expected} to match str: #{failure.actual}")
181
182
  end
182
183
 
183
184
  def display_not_equal_failure(failure)
184
- warn colorize(:info, "expected unequal values; both are: #{failure.expected.inspect}")
185
+ @err_ios.puts colorize(:info, "expected unequal values; both are: #{failure.expected.inspect}")
185
186
  end
186
187
 
187
188
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dohtest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.21
4
+ version: 0.1.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Makani Mason