forking_test_runner 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b60ad12f5e9ca46633a91e12106f4fd6e00bb161
4
- data.tar.gz: 453d510148cd579c234ed2d136f59fe6dbab7770
3
+ metadata.gz: 3f4949bda4bf2340ecc2bdbc26e27dcf7997a4e0
4
+ data.tar.gz: 8d7c6cbd163dd04cf57f5af38f7edeef622a7d00
5
5
  SHA512:
6
- metadata.gz: d4c72f64b34403c193e2fca528ef30e9f7de3afd4a2176148649ba033fe6e76ba49c87a4800f7b99af1459409b925147c086e1d7c6e576d83b16b95ef35a1f23
7
- data.tar.gz: b7fe40d180eabde2317abbf720e0f944e5b4fa94792c11c76225c6d89c328d2768a24c6db0b35c7f761d69bb8ff30dbaa4d2b422106de7318ac92a7e36e98b38
6
+ metadata.gz: bb20aee7735368aae9210789f9248cd70044018d6234242600c17b4bc84553eb680fbd8eda38791acd0ef3b0d516feae66d72dbe83ac1944a34a5f50461a345f
7
+ data.tar.gz: 8192705be39e309668fc7fb7c54330b824698b423e9729c271ce8f4698077e46d1ac37ac689070abe2732be023fe2c672ca68cc4d156f7b5318f4ac614aa2c65
@@ -1,3 +1,3 @@
1
1
  module ForkingTestRunner
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -1,9 +1,13 @@
1
+ require 'benchmark'
2
+
1
3
  module ForkingTestRunner
2
4
  CLEAR = "------"
3
5
 
4
6
  class << self
5
7
  def cli(argv)
6
- disable_minitest_autorun
8
+ @rspec = delete_argv("--rspec", argv, arg: false)
9
+
10
+ disable_test_autorun
7
11
  load_test_env(delete_argv("--helper", argv))
8
12
 
9
13
  # figure out what we need to run
@@ -98,7 +102,8 @@ module ForkingTestRunner
98
102
  end
99
103
 
100
104
  def load_test_env(helper=nil)
101
- helper = helper || "test/test_helper"
105
+ require 'rspec' if @rspec
106
+ helper = helper || (@rspec ? "spec/spec_helper" : "test/test_helper")
102
107
  require "./#{helper}"
103
108
  end
104
109
 
@@ -126,12 +131,12 @@ module ForkingTestRunner
126
131
  end
127
132
 
128
133
  # don't let minitest setup another exit hook
129
- def disable_minitest_autorun
130
- toggle_minitest_autorun false
134
+ def disable_test_autorun
135
+ toggle_test_autorun false
131
136
  end
132
137
 
133
- def enable_minitest_autorun
134
- toggle_minitest_autorun true
138
+ def enable_test_autorun(file)
139
+ toggle_test_autorun true, file
135
140
  end
136
141
 
137
142
  def run_test(file)
@@ -141,8 +146,7 @@ module ForkingTestRunner
141
146
  child = fork do
142
147
  key = (ActiveRecord::VERSION::STRING >= "4.1.0" ? :test : "test")
143
148
  ActiveRecord::Base.establish_connection key
144
- enable_minitest_autorun
145
- require "./#{file}"
149
+ enable_test_autorun(file)
146
150
  end
147
151
  Process.wait(child)
148
152
  end
@@ -174,23 +178,47 @@ module ForkingTestRunner
174
178
  group.map { |test| [test, (tests[test] if group_by == :runtime)] }
175
179
  end
176
180
 
177
- def delete_argv(name, argv)
181
+ def delete_argv(name, argv, arg: true)
178
182
  return unless index = argv.index(name)
179
183
  argv.delete_at(index)
180
- argv.delete_at(index) || raise("Missing argument for #{name}")
184
+ if arg
185
+ argv.delete_at(index) || raise("Missing argument for #{name}")
186
+ else
187
+ true
188
+ end
181
189
  end
182
190
 
183
- def toggle_minitest_autorun(value)
184
- gem 'minitest'
185
- klass = if Gem.loaded_specs["minitest"].version.segments.first == 4 # 4.x
186
- require 'minitest/unit'
187
- MiniTest::Unit
191
+ def toggle_test_autorun(value, file=nil)
192
+ if @rspec
193
+ if value
194
+ RSpec::Core::Runner.run([file])
195
+ else
196
+ require 'bundler/setup'
197
+ require 'rspec'
198
+ RSpec::Core::Runner.disable_autorun! # disable autorun in case the user left it in spec_helper.rb
199
+ $LOAD_PATH.unshift "./lib"
200
+ $LOAD_PATH.unshift "./spec"
201
+ end
188
202
  else
189
- require 'minitest'
190
- Minitest
203
+ @minitest_class ||= begin
204
+ require 'bundler/setup'
205
+ gem 'minitest'
206
+ if Gem.loaded_specs["minitest"].version.segments.first == 4 # 4.x
207
+ require 'minitest/unit'
208
+ MiniTest::Unit
209
+ else
210
+ require 'minitest'
211
+ Minitest
212
+ end
213
+ end
214
+
215
+ @minitest_class.class_variable_set("@@installed_at_exit", !value)
216
+
217
+ if value
218
+ @minitest_class.autorun
219
+ require "./#{file}"
220
+ end
191
221
  end
192
- klass.class_variable_set("@@installed_at_exit", !value)
193
- klass.autorun if value
194
222
  end
195
223
  end
196
224
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forking_test_runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-23 00:00:00.000000000 Z
11
+ date: 2015-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parallel_tests