ZenTest 3.11.1 → 4.0.0

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/.autotest ADDED
@@ -0,0 +1,17 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'autotest/restart'
4
+
5
+ Autotest.add_hook :initialize do |at|
6
+ at.order = :random
7
+ at.add_exception 'coverage'
8
+ at.add_exception 'coverage.info'
9
+
10
+ at.libs << ':../../minitest/dev/lib'
11
+ at.testlib = "minitest/autorun"
12
+ end
13
+
14
+ Autotest.add_hook :all_good do |at|
15
+ system "rake rcov_info"
16
+ end if ENV['RCOV']
17
+
data/History.txt CHANGED
@@ -1,5 +1,38 @@
1
+ === 4.0.0 / 2009-03-02
2
+
3
+ * 2 minor enhancements:
4
+
5
+ * Deleted autotest/screen - releasing as a separate gem soon.
6
+ * Deleted test-rails and rails_test_audit.
7
+
8
+ * 8 minor enhancements:
9
+
10
+ * Added "tags" command to multiruby_setup.
11
+ * Added "the_usual" as a recipe for multiruby_setup. Motivated by Dr. Nic.
12
+ * Added :died hook to Autotest (yoshuki).
13
+ * Added focus.rb, helping you ignore extra tests while you focus on something.
14
+ * Added multigem command line tool!
15
+ * Cleaned up multiruby to make it easier to tweak.
16
+ * Parameterized testlib so you can override test/unit in autotest. Thanks JB!
17
+ * Switched tests and rakefile to minitest. 20% faster!
18
+
19
+ * 7 bug fixes:
20
+
21
+ * Fix Autotest::Screen to distinguish between errors and failures. (khalsah)
22
+ * Fixed some hook commands from overriding others.
23
+ * Hopefully fixed growl support on 10.5.x?
24
+ * Supposedly adding -w to growlnotify will fix autotest/growl.
25
+ * Updated missing entries in Autotest::ALL_HOOKS.
26
+ * Updated rubygems download location. (carletti)
27
+ * Still not automated :(
28
+ * ruby 1.9.1 fixes.
29
+
1
30
  === 3.11.1 / 2009-01-20
2
31
 
32
+ * 1 minor enhancement:
33
+
34
+ * Parameterized test_lib so you can override test/unit. Thanks JB!
35
+
3
36
  * 1 bug fix:
4
37
 
5
38
  * Fixed growl autotest plugin hooks to not return true, preempting other plugins.
data/Manifest.txt CHANGED
@@ -1,3 +1,4 @@
1
+ .autotest
1
2
  History.txt
2
3
  Manifest.txt
3
4
  README.txt
@@ -6,9 +7,9 @@ articles/Article.css
6
7
  articles/getting_started_with_autotest.html
7
8
  articles/how_to_use_zentest.txt
8
9
  bin/autotest
10
+ bin/multigem
9
11
  bin/multiruby
10
12
  bin/multiruby_setup
11
- bin/rails_test_audit
12
13
  bin/unit_diff
13
14
  bin/zentest
14
15
  example.txt
@@ -37,33 +38,17 @@ lib/autotest/rails.rb
37
38
  lib/autotest/rcov.rb
38
39
  lib/autotest/redgreen.rb
39
40
  lib/autotest/restart.rb
40
- lib/autotest/screen.rb
41
41
  lib/autotest/shame.rb
42
42
  lib/autotest/snarl.rb
43
43
  lib/autotest/timestamp.rb
44
+ lib/focus.rb
44
45
  lib/functional_test_matrix.rb
45
46
  lib/multiruby.rb
46
- lib/test/rails.rb
47
- lib/test/rails/controller_test_case.rb
48
- lib/test/rails/functional_test_case.rb
49
- lib/test/rails/helper_test_case.rb
50
- lib/test/rails/ivar_proxy.rb
51
- lib/test/rails/pp_html_document.rb
52
- lib/test/rails/rake_tasks.rb
53
- lib/test/rails/render_tree.rb
54
- lib/test/rails/test_case.rb
55
- lib/test/rails/view_test_case.rb
56
- lib/test/zentest_assertions.rb
57
47
  lib/unit_diff.rb
58
48
  lib/zentest.rb
59
49
  lib/zentest_mapping.rb
60
50
  test/test_autotest.rb
61
- test/test_help.rb
62
- test/test_rails_autotest.rb
63
- test/test_rails_controller_test_case.rb
64
- test/test_rails_helper_test_case.rb
65
- test/test_rails_view_test_case.rb
51
+ test/test_focus.rb
66
52
  test/test_unit_diff.rb
67
53
  test/test_zentest.rb
68
- test/test_zentest_assertions.rb
69
54
  test/test_zentest_mapping.rb
data/Rakefile CHANGED
@@ -4,11 +4,16 @@ $: << 'lib'
4
4
 
5
5
  require 'rubygems'
6
6
  require 'hoe'
7
+
8
+ Hoe.add_include_dirs("../../minitest/dev/lib")
9
+
7
10
  require './lib/zentest.rb'
8
11
 
9
12
  Hoe.new("ZenTest", ZenTest::VERSION) do |zentest|
10
13
  zentest.developer('Ryan Davis', 'ryand-ruby@zenspider.com')
11
14
  zentest.developer('Eric Hodel', 'drbrain@segment7.net')
15
+
16
+ zentest.testlib = :minitest
12
17
  end
13
18
 
14
19
  task :autotest do
data/bin/multigem ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby -w
2
+
3
+ exec "multiruby", "-S", "gem", *ARGV
4
+
data/bin/multiruby_setup CHANGED
@@ -9,60 +9,63 @@ Multiruby.setup_dirs(false)
9
9
 
10
10
  ARGV.each do |spec|
11
11
  case spec
12
- when "-h", "help" then
12
+ when "-h", "--help", "help" then
13
13
  Multiruby.help
14
14
  exit 0
15
+ when "the_usual" then # TODO: update #help
16
+ ARGV.push(*Multiruby::TAGS.map { |v| "mri:tar:#{v.gsub(/_/, '.')}" })
17
+ ARGV << "build" << "update:rubygems"
18
+ system "multigem install --no-ri --no-rdoc rake minitest ZenTest"
19
+ when "build" then
20
+ Multiruby.build_and_install
21
+ when "clean" then
22
+ Multiruby.clean
15
23
  when "list" then
16
24
  Multiruby.list
17
- exit 0
18
- when "build" then
19
- # do nothing
20
25
  when /rm:(.*)/ then
21
26
  Multiruby.rm $1
22
- when "clean" then
23
- Multiruby.clean
24
- exit 0
25
- when "update" then
26
- Multiruby.update
27
- when "update:rubygems" then
28
- Multiruby.update_rubygems
29
27
  when "rubygems:merge" then
30
28
  Multiruby.merge_rubygems
29
+ when "rubygems:update", "update:rubygems" then
30
+ Multiruby.update_rubygems
31
+ when "update" then
32
+ Multiruby.update
33
+ when "tags" then
34
+ p Multiruby.tags
31
35
  when "mri:svn:current" then
32
- ARGV << "mri:svn:releases" << "mri:svn:branches"
36
+ ARGV << "mri:svn:releases" << "mri:svn:branches" << "build"
33
37
  when "mri:svn:releases" then
34
38
  Multiruby::TAGS.each do |v|
35
39
  latest = Multiruby.mri_latest_tag v
36
40
  abort "Can't find tag #{v}" unless latest
37
41
  ARGV << "mri:svn:tag:#{latest}:mri_rel_#{v}"
38
42
  end
43
+ ARGV << "build"
44
+ when /mri:svn:branch:(.*)/ then
45
+ ver = "branches/ruby_#{$1}" unless ver == "trunk"
46
+ Multiruby.svn_co "#{Multiruby::MRI_SVN}/#{$1}", "mri_#{$1}"
47
+ ARGV << "build"
39
48
  when "mri:svn:branches" then
40
49
  Multiruby::BRANCHES.each do |v|
41
50
  ARGV << "mri:svn:branch:#{v}"
42
51
  end
43
- when /mri:svn:branch:(.*)/ then
44
- dir = ver = $1
45
- ver = "branches/ruby_#{ver}" unless ver == "trunk"
46
-
47
- Multiruby.svn_co "#{Multiruby::MRI_SVN}/#{ver}", "mri_#{dir}"
52
+ ARGV << "build"
48
53
  when /mri:svn:tag:(.*):(.*)/ then
49
- ver, dir = $1, $2
50
-
51
- Multiruby.svn_co "#{Multiruby::MRI_SVN}/tags/#{ver}", dir
54
+ Multiruby.svn_co "#{Multiruby::MRI_SVN}/tags/#{$1}", $2
55
+ ARGV << "build"
52
56
  when /mri:svn:tag:(.*)/ then
53
- ver = $1
54
-
55
- ARGV << "mri:svn:tag:#{ver}:#{ver}"
57
+ ARGV << "mri:svn:tag:#{$1}:#{$1}" << "build"
56
58
  when /mri:tar:(.*)/ then
57
- v = $1
58
- Multiruby.fetch_tar v
59
- when /rbx:ln:(.*)/ then
60
- Multiruby.rbx_ln $1
59
+ Multiruby.fetch_tar $1
60
+ ARGV << "build"
61
61
  when /rbx:git:current/ then
62
62
  Multiruby.git_clone "#{Multiruby::RBX_GIT}/code", "rubinius"
63
+ ARGV << "build"
64
+ when /rbx:ln:(.*)/ then
65
+ Multiruby.rbx_ln $1
66
+ ARGV << "build"
63
67
  else
64
68
  warn "unknown spec #{spec}"
65
69
  end
66
70
  end
67
71
 
68
- Multiruby.build_and_install
data/lib/autotest.rb CHANGED
@@ -28,8 +28,7 @@ $TESTING = false unless defined? $TESTING
28
28
  #
29
29
  # Autotest.add_hook hook_name { |autotest| ... }
30
30
  #
31
- # The available hooks are: initialize, run, run_command, ran_command,
32
- # red, green, updated, all_good, reset, interrupt, and quit.
31
+ # The available hooks are listed in +ALL_HOOKS+.
33
32
  #
34
33
  # See example_dot_autotest.rb for more details.
35
34
  #
@@ -62,8 +61,8 @@ class Autotest
62
61
 
63
62
  T0 = Time.at 0
64
63
 
65
- ALL_HOOKS = [ :all_good, :initialize, :interrupt, :quit, :ran_command,
66
- :reset, :run_command, :waiting ]
64
+ ALL_HOOKS = [ :all_good, :died, :green, :initialize, :interrupt, :quit,
65
+ :ran_command, :red, :reset, :run_command, :updated, :waiting ]
67
66
 
68
67
  HOOKS = Hash.new { |h,k| h[k] = [] }
69
68
  unless defined? WINDOZE then
@@ -154,6 +153,7 @@ class Autotest
154
153
  :results,
155
154
  :sleep,
156
155
  :tainted,
156
+ :testlib,
157
157
  :find_directories,
158
158
  :unit_diff,
159
159
  :wants_to_quit)
