tconsole 1.3.0.pre1 → 1.3.0.pre2

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.
@@ -67,7 +67,6 @@ module TConsole
67
67
  sets.each do |set|
68
68
  self.file_sets[set] = ["#{test_dir}/#{set}/**/*_spec.rb"]
69
69
  end
70
- puts self.file_sets.to_s
71
70
  else
72
71
  self.file_sets = {
73
72
  "all" => ["#{test_dir}/**/*_test.rb"]
@@ -84,6 +83,11 @@ module TConsole
84
83
  @cached_suite_counts = {}
85
84
  @cached_elements = {}
86
85
  end
86
+
87
+ # Returns the string name of our current app, i.e. tconsole or rconsole
88
+ def app
89
+ Config.app(mode)
90
+ end
87
91
 
88
92
  def option_parser
89
93
  @option_parser ||= OptionParser.new do |opts|
@@ -234,5 +238,10 @@ module TConsole
234
238
  def self.is_rails?
235
239
  @rails ||= !!File.exist?("./config/application.rb")
236
240
  end
241
+
242
+ # Public: Returns the app name based on the given mode.
243
+ def self.app(mode)
244
+ mode == :minitest ? "tconsole" : "rconsole"
245
+ end
237
246
  end
238
247
  end
@@ -29,7 +29,7 @@ module TConsole
29
29
 
30
30
  # Returns true if the app should keep running, false otherwise
31
31
  def read_and_execute(pipe_server)
32
- prompt = "tconsole> "
32
+ prompt = "#{config.app}> "
33
33
 
34
34
  trap("SIGTSTP", "SYSTEM_DEFAULT")
35
35
  trap("SIGCONT") do
@@ -60,7 +60,7 @@ module TConsole
60
60
  end
61
61
 
62
62
  elsif defined?(::Test::Unit)
63
- reporter.error("Sorry, but tconsole doesn't support Test::Unit")
63
+ reporter.error("Sorry, but #{config.app} doesn't support Test::Unit")
64
64
  end
65
65
 
66
66
  result
@@ -90,8 +90,8 @@ module TConsole
90
90
  puts "Runtime Variables"
91
91
  puts
92
92
  puts "You can set runtime variables with the set command. This helps out with changing"
93
- puts "features of TConsole that you may want to change at runtime. At present, the"
94
- puts "following runtime variables are available:"
93
+ puts "features that you may want to change at runtime. At present, the following"
94
+ puts "runtime variables are available:"
95
95
  puts
96
96
  puts "fast # Turns on fail fast mode. Values: on, off"
97
97
  puts
@@ -101,7 +101,7 @@ module TConsole
101
101
  # Public: Outputs the tconsole welcome message
102
102
  def welcome_message
103
103
  info
104
- info("Welcome to tconsole (v#{TConsole::VERSION}). Type 'help' for help or 'exit' to quit.")
104
+ info("Welcome to #{config.app} (v#{TConsole::VERSION}). Type 'help' for help or 'exit' to quit.")
105
105
  end
106
106
 
107
107
  # Public: Outputs the tconsole exit message
@@ -95,24 +95,6 @@ module TConsole
95
95
  reporter.info
96
96
  end
97
97
 
98
- # Preloads our autocomplete cache
99
- def preload_test_ids
100
- result = nil
101
- # result = run_in_fork do
102
- # paths = []
103
- # config.file_sets["all"].each do |glob|
104
- # paths.concat(Dir.glob(glob))
105
- # end
106
- #
107
- # paths.each { |path| require File.expand_path(path) }
108
- #
109
- # require File.join(File.dirname(__FILE__), "minitest_handler")
110
- # MiniTestHandler.preload_elements
111
- # end
112
-
113
- config.cache_test_ids(result) unless result.nil?
114
- end
115
-
116
98
  # Runs all tests against the match patterns given
117
99
  def run_all_tests(match_patterns = nil)
118
100
  run_tests(config.file_sets["all"], match_patterns)
@@ -122,14 +104,5 @@ module TConsole
122
104
  def run_file_set(set)
123
105
  run_tests(config.file_sets[set], nil)
124
106
  end
125
-
126
- def run_failed
127
- if last_result.failures.empty?
128
- reporter.info("No tests failed in your last run, or you haven't run any tests in this session yet.")
129
- reporter.info
130
- else
131
- run_tests(config.file_sets["all"], last_result.failures)
132
- end
133
- end
134
107
  end
135
108
  end
@@ -8,8 +8,8 @@ module TConsole
8
8
  self.mode = mode
9
9
 
10
10
  # try to load the default configs
11
- Config.load_config(File.join(Dir.home, ".tconsole"))
12
- Config.load_config(File.join(Dir.pwd, ".tconsole"))
11
+ Config.load_config(File.join(Dir.home, ".#{Config.app(mode)}"))
12
+ Config.load_config(File.join(Dir.pwd, ".#{Config.app(mode)}"))
13
13
  self.config = Config.configure(mode, argv)
14
14
  self.reporter = Reporter.new(config)
15
15
  end
@@ -7,6 +7,11 @@ module TConsole
7
7
  self.reporter = reporter
8
8
  self.last_result = TConsole::TestResult.new
9
9
  end
10
+
11
+ # Internal: Outputs a message that a feature hasn't been implemented
12
+ def not_implemented
13
+ reporter.error("This feature hasn't been implemented yet.")
14
+ end
10
15
 
11
16
  # Processes the message sent from the console
12
17
  def handle(message)
@@ -92,122 +97,23 @@ module TConsole
92
97
  end
93
98
  end
94
99
 
95
- # Loads the files that match globs and then executes tests against them. Limit tests
96
- # with class names, method names, and test ids using match_patterns.
97
- def run_tests(globs, match_patterns, message = "Running tests...")
98
- time = Benchmark.realtime do
99
- reporter.info(message)
100
- reporter.info
101
-
102
- paths = []
103
- globs.each do |glob|
104
- paths.concat(Dir.glob(glob))
105
- end
106
-
107
- if paths.length == 0
108
- reporter.warn("No test files match your requested test set: #{globs.join(",")}.")
109
- reporter.warn("Skipping execution.")
110
- return nil
111
- end
112
-
113
- self.last_result = run_in_fork do
114
-
115
- paths.each do |path|
116
- reporter.trace("Requested path `#{path}` doesn't exist.") unless File.exist?(path)
117
- require File.expand_path(path)
118
- end
119
-
120
- reporter.trace("Running before_test_run callback")
121
- config.before_test_run!
122
- reporter.trace("Completed before_test_run callback")
123
-
124
- result = nil
125
- if defined?(::MiniTest)
126
- reporter.trace("Detected minitest.")
127
- require File.join(File.dirname(__FILE__), "minitest_handler")
128
-
129
- reporter.trace("Running tests.")
130
- runner = MiniTestHandler.setup(match_patterns, config)
131
-
132
- # Handle trapping interrupts
133
- trap("SIGINT") do
134
- reporter.warn
135
- reporter.warn("Trapped interrupt. Halting tests.")
136
-
137
- runner.interrupted = true
138
- end
139
-
140
- runner.run
141
-
142
- result = runner.results
143
-
144
- # Make sure minitest doesn't run automatically
145
- MiniTestHandler.patch_minitest
146
-
147
- reporter.trace("Finished running tests.")
148
-
149
- if runner.interrupted
150
- reporter.error("Test run was interrupted.")
151
- end
152
-
153
- elsif defined?(::Test::Unit)
154
- reporter.error("Sorry, but tconsole doesn't support Test::Unit yet")
155
- elsif defined?(::RSpec)
156
- reporter.error("Sorry, but tconsole doesn't support RSpec yet")
157
- end
158
-
159
- result
160
- end
161
-
162
- if self.last_result == nil
163
- # Just in case anything crazy goes down with marshalling
164
- self.last_result = TConsole::TestResult.new
165
- end
166
-
167
- config.cache_test_ids(self.last_result)
168
-
169
- true
170
- end
171
-
172
- reporter.info
173
- reporter.info("Tests ran in #{"%0.6f" % time}s. Finished at #{Time.now.strftime('%Y-%m-%d %l:%M:%S %p')}.")
174
- reporter.info
175
- end
176
-
177
100
  # Preloads our autocomplete cache
178
101
  def preload_test_ids
179
- result = run_in_fork do
180
- paths = []
181
- config.file_sets["all"].each do |glob|
182
- paths.concat(Dir.glob(glob))
183
- end
184
-
185
- paths.each { |path| require File.expand_path(path) }
186
-
187
- require File.join(File.dirname(__FILE__), "minitest_handler")
188
- MiniTestHandler.preload_elements
189
- end
190
-
191
- config.cache_test_ids(result) unless result.nil?
102
+ # Does nothing by default
192
103
  end
193
104
 
194
105
  # Runs all tests against the match patterns given
195
106
  def run_all_tests(match_patterns = nil)
196
- run_tests(config.file_sets["all"], match_patterns)
107
+ reporter.error("This feature hasn't been implemented yet.")
197
108
  end
198
109
 
199
110
  # Runs a file set out of the config
200
111
  def run_file_set(set)
201
- run_tests(config.file_sets[set], nil)
112
+ reporter.error("This feature hasn't been implemented yet.")
202
113
  end
203
114
 
204
115
  def run_failed
205
- if last_result.failures.empty?
206
- reporter.info("No tests failed in your last run, or you haven't run any tests in this session yet.")
207
- reporter.info
208
- else
209
- run_tests(config.file_sets["all"], last_result.failures)
210
- end
116
+ reporter.error("This feature hasn't been implemented yet.")
211
117
  end
212
118
 
213
119
  def run_info
@@ -1,3 +1,3 @@
1
1
  module TConsole
2
- VERSION = "1.3.0.pre1"
2
+ VERSION = "1.3.0.pre2"
3
3
  end
data/spec/config_spec.rb CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe TConsole::Config do
4
4
  context "a Config without arguments" do
5
5
  before do
6
- @config = TConsole::Config.new([])
6
+ @config = TConsole::Config.new(:minitest, [])
7
7
  @config.test_dir = "./spec/fixtures/minitest"
8
8
  end
9
9
 
@@ -30,7 +30,7 @@ describe TConsole::Config do
30
30
 
31
31
  context "a Config with the trace argument" do
32
32
  before do
33
- @config = TConsole::Config.new(Shellwords.shellwords("--trace"))
33
+ @config = TConsole::Config.new(:minitest, Shellwords.shellwords("--trace"))
34
34
  end
35
35
 
36
36
  it "has tracing enabled" do
@@ -40,7 +40,7 @@ describe TConsole::Config do
40
40
 
41
41
  context "a Config with the once argument" do
42
42
  before do
43
- @config = TConsole::Config.new(Shellwords.shellwords("--once all"))
43
+ @config = TConsole::Config.new(:minitest, Shellwords.shellwords("--once all"))
44
44
  end
45
45
 
46
46
  it "has run once enabled" do
@@ -50,7 +50,7 @@ describe TConsole::Config do
50
50
 
51
51
  context "a Config with remaining arguments" do
52
52
  before do
53
- @config = TConsole::Config.new(Shellwords.shellwords("--trace set fast on"))
53
+ @config = TConsole::Config.new(:minitest, Shellwords.shellwords("--trace set fast on"))
54
54
  end
55
55
 
56
56
  it "sets remaining args as first command" do
@@ -79,7 +79,7 @@ describe TConsole::Config do
79
79
  config.test_dir = "./awesomer_sauce"
80
80
  end
81
81
 
82
- config = TConsole::Config.configure
82
+ config = TConsole::Config.configure(:minitest)
83
83
  expect(config.test_dir).to eq("./awesomer_sauce")
84
84
  end
85
85
  end
data/spec/runner_spec.rb CHANGED
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe TConsole::Runner do
4
4
  before do
5
- @runner = TConsole::Runner.new
5
+ @runner = TConsole::Runner.new(:minitest)
6
6
  @ps = ChattyProc::PipeServer.new
7
7
  end
8
8
 
@@ -24,7 +24,7 @@ describe TConsole::Runner do
24
24
 
25
25
  describe "#console_run_loop" do
26
26
  before do
27
- @config = TConsole::Config.new
27
+ @config = TConsole::Config.new(:minitest)
28
28
  @reporter = TConsole::Reporter.new(@config)
29
29
  @console = TConsole::Console.new(@config, @reporter)
30
30
  end
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.3.0.pre1
4
+ version: 1.3.0.pre2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors: