test-unit-runner-failfast 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +11 -0
- data/lib/test/unit/runner/failfast.rb +85 -0
- metadata +68 -0
data/README.md
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'test/unit/ui/console/testrunner'
|
3
|
+
|
4
|
+
class FailFastRunner < Test::Unit::UI::Console::TestRunner
|
5
|
+
def initialize(suite, options={})
|
6
|
+
@finished = []
|
7
|
+
@bar_length = 50
|
8
|
+
@status = Hash.new { |h, k| h[k] = 0 }
|
9
|
+
@bar = (0...@bar_length).map { |i| " " }
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_fault(fault)
|
14
|
+
@faults << fault
|
15
|
+
output "\r" + (" " * 80) + "\r"
|
16
|
+
output("%3d) %s" % [@faults.length, fault.long_display])
|
17
|
+
output("--")
|
18
|
+
nl
|
19
|
+
|
20
|
+
@already_outputted = true
|
21
|
+
add_progress @finished.size, char_fault(fault), 1
|
22
|
+
|
23
|
+
@status[fault.single_character_display] += 1
|
24
|
+
output_progress
|
25
|
+
end
|
26
|
+
|
27
|
+
def finished(elapsed_time)
|
28
|
+
nl
|
29
|
+
output("Finished in #{elapsed_time} seconds.")
|
30
|
+
nl
|
31
|
+
output(@result)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_finished(name)
|
35
|
+
@finished << name
|
36
|
+
add_progress @finished.size, char_success
|
37
|
+
super
|
38
|
+
end
|
39
|
+
|
40
|
+
def char_fault(fault)
|
41
|
+
char = fault.single_character_display
|
42
|
+
color = fault_color(fault)
|
43
|
+
reset = @reset_color.escape_sequence
|
44
|
+
char = "%s%s%s" % [ color.escape_sequence, char, reset ]
|
45
|
+
end
|
46
|
+
|
47
|
+
def char_success
|
48
|
+
"\033[0;43m.\033[0m"
|
49
|
+
end
|
50
|
+
|
51
|
+
# Adds a char to the progress bar.
|
52
|
+
def add_progress(i, char, priority=0)
|
53
|
+
first_index = (i-1) * @bar_length / @suite.size
|
54
|
+
last_index = i * @bar_length / @suite.size
|
55
|
+
# Don't override E's!
|
56
|
+
|
57
|
+
(first_index..last_index).each do |index|
|
58
|
+
@bar[index] = char unless @bar[index] != " " && priority == 0
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def output_started
|
63
|
+
output("Started")
|
64
|
+
nl
|
65
|
+
end
|
66
|
+
|
67
|
+
def status_indicator
|
68
|
+
status = @status.map { |char, i| "#{i}#{char}" }.join(" ")
|
69
|
+
status = " \033[0;31m[#{status}]\033[0m" unless status.empty?
|
70
|
+
status
|
71
|
+
end
|
72
|
+
|
73
|
+
def output_progress(mark=nil, color=nil)
|
74
|
+
reset = @reset_color.escape_sequence
|
75
|
+
perc = [100, @finished.size * 100 / @suite.size].min
|
76
|
+
|
77
|
+
output_status "%3i%% |%s| %3i of %i%s" % [ perc, @bar.join(""), @finished.size, @suite.size, status_indicator ]
|
78
|
+
end
|
79
|
+
|
80
|
+
def output_status(str)
|
81
|
+
print "\r#{str}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
Test::Unit::AutoRunner::RUNNERS[:failfast] = proc { |r| FailFastRunner }
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: test-unit-runner-failfast
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Rico Sta. Cruz
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-04-23 00:00:00 +08:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: test-unit
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "2.2"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
description: Test::Unit::Runner::Failfast allows you to see your Test::Unit errors more intuitively.
|
28
|
+
email:
|
29
|
+
- rico@sinefunc.com
|
30
|
+
executables: []
|
31
|
+
|
32
|
+
extensions: []
|
33
|
+
|
34
|
+
extra_rdoc_files: []
|
35
|
+
|
36
|
+
files:
|
37
|
+
- lib/test/unit/runner/failfast.rb
|
38
|
+
- README.md
|
39
|
+
has_rdoc: true
|
40
|
+
homepage: http://github.com/rstacruz/test-unit-runner-failfast
|
41
|
+
licenses: []
|
42
|
+
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.5.0
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: A Test::Unit runner that shows errors first.
|
67
|
+
test_files: []
|
68
|
+
|