@@ -168,18 +168,19 @@ class Autotest
168
168
  @test_mappings = []
169
169
 
170
170
  self.completed_re = /\d+ tests, \d+ assertions, \d+ failures, \d+ errors/
171
- self.extra_class_map = {}
172
- self.extra_files = []
171
+ self.extra_class_map = {}
172
+ self.extra_files = []
173
173
  self.failed_results_re = /^\s+\d+\) (?:Failure|Error):\n(.*?)\((.*?)\)/
174
- self.files_to_test = new_hash_of_arrays
175
- self.find_order = []
176
- self.known_files = nil
177
- self.libs = %w[. lib test].join(File::PATH_SEPARATOR)
178
- self.order = :random
179
- self.output = $stderr
180
- self.sleep = 1
181
- self.find_directories = ['.']
182
- self.unit_diff = "unit_diff -u"
174
+ self.files_to_test = new_hash_of_arrays
175
+ self.find_order = []
176
+ self.known_files = nil
177
+ self.libs = %w[. lib test].join(File::PATH_SEPARATOR)
178
+ self.order = :random
179
+ self.output = $stderr
180
+ self.sleep = 1
181
+ self.testlib = "test/unit"
182
+ self.find_directories = ['.']
183
+ self.unit_diff = "unit_diff -u"
183
184
 
184
185
  self.add_mapping(/^lib\/.*\.rb$/) do |filename, _|
185
186
  possible = File.basename(filename).gsub '_', '_?'
@@ -221,6 +222,8 @@ class Autotest
221
222
  end
222
223
  end
223
224
  hook :quit
225
+ rescue Exception
226
+ hook :died
224
227
  end
225
228
 
226
229
  ##
@@ -429,8 +432,9 @@ class Autotest
429
432
  full, partial = reorder(files_to_test).partition { |k,v| v.empty? }
430
433
 
431
434
  unless full.empty? then
432
- classes = full.map {|k,v| k}.flatten.uniq.join(' ')
433
- cmds << "#{ruby} -I#{libs} -rtest/unit -e \"%w[#{classes}].each { |f| require f }\" | #{unit_diff}"
435
+ classes = full.map {|k,v| k}.flatten.uniq
436
+ classes.unshift testlib
437
+ cmds << "#{ruby} -I#{libs} -rubygems -e \"%w[#{classes.join(' ')}].each { |f| require f }\" | #{unit_diff}"
434
438
  end
435
439
 
436
440
  partial.each do |klass, methods|
@@ -11,6 +11,7 @@ module Autotest::Emacs
11
11
 
12
12
  def self.emacs_autotest status
13
13
  `#{@@client_cmd} \"(autotest-update '#{status})\"`
14
+ nil
14
15
  end
15
16
 
16
17
  Autotest.add_hook :run_command do |at|
@@ -6,7 +6,7 @@ module Autotest::Growl
6
6
  msg += " at #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}"
7
7
  # TODO: parameterize default image
8
8
  img ||= "/Applications/Mail.app/Contents/Resources/Caution.tiff"
9
- cmd = "growlnotify -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title}"
9
+ cmd = "growlnotify -w -n autotest --image #{img} -p #{pri} -m #{msg.inspect} #{title}"
10
10
  system cmd
11
11
  nil
12
12
  end
data/lib/focus.rb ADDED
@@ -0,0 +1,9 @@
1
+ class Module
2
+ def focus *wanteds
3
+ wanteds.map! { |m| m.to_s }
4
+ unwanteds = public_instance_methods(false).grep(/test_/) - wanteds
5
+ unwanteds.each do |unwanted|
6
+ remove_method unwanted
7
+ end
8
+ end
9
+ end
data/lib/multiruby.rb CHANGED
@@ -8,37 +8,53 @@ require 'open-uri'
8
8
  #
9
9
  # cmds:
10
10
  #
11
- # h, help - show this help.
12
- # list - print installed versions.
13
- # update - update svn builds.
14
- # update:rubygems - update rubygems and nuke install dirs.
15
- # rubygems:merge - symlink all rubygem dirs to one dir.
16
- # rm:$version - remove a particular version.
17
- # clean - clean scm build dirs and remove non-scm build dirs.
11
+ # -h, --help, help = show this help.
12
+ # build = build and install everything. used internally.
13
+ # clean = clean scm build dirs and remove non-scm build dirs.
14
+ # list = print installed versions.
15
+ # rm:$version = remove a particular version.
16
+ # rubygems:merge = symlink all rubygem dirs to one dir.
17
+ # tags = list all tags from svn.
18
+ # update = update svn builds.
19
+ # update:rubygems = update rubygems and nuke install dirs.
18
20
  #
