Skip to content

Commit ed877ff

Browse files
committed
Initial support for Minitest 5.
1 parent 3b0e704 commit ed877ff

19 files changed

+568
-84
lines changed

.gitignore

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
Gemfile.lock
2-
log
3-
doc
4-
pkg
5-
tmp
1+
/log
2+
/doc
3+
/pkg
4+
/tmp
65
/tags
76
.ruby-version
7+
*.gem
8+
*.lock

.index

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ organizations: []
1313
requirements:
1414
- version: '>= 1.1'
1515
name: ansi
16-
- version: ~> 4
16+
- version: ~> 5
1717
name: minitest
1818
- groups:
1919
- development
@@ -37,21 +37,21 @@ repositories: []
3737
categories: []
3838
copyrights:
3939
- holder: Thomas Sawyer
40-
year: '2014'
40+
year: '2009'
4141
license: MIT
4242
- holder: Tim Pease
43-
year: '2005'
43+
year: '2006'
4444
license: MIT
4545
customs: []
4646
paths:
4747
lib:
4848
- lib
4949
name: turn
5050
title: Turn
51-
version: 0.9.7
51+
version: 1.0.0
5252
summary: Better report formats for MiniTest
5353
description: |2
5454

5555
Turn provides a set of alternative reporter formats for MiniTest,
5656
both colorful and informative.
57-
date: '2014-06-27'
57+
date: '2014-07-10'

Gemfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
source "https://rubygems.org"
22

3-
ruby ">= 1.9.2"
3+
#ruby ">= 1.9.2"
44

55
gem "ansi", ">= 1.1"
6-
gem "minitest", "~> 4"
6+
#gem "minitest", "~> 4"
7+
gem "minitest", "~> 5"
78

89
group :development do
910
gem "rake"

bin/turn

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env ruby
22
require 'turn'
33
begin
4-
Turn::Command.main(*ARGV)
4+
Turn.run
5+
#Turn::Command.main(*ARGV)
56
rescue StandardError => e
67
raise if $DEBUG
78
puts e

lib/minitest/turn_plugin.rb

