tconsole 1.1.0pre5 → 1.1.0pre6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tconsole.rb +13 -1
- data/lib/tconsole/config.rb +20 -3
- data/lib/tconsole/minitest_handler.rb +37 -21
- data/lib/tconsole/server.rb +18 -1
- data/lib/tconsole/version.rb +1 -1
- metadata +3 -3
data/lib/tconsole.rb
CHANGED
@@ -122,7 +122,7 @@ module TConsole
|
|
122
122
|
end
|
123
123
|
|
124
124
|
class Console
|
125
|
-
KNOWN_COMMANDS = ["exit", "reload", "help", "units", "functionals", "integration", "recent", "uncommitted", "all", "info", "!failed", "!timings"]
|
125
|
+
KNOWN_COMMANDS = ["exit", "reload", "help", "units", "functionals", "integration", "recent", "uncommitted", "all", "info", "!failed", "!timings", "set"]
|
126
126
|
|
127
127
|
def initialize
|
128
128
|
read_history
|
@@ -163,6 +163,8 @@ module TConsole
|
|
163
163
|
server.show_performance(args[1])
|
164
164
|
elsif args[0] == "info"
|
165
165
|
server.run_info
|
166
|
+
elsif args[0] == "set"
|
167
|
+
server.set(args[1], args[2])
|
166
168
|
else
|
167
169
|
server.run_tests([args[0]], args[1])
|
168
170
|
end
|
@@ -186,6 +188,7 @@ module TConsole
|
|
186
188
|
puts "!timings [limit] # Lists the timings for the last test run, sorted."
|
187
189
|
puts "[filename] [test_pattern] # Run the tests contained in the given file"
|
188
190
|
puts "reload # Reload your Rails environment"
|
191
|
+
puts "set [variable] [value] # Sets a runtime variable (see below for details)"
|
189
192
|
puts "exit # Exit the console"
|
190
193
|
puts
|
191
194
|
puts "Working with test patterns:"
|
@@ -195,6 +198,15 @@ module TConsole
|
|
195
198
|
puts "name matches the pattern given. This is especially useful when rerunning a failing"
|
196
199
|
puts "test."
|
197
200
|
puts
|
201
|
+
puts "Runtime Variables"
|
202
|
+
puts
|
203
|
+
puts "You can set runtime variables with the set command. This helps out with changing"
|
204
|
+
puts "features of TConsole that you may want to change at runtime. At present, the"
|
205
|
+
puts "following runtime variables are available:"
|
206
|
+
puts
|
207
|
+
puts "fast # Turns on fail fast mode. Values: on, off"
|
208
|
+
puts
|
209
|
+
|
198
210
|
end
|
199
211
|
|
200
212
|
def history_file
|
data/lib/tconsole/config.rb
CHANGED
@@ -3,28 +3,45 @@ module TConsole
|
|
3
3
|
# Lets us know if we should include trace output
|
4
4
|
attr_accessor :trace_execution
|
5
5
|
|
6
|
-
#
|
6
|
+
# Lets us know if we should include trace output.
|
7
|
+
# Defaults to false.
|
8
|
+
attr_accessor :trace
|
9
|
+
|
10
|
+
# Test directory for the app we're testing.
|
11
|
+
# Defaults to ./test.
|
7
12
|
attr_accessor :test_dir
|
8
13
|
|
9
|
-
# Paths to add to the ruby include path
|
14
|
+
# Paths to add to the ruby include path.
|
15
|
+
# Defaults to ./test, ./lib
|
10
16
|
attr_accessor :include_paths
|
11
17
|
|
12
|
-
# Paths we want to preload
|
18
|
+
# Paths we want to preload. Defaults to nil.
|
13
19
|
attr_accessor :preload_paths
|
14
20
|
|
21
|
+
# Whether or not our test runs should stop when the first
|
22
|
+
# test fails. Defaults to false.
|
23
|
+
attr_accessor :fail_fast
|
24
|
+
|
15
25
|
def initialize
|
16
26
|
self.trace_execution = false
|
17
27
|
self.test_dir = "./test"
|
18
28
|
self.include_paths = ["./test", "./lib"]
|
19
29
|
self.preload_paths = []
|
30
|
+
self.fail_fast = false
|
20
31
|
|
21
32
|
@after_load = nil
|
33
|
+
@before_load = nil
|
34
|
+
@before_test_run = nil
|
22
35
|
end
|
23
36
|
|
24
37
|
def trace?
|
25
38
|
self.trace_execution
|
26
39
|
end
|
27
40
|
|
41
|
+
def fail_fast?
|
42
|
+
self.fail_fast
|
43
|
+
end
|
44
|
+
|
28
45
|
# Code to run before loading the environment
|
29
46
|
def before_load(&block)
|
30
47
|
@before_load = block
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module TConsole
|
2
2
|
class MiniTestHandler
|
3
|
-
def self.run(name_pattern)
|
3
|
+
def self.run(name_pattern, config)
|
4
4
|
args = []
|
5
5
|
unless name_pattern.nil?
|
6
6
|
args = ["--name", name_pattern]
|
@@ -8,7 +8,7 @@ module TConsole
|
|
8
8
|
|
9
9
|
# Make sure we have a recent version of minitest, and use it
|
10
10
|
if ::MiniTest::Unit.respond_to?(:runner=)
|
11
|
-
::MiniTest::Unit.runner = TConsole::MiniTestUnit.new
|
11
|
+
::MiniTest::Unit.runner = TConsole::MiniTestUnit.new(config)
|
12
12
|
else
|
13
13
|
raise "MiniTest v#{MiniTest::Unit::VERSION} is not compatible with tconsole. Please load a more recent version of MiniTest"
|
14
14
|
end
|
@@ -48,12 +48,13 @@ module TConsole
|
|
48
48
|
"P" => ::Term::ANSIColor.green
|
49
49
|
}
|
50
50
|
|
51
|
-
attr_accessor :results
|
51
|
+
attr_accessor :config, :results
|
52
52
|
|
53
|
-
def initialize
|
53
|
+
def initialize(config)
|
54
|
+
self.config = config
|
54
55
|
self.results = TConsole::TestResult.new
|
55
56
|
|
56
|
-
super
|
57
|
+
super()
|
57
58
|
end
|
58
59
|
|
59
60
|
def _run_anything(type)
|
@@ -95,30 +96,45 @@ module TConsole
|
|
95
96
|
end
|
96
97
|
|
97
98
|
def _run_suite(suite, type)
|
99
|
+
@failed_fast ||= false
|
100
|
+
|
98
101
|
filter = options[:filter] || '/./'
|
99
102
|
filter = Regexp.new $1 if filter =~ /\/(.*)\//
|
100
103
|
|
101
|
-
assertions = suite.send("#{type}_methods").grep(filter).map
|
102
|
-
|
103
|
-
|
104
|
+
assertions = suite.send("#{type}_methods").grep(filter).map do |method|
|
105
|
+
if @failed_fast
|
106
|
+
0
|
107
|
+
else
|
108
|
+
inst = suite.new method
|
109
|
+
inst._assertions = 0
|
104
110
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
111
|
+
# Print the suite name if needed
|
112
|
+
if results.add_suite(suite)
|
113
|
+
print("\n\n", ::Term::ANSIColor.cyan, suite, ::Term::ANSIColor.reset, "\n")
|
114
|
+
end
|
115
|
+
|
116
|
+
@start_time = Time.now
|
117
|
+
result = inst.run self
|
118
|
+
time = Time.now - @start_time
|
119
|
+
results.add_timing(suite, method, time)
|
120
|
+
|
121
|
+
result = "P" if result == "."
|
109
122
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
123
|
+
if config.fail_fast && result != "P"
|
124
|
+
@failed_fast = true
|
125
|
+
end
|
126
|
+
|
127
|
+
output = "#{result} #{method}"
|
114
128
|
|
115
|
-
|
116
|
-
output = "#{result} #{method}"
|
129
|
+
print COLOR_MAP[result], " #{output}", ::Term::ANSIColor.reset, " #{time}s\n"
|
117
130
|
|
118
|
-
|
131
|
+
if @failed_fast
|
132
|
+
print "\n", COLOR_MAP["E"], "Halting tests because of failure.", ::Term::ANSIColor.reset, "\n"
|
133
|
+
end
|
119
134
|
|
120
|
-
|
121
|
-
|
135
|
+
inst._assertions
|
136
|
+
end
|
137
|
+
end
|
122
138
|
|
123
139
|
return assertions.size, assertions.inject(0) { |sum, n| sum + n }
|
124
140
|
end
|
data/lib/tconsole/server.rb
CHANGED
@@ -76,7 +76,7 @@ module TConsole
|
|
76
76
|
if defined?(::MiniTest)
|
77
77
|
require File.join(File.dirname(__FILE__), "minitest_handler")
|
78
78
|
|
79
|
-
result = MiniTestHandler.run(name_pattern)
|
79
|
+
result = MiniTestHandler.run(name_pattern, config)
|
80
80
|
|
81
81
|
write.puts([Marshal.dump(result)].pack("m"))
|
82
82
|
|
@@ -204,6 +204,23 @@ module TConsole
|
|
204
204
|
puts
|
205
205
|
end
|
206
206
|
|
207
|
+
def set(key, value)
|
208
|
+
if key == "fast"
|
209
|
+
value.downcase!
|
210
|
+
if value == "on" || value == "true" || value == "yes"
|
211
|
+
config.fail_fast = true
|
212
|
+
else
|
213
|
+
config.fail_fast = false
|
214
|
+
end
|
215
|
+
|
216
|
+
puts "Fail Fast is now #{config.fail_fast ? "on" : "off"}"
|
217
|
+
puts
|
218
|
+
else
|
219
|
+
puts "#{key} isn't an available runtime setting."
|
220
|
+
puts
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
207
224
|
def filenameify(klass_name)
|
208
225
|
result = ""
|
209
226
|
first = true
|
data/lib/tconsole/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tconsole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.0pre6
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-02-17 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: term-ansicolor
|
16
|
-
requirement: &
|
16
|
+
requirement: &70270052774740 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 1.0.7
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70270052774740
|
25
25
|
description: ! " tconsole allows Rails developers to easily and quickly run their
|
26
26
|
tests as a whole or in subsets. It forks the testing processes from\n a preloaded
|
27
27
|
test environment to ensure that developers don't have to reload their entire Rails
|