19
21
  # specs:
20
22
  #
21
- # mri:svn:current - alias for mri:svn:releases and mri:svn:branches.
22
- # mri:svn:releases - alias for supported releases of mri ruby.
23
- # mri:svn:branches - alias for active branches of mri ruby.
24
- # mri:svn:branch:$branch - install a specific $branch of mri from svn.
25
- # mri:svn:tag:$tag - install a specific $tag of mri from svn.
26
- # mri:tar:$version - install a specific $version of mri from tarball.
27
- # rbx:ln:$dir - symlink your rbx $dir
28
- # rbx:git:current - install rbx from git
23
+ # the_usual = alias for latest versions from tar + rubygems
24
+ # mri:svn:current = alias for mri:svn:releases and mri:svn:branches.
25
+ # mri:svn:releases = alias for supported releases of mri ruby.
26
+ # mri:svn:branches = alias for active branches of mri ruby.
27
+ # mri:svn:branch:$branch = install a specific $branch of mri from svn.
28
+ # mri:svn:tag:$tag = install a specific $tag of mri from svn.
29
+ # mri:tar:$version = install a specific $version of mri from tarball.
30
+ # rbx:ln:$dir = symlink your rbx $dir
31
+ # rbx:git:current = install rbx from git
32
+ #
33
+ # environment variables:
34
+ #
35
+ # GEM_URL = url for rubygems tarballs
36
+ # MRI_SVN = url for MRI SVN
37
+ # RBX_GIT = url for rubinius git
38
+ # RUBY_URL = url for MRI tarballs
39
+ # VERSIONS = what versions to install
29
40
  #
30
41
  # NOTES:
31
42
  #
32
43
  # * you can add a symlink to your rubinius build into ~/.multiruby/install
33
- # * I'll get to adding support for other implementations soon.
44
+ # * I need patches/maintainers for other implementations.
34
45
  #
35
46
  module Multiruby
36
- MRI_SVN = "http://svn.ruby-lang.org/repos/ruby"
37
- RBX_GIT = "git://git.rubini.us"
47
+ def self.env name, fallback; ENV[name] || fallback; end # :nodoc:
38
48
 
39
- TAGS = %w( 1_8_6 1_8_7 1_9 )
49
+ TAGS = %w( 1_8_6 1_8_7 1_9_1)
40
50
  BRANCHES = %w(1_8 1_8_6 1_8_7 trunk)
41
51
 
52
+ VERSIONS = env('VERSIONS', TAGS.join(":")).split(/:/)
53
+ MRI_SVN = env 'MRI_SVN', 'http://svn.ruby-lang.org/repos/ruby'
54
+ RBX_GIT = env 'RBX_GIT', 'git://git.rubini.us'
55
+ RUBY_URL = env 'RUBY_URL', 'http://ftp.ruby-lang.org/pub/ruby'
56
+ GEM_URL = env 'GEM_URL', 'http://files.rubyforge.vm.bytemark.co.uk/rubygems'
57
+
42
58
  HELP = []
43
59
 
44
60
  File.readlines(__FILE__).each do |line|
@@ -138,7 +154,7 @@ module Multiruby
138
154
  def self.extract_latest_version url, matching=nil
139
155
  file = URI.parse(url).read
140
156
  versions = file.scan(/href="(ruby.*tar.gz)"/).flatten.reject { |s|
141
- s =~ /preview/
157
+ s =~ /preview|-rc\d/
142
158
  }.sort_by { |s|
143
159
  s.split(/\D+/).map { |i| i.to_i }
144
160
  }.flatten
@@ -147,19 +163,18 @@ module Multiruby
147
163
  end
148
164
 
149
165
  def self.fetch_tar v
150
- require 'open-uri'
151
- base_url = "http://ftp.ruby-lang.org/pub/ruby"
152
-
153
166
  in_versions_dir do
154
- warn " Determining latest version for #{v}"
167
+ warn " Determining latest version for #{v}"
155
168
  ver = v[/\d+\.\d+/]
