test-loop 12.2.0 → 12.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/LICENSE +1 -0
  2. data/README.md +4 -0
  3. data/lib/test/loop.rb +18 -10
  4. data/lib/test/loop/rails.rb +6 -0
  5. metadata +26 -33
data/LICENSE CHANGED
@@ -3,6 +3,7 @@
3
3
  Copyright 2010 Suraj N. Kurapati <sunaku@gmail.com>
4
4
  Copyright 2011 Brian D. Burns <burns180@gmail.com>
5
5
  Copyright 2011 Daniel Pittman <daniel@rimspace.net>
6
+ Copyright 2011 Jacob Helwig <jacob@technosorcery.net>
6
7
 
7
8
  Permission to use, copy, modify, and/or distribute this software for any
8
9
  purpose with or without fee is hereby granted, provided that the above
data/README.md CHANGED
@@ -246,6 +246,10 @@ configuration file:
246
246
  end
247
247
  }
248
248
 
249
+ ### Test::Loop.max_concurrent_tests
250
+
251
+ Maximum number of test files to run concurrently. The default value is 4.
252
+
249
253
  ------------------------------------------------------------------------------
250
254
  Configuration presets
251
255
  ------------------------------------------------------------------------------
@@ -1,3 +1,4 @@
1
+ require 'set'
1
2
  require 'ostruct'
2
3
  require 'diff/lcs'
3
4
 
@@ -6,6 +7,8 @@ module Test
6
7
 
7
8
  Loop.delay_per_iteration = 1
8
9
 
10
+ Loop.max_concurrent_tests = 4
11
+
9
12
  Loop.overhead_file_globs = ['{test,spec}/{test,spec}_helper.rb']
10
13
 
11
14
  Loop.reabsorb_file_globs = Loop.overhead_file_globs.dup
@@ -74,7 +77,7 @@ module Test
74
77
  private
75
78
 
76
79
  MASTER_EXECV = [$0, *ARGV].map {|s| s.dup.freeze }.freeze
77
- MASTER_ENV = Hash[ENV.map {|k,v| [k.freeze, v.freeze] }].freeze
80
+ MASTER_ENV = ENV.to_hash.freeze
78
81
  RESUME_ENV_KEY = 'TEST_LOOP_RESUME_FILES'.freeze
79
82
 
80
83
  ANSI_CLEAR_LINE = "\e[2K\e[0G".freeze
@@ -115,10 +118,10 @@ module Test
115
118
 
116
119
  # The given test files are passed down (along with currently running
117
120
  # test files) to the next incarnation of test-loop for resumption.
118
- def reload_master_process test_files = []
119
- test_files.concat currently_running_test_files
121
+ def reload_master_process test_files = Set.new
122
+ test_files.merge currently_running_test_files
120
123
  stop_worker_queue
121
- ENV.replace MASTER_ENV.merge(RESUME_ENV_KEY => test_files.inspect)
124
+ ENV.replace MASTER_ENV.merge(RESUME_ENV_KEY => Marshal.dump(test_files))
122
125
  exec(*MASTER_EXECV)
123
126
  end
124
127
 
@@ -142,21 +145,22 @@ module Test
142
145
 
143
146
  def enter_testing_loop
144
147
  notify 'Ready for testing!'
148
+ test_files = Set.new
145
149
  loop do
146
150
  reap_worker_queue
147
151
 
148
152
  # find test files that have been modified since the last run
149
- test_files = test_file_matchers.map do |source_glob, test_matcher|
153
+ test_files.merge test_file_matchers.map {|source_glob, test_matcher|
150
154
  Dir[source_glob].select {|file| File.mtime(file) > @last_ran_at }.
151
155
  map {|path| Dir[test_matcher.call(path).to_s] }
152
- end.flatten.uniq
156
+ }.flatten
153
157
 
154
158
  # resume test files stopped by the previous incarnation of test-loop
