tconsole 1.1.0pre9 → 1.1.0pre10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +2 -2
- data/lib/tconsole.rb +16 -38
- data/lib/tconsole/console.rb +14 -7
- data/lib/tconsole/minitest_handler.rb +5 -5
- data/lib/tconsole/pipe_server.rb +47 -0
- data/lib/tconsole/server.rb +26 -8
- data/lib/tconsole/test_result.rb +7 -7
- data/lib/tconsole/version.rb +1 -1
- metadata +5 -5
- data/drb_connection_test.rb +0 -63
data/README.md
CHANGED
@@ -32,7 +32,7 @@ Installing tconsole
|
|
32
32
|
|
33
33
|
Prereleases of tconsole come out pretty frequently. You can install the latest prerelease version with:
|
34
34
|
|
35
|
-
gem
|
35
|
+
gem install tconsole --pre
|
36
36
|
|
37
37
|
How to use tconsole
|
38
38
|
------
|
@@ -45,7 +45,7 @@ In your shell of choice, cd into your Rails project's directory and then run `bu
|
|
45
45
|
|
46
46
|
>
|
47
47
|
|
48
|
-
Now that you're in the console, let's test out the all command! Running all from the console runs all of your unit, functional, and integration tests:
|
48
|
+
Now that you're in the console, let's test out the `all` command! Running `all` from the console runs all of your unit, functional, and integration tests:
|
49
49
|
|
50
50
|
> all
|
51
51
|
Running tests...
|
data/lib/tconsole.rb
CHANGED
@@ -2,6 +2,7 @@ require "tconsole/version"
|
|
2
2
|
require "tconsole/config"
|
3
3
|
require "tconsole/console"
|
4
4
|
require "tconsole/server"
|
5
|
+
require "tconsole/pipe_server"
|
5
6
|
require "tconsole/test_result"
|
6
7
|
require "tconsole/util"
|
7
8
|
|
@@ -37,63 +38,40 @@ module TConsole
|
|
37
38
|
while running
|
38
39
|
# ignore ctrl-c during load, since things can get kind of messy if we don't
|
39
40
|
|
41
|
+
pipe_server = PipeServer.new
|
42
|
+
|
40
43
|
config.trace("Forking test server.")
|
41
44
|
server_pid = fork do
|
45
|
+
pipe_server.callee!
|
46
|
+
|
42
47
|
begin
|
43
48
|
server = Server.new(config)
|
44
49
|
|
45
|
-
|
46
|
-
|
50
|
+
while message = pipe_server.read
|
51
|
+
config.trace("Server Received Message: #{message[:action]}")
|
52
|
+
pipe_server.write(server.handle(message))
|
53
|
+
end
|
54
|
+
|
47
55
|
rescue Interrupt
|
48
56
|
# do nothing here since the outer process will shut things down for us
|
49
57
|
end
|
50
58
|
end
|
51
59
|
|
52
|
-
|
60
|
+
pipe_server.caller!
|
53
61
|
|
54
|
-
|
55
|
-
config.trace("Connecting to testing server.")
|
56
|
-
DRb.start_service
|
57
|
-
server = nil
|
58
|
-
|
59
|
-
loaded = false
|
60
|
-
until loaded || Time.now > wait_until
|
61
|
-
begin
|
62
|
-
server = DRbObject.new_with_uri("drbunix:/tmp/tconsole.#{server_pid}")
|
63
|
-
|
64
|
-
config.trace("Testing connection to test server.")
|
65
|
-
loaded = server.connected?
|
66
|
-
rescue
|
67
|
-
# do nothing
|
68
|
-
config.trace("Not connected to server yet. Retrying.")
|
69
|
-
sleep(1)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
unless loaded
|
74
|
-
puts
|
75
|
-
puts "Couldn't connect to the test environment. Exiting."
|
76
|
-
exit(1)
|
77
|
-
end
|
62
|
+
wait_until = Time.now + 10
|
78
63
|
|
79
|
-
|
80
|
-
|
81
|
-
running = server.load_environment
|
82
|
-
rescue => e
|
83
|
-
config.trace("Could not load environment: #{e.message}")
|
84
|
-
config.trace("==== Backtrace ====")
|
85
|
-
config.trace(e.backtrace.join("\n"))
|
86
|
-
config.trace("==== End Backtrace ====")
|
64
|
+
config.trace("Attempting to load environment.")
|
65
|
+
pipe_server.write({:action => "load_environment"})
|
87
66
|
|
67
|
+
unless pipe_server.read
|
88
68
|
puts "Couldn't load the test environment. Exiting."
|
89
69
|
exit(1)
|
90
70
|
end
|
91
|
-
|
92
71
|
config.trace("Environment loaded successfully.")
|
93
72
|
|
94
|
-
running = console.read_and_execute(
|
73
|
+
running = console.read_and_execute(pipe_server)
|
95
74
|
|
96
|
-
server.stop
|
97
75
|
Process.waitall
|
98
76
|
end
|
99
77
|
|
data/lib/tconsole/console.rb
CHANGED
@@ -30,7 +30,7 @@ module TConsole
|
|
30
30
|
end
|
31
31
|
|
32
32
|
# Returns true if the app should keep running, false otherwise
|
33
|
-
def read_and_execute(
|
33
|
+
def read_and_execute(pipe_server)
|
34
34
|
while line = Readline.readline("tconsole> ", false)
|
35
35
|
line.strip!
|
36
36
|
args = Shellwords.shellwords(line)
|
@@ -43,29 +43,36 @@ module TConsole
|
|
43
43
|
if line == ""
|
44
44
|
# do nothing
|
45
45
|
elsif args[0] == "exit"
|
46
|
+
send_message_to_server({:action => "exit"}, pipe_server)
|
46
47
|
return false
|
47
48
|
elsif args[0] == "reload"
|
49
|
+
send_message_to_server({:action => "exit"}, pipe_server)
|
48
50
|
return true
|
49
51
|
elsif args[0] == "help"
|
50
52
|
print_help
|
51
53
|
elsif args[0] == "!failed"
|
52
|
-
|
54
|
+
send_message_to_server({:action => "run_failed"}, pipe_server)
|
53
55
|
elsif args[0] == "!timings"
|
54
|
-
|
56
|
+
send_message_to_server({:action => "show_performance", :limit => args[1]}, pipe_server)
|
55
57
|
elsif args[0] == "info"
|
56
|
-
|
58
|
+
send_message_to_server({:action => "run_info"}, pipe_server)
|
57
59
|
elsif args[0] == "set"
|
58
|
-
|
60
|
+
send_message_to_server({:action => "set", :var => args[1], :value => args[2]}, pipe_server)
|
59
61
|
elsif @config.file_sets.has_key?(args[0])
|
60
|
-
|
62
|
+
send_message_to_server({:action => "run_file_set", :set => args[0]}, pipe_server)
|
61
63
|
else
|
62
|
-
|
64
|
+
send_message_to_server({:action => "run_all_tests", :args => args}, pipe_server)
|
63
65
|
end
|
64
66
|
end
|
65
67
|
|
66
68
|
true
|
67
69
|
end
|
68
70
|
|
71
|
+
def send_message_to_server(message, pipe_server)
|
72
|
+
pipe_server.write(message)
|
73
|
+
pipe_server.read
|
74
|
+
end
|
75
|
+
|
69
76
|
# Prints a list of available commands
|
70
77
|
def print_help
|
71
78
|
puts
|
@@ -113,10 +113,10 @@ module TConsole
|
|
113
113
|
# If we've got match patterns, see if this matches them
|
114
114
|
if !match_patterns.empty?
|
115
115
|
match = match_patterns.find do |pattern|
|
116
|
-
pattern == suite.to_s || pattern == "#{suite.to_s}##{method.to_s}" || pattern == suite_id || pattern == id
|
116
|
+
pattern == suite.to_s || pattern == "#{suite.to_s}##{method.to_s}" || pattern == suite_id.to_s || pattern == id
|
117
117
|
end
|
118
118
|
|
119
|
-
skip = true unless match
|
119
|
+
skip = true unless !match.nil?
|
120
120
|
end
|
121
121
|
|
122
122
|
if skip
|
@@ -165,16 +165,16 @@ module TConsole
|
|
165
165
|
e = case e
|
166
166
|
when MiniTest::Skip then
|
167
167
|
@skips += 1
|
168
|
-
results.
|
168
|
+
results.skip_count += 1
|
169
169
|
return "S" unless @verbose
|
170
170
|
"Skipped:\n#{meth}(#{klass}) [#{location e}]:\n#{e.message}\n"
|
171
171
|
when MiniTest::Assertion then
|
172
172
|
@failures += 1
|
173
|
-
results.
|
173
|
+
results.failure_count += 1
|
174
174
|
"Failure:\n#{meth}(#{klass}) [#{location e}]:\n#{e.message}\n"
|
175
175
|
else
|
176
176
|
@errors += 1
|
177
|
-
results.
|
177
|
+
results.error_count += 1
|
178
178
|
bt = MiniTest::filter_backtrace(e.backtrace).join "\n "
|
179
179
|
"Error:\n#{meth}(#{klass}):\n#{e.class}: #{e.message}\n #{bt}\n"
|
180
180
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module TConsole
|
2
|
+
class PipeServer
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@callee = []
|
6
|
+
@caller = []
|
7
|
+
@callee[0], @caller[1] = IO.pipe
|
8
|
+
@caller[0], @callee[1] = IO.pipe
|
9
|
+
|
10
|
+
@me = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
# Identifies the current process as the callee process
|
14
|
+
def callee!
|
15
|
+
@me = @callee
|
16
|
+
|
17
|
+
@caller.each do |io|
|
18
|
+
io.close
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Identifies the current process as the caller process
|
23
|
+
def caller!
|
24
|
+
@me = @caller
|
25
|
+
|
26
|
+
@callee.each do |io|
|
27
|
+
io.close
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Writes a message to the appropriate pipe. The message can be
|
32
|
+
# anything that will Marshal cleanly
|
33
|
+
def write(message)
|
34
|
+
encoded_message = [Marshal.dump(message)].pack("m0")
|
35
|
+
@me[1].puts(encoded_message)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Reads a message from the appropriate pipe and unmarshalls it
|
39
|
+
def read
|
40
|
+
raw_message = @me[0].gets
|
41
|
+
|
42
|
+
return nil if raw_message.nil?
|
43
|
+
|
44
|
+
Marshal.load(raw_message.unpack("m")[0])
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/tconsole/server.rb
CHANGED
@@ -7,13 +7,26 @@ module TConsole
|
|
7
7
|
self.last_result = TConsole::TestResult.new
|
8
8
|
end
|
9
9
|
|
10
|
-
#
|
11
|
-
def
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
# Processes the message sent from the console
|
11
|
+
def handle(message)
|
12
|
+
action = message[:action]
|
13
|
+
if action == "load_environment"
|
14
|
+
load_environment
|
15
|
+
elsif action == "run_failed"
|
16
|
+
run_failed
|
17
|
+
elsif action == "show_performance"
|
18
|
+
show_performance(message[:limit])
|
19
|
+
elsif action == "run_info"
|
20
|
+
run_info
|
21
|
+
elsif action == "set"
|
22
|
+
set(message[:var], message[:value])
|
23
|
+
elsif action == "run_file_set"
|
24
|
+
run_file_set(message[:set])
|
25
|
+
elsif action == "run_all_tests"
|
26
|
+
run_all_tests(message[:args])
|
27
|
+
elsif action == "exit"
|
28
|
+
exit(0)
|
29
|
+
end
|
17
30
|
end
|
18
31
|
|
19
32
|
def load_environment
|
@@ -145,7 +158,12 @@ module TConsole
|
|
145
158
|
end
|
146
159
|
|
147
160
|
def run_failed
|
148
|
-
|
161
|
+
if last_result.failures.empty?
|
162
|
+
puts "No tests failed in your last run, or you haven't run any tests in this session yet."
|
163
|
+
puts
|
164
|
+
else
|
165
|
+
run_tests(config.file_sets["all"], last_result.failures)
|
166
|
+
end
|
149
167
|
end
|
150
168
|
|
151
169
|
def run_info
|
data/lib/tconsole/test_result.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
module TConsole
|
2
2
|
class TestResult
|
3
3
|
# The number of failed tests in the last run
|
4
|
-
attr_accessor :
|
4
|
+
attr_accessor :failure_count
|
5
5
|
|
6
6
|
# The number of errors that occurred in the last run
|
7
|
-
attr_accessor :
|
7
|
+
attr_accessor :error_count
|
8
8
|
|
9
9
|
# The number of skipped tests
|
10
|
-
attr_accessor :
|
10
|
+
attr_accessor :skip_count
|
11
11
|
|
12
12
|
# Details about the failures in the last run
|
13
|
-
attr_accessor :
|
13
|
+
attr_accessor :failures
|
14
14
|
|
15
15
|
# The suites that we've run
|
16
16
|
attr_accessor :suites
|
@@ -25,9 +25,9 @@ module TConsole
|
|
25
25
|
attr_accessor :suite_counts
|
26
26
|
|
27
27
|
def initialize
|
28
|
-
self.
|
29
|
-
self.
|
30
|
-
self.
|
28
|
+
self.failure_count = 0
|
29
|
+
self.error_count = 0
|
30
|
+
self.skip_count = 0
|
31
31
|
self.failures = []
|
32
32
|
self.suites = {}
|
33
33
|
self.timings = []
|
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.0pre10
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: term-ansicolor
|
16
|
-
requirement: &
|
16
|
+
requirement: &70325750739560 !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: *70325750739560
|
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
|
@@ -39,11 +39,11 @@ files:
|
|
39
39
|
- README.md
|
40
40
|
- Rakefile
|
41
41
|
- bin/tconsole
|
42
|
-
- drb_connection_test.rb
|
43
42
|
- lib/tconsole.rb
|
44
43
|
- lib/tconsole/config.rb
|
45
44
|
- lib/tconsole/console.rb
|
46
45
|
- lib/tconsole/minitest_handler.rb
|
46
|
+
- lib/tconsole/pipe_server.rb
|
47
47
|
- lib/tconsole/server.rb
|
48
48
|
- lib/tconsole/test_result.rb
|
49
49
|
- lib/tconsole/util.rb
|
data/drb_connection_test.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "drb/drb"
|
4
|
-
|
5
|
-
class Server
|
6
|
-
def connected?
|
7
|
-
true
|
8
|
-
end
|
9
|
-
|
10
|
-
def load_environment
|
11
|
-
ENV['RAILS_ENV'] ||= "test"
|
12
|
-
|
13
|
-
require './config/application'
|
14
|
-
|
15
|
-
::Rails.application
|
16
|
-
::Rails::Engine.class_eval do
|
17
|
-
def eager_load!
|
18
|
-
# turn off eager_loading
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
true
|
23
|
-
end
|
24
|
-
|
25
|
-
def stop
|
26
|
-
DRb.stop_service
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
socket = "/tmp/test.#{Process.pid}"
|
31
|
-
|
32
|
-
server_pid = fork do
|
33
|
-
server = Server.new
|
34
|
-
|
35
|
-
drb_server = DRb.start_service("drbunix:#{socket}", server)
|
36
|
-
DRb.thread.join
|
37
|
-
end
|
38
|
-
|
39
|
-
wait_until = Time.now + 10
|
40
|
-
DRb.start_service
|
41
|
-
|
42
|
-
loaded = false
|
43
|
-
until loaded || Time.now > wait_until
|
44
|
-
begin
|
45
|
-
puts "Trying to load environment"
|
46
|
-
server = DRbObject.new_with_uri("drbunix:#{socket}")
|
47
|
-
loaded = server.connected?
|
48
|
-
rescue
|
49
|
-
puts "Couldn't connect. Waiting."
|
50
|
-
sleep(1)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
if !loaded
|
55
|
-
puts "Wasn't able to connect"
|
56
|
-
end
|
57
|
-
|
58
|
-
puts "Connected! Attempting to load environment"
|
59
|
-
server.load_environment
|
60
|
-
puts "Environment loaded!"
|
61
|
-
|
62
|
-
# Clean it all up
|
63
|
-
server.stop
|