+181
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
module Minitest
2+
3+
# Select report format.
4+
#
5+
# -T outline turn's original case/test outline mode
6+
# -T progress indicates progress with progress bar
7+
# -T dot test-unit's traditonal dot-progress mode
8+
# -T pretty new pretty output mode [default]
9+
# -T cue cue for action on each failure/error
10+
# -T marshal dump output as YAML (normal run mode only)
11+
#
12+
def self.plugin_turn_options(opts, options)
13+
unless $turn_command
14+
opts.on "-t", "--turn", "Use Turn for output." do |format|
15+
$turn_command = true
16+
end
17+
end
18+
19+
options[:loadpath] ||= []
20+
options[:requires] ||= []
21+
22+
opts.separator " "
23+
opts.separator "turn options:"
24+
25+
opts.on('-I', '--loadpath=PATHS', "add paths to $LOAD_PATH") do |path|
26+
options[:loadpath].concat(path.split(':'))
27+
end
28+
opts.on('-r', '--require=LIBS', "require libraries") do |lib|
29+
@options[:requires].concat(lib.split(':'))
30+
end
31+
#opts.on('-n', '--name=PATTERN', "only run tests that match PATTERN") do |pattern|
32+
# if pattern =~ /\/(.*)\//
33+
# options[:pattern] = Regexp.new($1)
34+
# else
35+
# options[:pattern] = Regexp.new(pattern, Regexp::IGNORECASE)
36+
# end
37+
#end
38+
#opts.on('-c', '--case=PATTERN', "only run test cases that match PATTERN") do |pattern|
39+
# if pattern =~ /\/(.*)\//
40+
# options[:matchcase] = Regexp.new($1)
41+
# else
42+
# options[:matchcase] = Regexp.new(pattern, Regexp::IGNORECASE)
43+
# end
44+
#end
45+
opts.on('-m', '--mark=SECONDS', "Mark test if it exceeds runtime threshold.") do |int|
46+
@options[:mark] = int.to_i
47+
end
48+
opts.on('-b', '--backtrace', '--trace INT', "Limit the number of lines of backtrace.") do |int|
49+
options[:trace] = int
50+
end
51+
opts.on('--natural', "Show natualized test names.") do |bool|
52+
options[:natural] = bool
53+
end
54+
opts.on('-v', '--verbose', "Show extra information.") do |bool|
55+
options[:verbose] = bool
56+
end
57+
opts.on('--[no-]ansi', "Force use of ANSI codes on or off.") do |bool|
58+
options[:ansi] = bool
59+
end
60+
opts.on('--log', "log results to a file") do #|path|
61+
options[:log] = true # TODO: support path/file
62+
end
63+
#opts.on('--live', "do not use local load path") do
64+
# options[:live] = true
65+
#end
66+
67+
opts.on('--normal', "run all tests in a single process [default]") do
68+
options[:runmode] = nil
69+
end
70+
opts.on('--solo', "run each test in a separate process") do
71+
options[:runmode] = :solo
72+
end
73+
opts.on('--cross', "run each pair of test files in a separate process") do
74+
options[:runmode] = :cross
75+
end
76+
77+
opts.on('--outline', '-O', "turn's original case/test outline mode") do
78+
options[:outmode] = :outline
79+
end
80+
opts.on('--progress', '-P', "indicates progress with progress bar") do
81+
options[:outmode] = :progress
82+
end
83+
opts.on('--dot', '--dotted', '-D', "test-unit's traditonal dot-progress mode") do
84+
options[:outmode] = :dot
85+
end
86+
opts.on('--pretty', '-R', '-T', "new pretty output mode [default]") do
87+
options[:outmode] = :pretty
88+
end
89+
opts.on('--cue', '-C', "cue for action on each failure/error") do
90+
options[:outmode] = :cue
91+
end
92+
opts.on('--marshal', '-M', "dump output as YAML (normal run mode only)") do
93+
options[:runmode] = :marshal
94+
options[:outmode] = :marshal
95+
end
96+
97+
opts.on('--topten', "show only top ten slowest tests") do
98+
@options[:decmode] = :topten
99+
end
100+
opts.on('--debug', "turn debug mode on") do
101+
$DEBUG = true
102+
end
103+
opts.on('--warn', "turn warnings on") do
104+
$VERBOSE = true
105+
end
106+
107+
# DEPRECATED Thanks to minitest-reporter-api gem.
108+
#unless options[:minitap]
109+
# if defined?(Minitest::TapY) && self.reporter == Minitest::TapY
110+
# options[:minitap] = 'tapy'
111+
# elsif defined?(Minitest::TapJ) && self.reporter == Minitest::TapJ
112+
# options[:minitap] = 'tapj'
113+
# end
114+
#end
115+
end
116+
117+
#
118+
#
119+
def self.plugin_turn_init(options)
120+
if $turn_command || ENV['turn']
121+
122+
require 'turn'
123+
124+
self.reporter.reporters.clear
125+
126+
format = options[:outmode] || ENV['turn'] || 'pretty'
127+
128+
case format.to_s
129+
when 'dot', 'd'
130+
require 'turn/reporters/dot_reporter'
131+
self.reporter << Turn::DotReporter.new(options)
132+
when 'cue', 'c'
133+
require 'turn/reporters/cue_reporter'
134+
self.reporter << Turn::CueReporter.new(options)
135+
when 'pretty', 't'
136+
require 'turn/reporters/pretty_reporter'
137+
self.reporter << Turn::PrettyReporter.new(options)
138+
when 'outline', 'o'
139+
require 'turn/reporters/outline_reporter'
140+
self.reporter << Turn::OutlineReporter.new(options)
141+
when 'progress', 'p'
142+
require 'turn/reporters/progress_reporter'
143+
self.reporter << Turn::ProgressReporter.new(options)
144+
when 'marshal', 'm'
145+
require 'turn/reporters/marshal_reporter'
146+
self.reporter << Turn::MarshalReporter.new(options)
147+
else
148+
raise "Unknown reporter -- `#{format}'"
149+
end
150+
151+
options[:tests] = ARGV.empty? ? nil : ARGV.dup
152+
153+
config = Turn.config
154+
config.tests = options[:tests]
155+
config.live = options[:live]
156+
config.log = options[:log]
157+
config.loadpath = options[:loadpath]
158+
config.requires = options[:requires]
159+
config.runmode = options[:runmode]
160+
config.format = options[:outmode]
161+
config.mode = options[:decmode]
162+
config.pattern = options[:pattern]
163+
config.matchcase = options[:matchcase]
164+
config.trace = options[:trace]
165+
config.natural = options[:natural]
166+
config.verbose = options[:verbose]
167+
config.mark = options[:mark]
168+
config.ansi = options[:ansi] unless options[:ansi].nil?
169+
170+
config.loadpath.each{ |path| $: << path } unless config.live?
171+
config.requires.each{ |path| require(path) }
172+
173+
# load'em up
174+
if $turn_command
175+
config.files.each{ |path| require(path) }
176+
end
177+
end
178+
end
179+
180+
end
181+

lib/turn.rb

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
module Turn
2+
# Use by the command line tool to start test run.
3+
def self.run
4+
$turn_command = true
5+
Minitest.autorun
6+
end
27
end
38

49
require 'fileutils'
@@ -10,5 +15,6 @@ module Turn
1015
require 'turn/components'
1116
require 'turn/controller'
1217
require 'turn/command'
18+
1319
require 'turn/minitest'
1420

0 commit comments

Comments
 (0)