155
159
  if ENV.key? RESUME_ENV_KEY
156
- resume_files = eval(ENV.delete(RESUME_ENV_KEY))
160
+ resume_files = Marshal.load(ENV.delete(RESUME_ENV_KEY))
157
161
  unless resume_files.empty?
158
162
  notify 'Resuming tests...'
159
- test_files.concat(resume_files).uniq!
163
+ test_files.merge resume_files
160
164
  end
161
165
  end
162
166
 
@@ -168,10 +172,14 @@ module Test
168
172
 
169
173
  # fork workers to run the test files in parallel,
170
174
  # excluding test files that are already running
171
- test_files -= currently_running_test_files
175
+ test_files.subtract currently_running_test_files
172
176
  unless test_files.empty?
173
177
  @last_ran_at = Time.now
174
- test_files.each {|file| fork_worker Worker.new(file) }
178
+ num_workers = Loop.max_concurrent_tests - @worker_by_pid.length
179
+ test_files.to_a.first(num_workers).each do |file|
180
+ fork_worker Worker.new(file)
181
+ test_files.delete file
182
+ end
175
183
  end
176
184
 
177
185
  pause_momentarily
@@ -9,6 +9,12 @@ Test::Loop.reabsorb_file_globs.push(
9
9
  Test::Loop.test_file_matchers['{app,lib,test,spec}/**/*.rb'] =
10
10
  Test::Loop.test_file_matchers.delete('lib/**/*.rb')
11
11
 
12
+ Test::Loop.test_file_matchers['{test,spec}/factories/**/*_factory.rb'] =
13
+ lambda do |path|
14
+ base = File.basename(path, '_factory.rb')
15
+ "{test,spec}/**/#{base}_{test,spec}.rb"
16
+ end
17
+
12
18
  require 'rails/railtie'
13
19
  Class.new Rails::Railtie do
14
20
  config.before_initialize do |app|
metadata CHANGED
@@ -1,39 +1,36 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: test-loop
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 12.3.0
4
5
  prerelease:
5
- version: 12.2.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Suraj N. Kurapati
9
9
  - Brian D. Burns
10
10
  - Daniel Pittman
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
-
15
- date: 2011-06-01 00:00:00 Z
16
- dependencies:
17
- - !ruby/object:Gem::Dependency
14
+ date: 2011-07-19 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
18
17
  name: diff-lcs
19
- prerelease: false
20
- requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirement: &8986060 !ruby/object:Gem::Requirement
21
19
  none: false
22
- requirements:
23
- - - ">="
24
- - !ruby/object:Gem::Version
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
25
23
  version: 1.1.2
26
24
  type: :runtime
27
- version_requirements: *id001
25
+ prerelease: false
26
+ version_requirements: *8986060
28
27
  description:
29
28
  email:
30
- executables:
29
+ executables:
31
30
  - test-loop
32
31
  extensions: []
33
-
34
32
  extra_rdoc_files: []
35
-
36
- files:
33
+ files:
37
34
  - LICENSE
38
35
  - README.md
39
36
  - bin/test-loop
@@ -42,30 +39,26 @@ files:
42
39
  - lib/test/loop/rails.rb
43
40
  homepage: http://github.com/sunaku/test-loop
44
41
  licenses: []
45
-
46
42
  post_install_message:
47
43
  rdoc_options: []
48
-
49
- require_paths:
44
+ require_paths:
50
45
  - lib
51
- required_ruby_version: !ruby/object:Gem::Requirement
46
+ required_ruby_version: !ruby/object:Gem::Requirement
52
47
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: "0"
57
- required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
53
  none: false
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: "0"
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
63
58
  requirements: []
64
-
65
59
  rubyforge_project:
66
60
  rubygems_version: 1.8.5
67
61
  signing_key:
68
62
  specification_version: 3
69
63
  summary: Continuous testing for Ruby with fork/eval
70
64
  test_files: []
71
-