156
- base = extract_latest_version("#{base_url}/#{ver}/", v)
169
+ base = extract_latest_version("#{RUBY_URL}/#{ver}/", v)
157
170
  abort "Could not determine release for #{v}" unless base
158
- url = File.join base_url, ver, base
159
- warn " Fetching #{base} via HTTP... this might take a while."
160
- open(url) do |f|
161
- File.open base, 'w' do |out|
162
- out.write f.read
171
+ url = File.join RUBY_URL, ver, base
172
+ unless File.file? base then
173
+ warn " Fetching #{base} via HTTP... this might take a while."
174
+ open(url) do |f|
175
+ File.open base, 'w' do |out|
176
+ out.write f.read
177
+ end
163
178
  end
164
179
  end
165
180
  end
@@ -179,11 +194,6 @@ module Multiruby
179
194
  run "make install &> log.install"
180
195
  end
181
196
 
182
- def self.rake_build inst_dir
183
- run "rake &> log.build"
184
- FileUtils.ln_sf "../build/#{File.basename Dir.pwd}", inst_dir
185
- end
186
-
187
197
  def self.help
188
198
  puts HELP.join
189
199
  end
@@ -246,6 +256,11 @@ module Multiruby
246
256
  Multiruby.tags.grep(/#{v}/).last
247
257
  end
248
258
 
259
+ def self.rake_build inst_dir
260
+ run "rake &> log.build"
261
+ FileUtils.ln_sf "../build/#{File.basename Dir.pwd}", inst_dir
262
+ end
263
+
249
264
  def self.rbx_ln dir
250
265
  dir = File.expand_path dir
251
266
  Multiruby.in_versions_dir do
@@ -274,19 +289,19 @@ module Multiruby
274
289
  root_dir
275
290
  end
276
291
 
277
- def self.run(cmd)
292
+ def self.run cmd
278
293
  puts "Running command: #{cmd}"
279
294
  raise "ERROR: Command failed with exit code #{$?}" unless system cmd
280
295
  end
281
296
 
282
- def self.setup_dirs(download = true)
297
+ def self.setup_dirs download = true
283
298
  %w(build install versions tmp).each do |dir|
284
299
  unless test ?d, dir then
285
300
  puts "creating #{dir}"
286
301
  Dir.mkdir dir
287
302
  if dir == "versions" && download then
288
303
  warn " Downloading initial ruby tarballs to ~/.multiruby/versions:"
289
- %w(1.8 1.9).each do |v|
304
+ VERSIONS.each do |v|
290
305
  self.fetch_tar v
291
306
  end
292
307
  warn " ...done"
@@ -380,17 +395,20 @@ module Multiruby
380
395
  end
381
396
 
382
397
  def self.update_rubygems
383
- url = "http://files.rubyforge.rubyuser.de/rubygems/"
384
- html = URI.parse(url).read
398
+ warn " Determining latest version for rubygems"
399
+ html = URI.parse(GEM_URL).read
385
400
 
386
- versions = html.scan(/href="rubygems-update-(\d+(?:\.\d+)+).gem/).flatten
401
+ versions = html.scan(/href="rubygems-update-(\d+(?:\.\d+)+).gem/i).flatten
387
402
  latest = versions.sort_by { |s| s.scan(/\d+/).map { |s| s.to_i } }.last
388
403
 
389
404
  Multiruby.in_versions_dir do
390
- File.unlink(*Dir["rubygems*"])
391
405
  file = "rubygems-#{latest}.tgz"
392
- File.open file, 'w' do |f|
393
- f.write URI.parse(url+file).read
406
+ unless File.file? file then
407
+ warn " Fetching rubygems-#{latest}.tgz via HTTP."
408
+ File.unlink(*Dir["rubygems*"])
409
+ File.open file, 'w' do |f|
410
+ f.write URI.parse(GEM_URL+"/"+file).read
411
+ end
394
412
  end
395
413
  end
396
414