public
Fork of wycats/merb-core
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/myobie/merb-core.git
Search Repo:
get autotest working for merb-core

Extracted run_specs from Rakefile into lib/merb-core/test/run_specs.rb,
and call that from bin/merb-specs

Specs now run individually, as designed.

autotest still chokes up and runs the failing specs 8 or 9 times in rapid
succession, but that's a bug we can live with for the time being.
ivey (author)
Fri Feb 29 08:57:47 -0800 2008
commit  0b7f94a35d25057b7cccd593cea3abaae3efa72a
tree    e95572c74de4199533828dc3509fa7e6f0ef1c8a
parent  ff6e1a92e276b04529e7cea4ceb97c5ced4246aa
...
18
19
20
 
21
22
23
...
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
...
18
19
20
21
22
23
24
...
127
128
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
131
132
0
@@ -18,6 +18,7 @@ include FileUtils
0
 NAME = "merb-core"
0
 
0
 require "lib/merb-core/version"
0
+require "lib/merb-core/test/run_specs"
0
 
0
 ##############################################################################
0
 # Packaging & Installation
0
@@ -126,37 +127,6 @@ task :aok => [:specs, :rcov]
0
 # t.spec_files = Dir["spec/**/*_spec.rb"].sort
0
 # end
0
 
0
-require 'open3'
0
-
0
-def run_specs(glob, spec_cmd='spec')
0
- require "optparse"
0
- require "spec"
0
- examples, failures, errors, pending = 0, 0, 0, 0
0
- Dir[glob].each do |spec|
0
- response = Open3.popen3("#{spec_cmd} #{File.expand_path(spec)} -f s -c") do |i,o,e|
0
- while out = o.gets
0
- STDOUT.puts out
0
- STDOUT.flush
0
- if out =~ /\d+ example/
0
- e, f, p = out.match(/(\d+) examples?, (\d+) failures?(?:, (\d+) pending?)?/)[1..-1]
0
- examples += e.to_i; failures += f.to_i; pending += p.to_i
0
- end
0
- end
0
- errors += 1 if e.is_a?(IO)
0
- STDOUT.puts e.read if e.is_a?(IO)
0
- end
0
- end
0
- puts
0
- puts "*** TOTALS ***"
0
- if failures == 0
0
- print "\e[32m"
0
- else
0
- print "\e[31m"
0
- end
0
- puts "#{examples} examples, #{failures} failures, #{errors} errors, #{pending} pending"
0
- print "\e[0m"
0
-end
0
-
0
 def setup_specs(name, spec_cmd='spec')
0
   desc "Run all specs (#{name})"
0
   task "specs:#{name}" do
...
22
23
24
25
26
27
28
 
 
 
29
30
31
 
 
32
33
34
 
 
 
35
36
37
 
 
38
39
40
 
 
41
42
43
 
 
44
45
46
 
 
47
48
49
...
57
58
59
60
61
62
63
64
65
66
67
68
...
83
84
85
86
 
87
88
89
...
98
99
100
101
 
102
103
104
...
113
114
115
116
117
118
119
120
 
121
122
123
124
125
126
 
127
128
129
...
22
23
24
 
 
 
 
25
26
27
28
 
 
29
30
31
 
 
32
33
34
35
 
 
36
37
38
 
 
39
40
41
 
 
42
43
44
 
 
45
46
47
48
49
...
57
58
59
 
 
 
 
 
 
60
61
62
...
77
78
79
 
80
81
82
83
...
92
93
94
 
95
96
97
98
...
107
108
109
 
 
 
 
 
110
111
 
 
 
 
 
112
113
114
115
0
@@ -22,28 +22,28 @@ class RspecCommandError < StandardError; end
0
 class Autotest::MerbsourceRspec < Autotest
0
   
0
   Autotest.add_hook :initialize do |at|
0
- %w{.git}.each {|exception| at.exceptions.push exception}
0
- end
0
-
0
- Autotest.add_hook :run do |at|
0
+ at.clear_mappings
0
+ at.add_exception(/\.git/)
0
+
0
     # See above for human-readable descriptions of these rules
0
- # 1 above
0
- at.add_mapping(%r{^spec/.*_spec\.rb$}) { |filename, _| filename}
0
+ # 1 above
0
+ at.add_mapping(%r{^spec/.*_spec\.rb$}) { |filename, _| filename}
0
 
0
- # 2 above
0
- at.add_mapping(%r{^spec/(.*)/spec_helper\.rb$}) { |_, m| at.files_matching %r{^spec/#{m[1]}/.*_spec\.rb$} }
0
+ # 2 above
0
+ at.add_mapping(%r{^spec/spec_helper\.rb$}) { |_, m| at.files_matching %r{^spec/.*_spec\.rb$} }
0
+ at.add_mapping(%r{^spec/(.*)/spec_helper\.rb$}) { |_, m| at.files_matching %r{^spec/#{m[1]}/.*_spec\.rb$} }
0
 
0
- # 3 above
0
- at.add_mapping(%r{^lib/merb-core/controller/([^/]*)\.rb$}) { |_, m| at.files_matching %r{^spec\/(public|private)\/#{m[1]}\/.*_spec\.rb} }
0
+ # 3 above
0
+ at.add_mapping(%r{^lib/merb-core/controller/([^/]*)\.rb$}) { |_, m| at.files_matching %r{^spec/(public|private)/abstract_controller/.*_spec\.rb} }
0
 
0
- # 4 above
0
- at.add_mapping(%r{^lib/merb-core/controller/mixins/([^/]*)\.rb$}) { |_, m| at.files_matching %r{^spec/(public|private)/(abstract_)?controller/#{m[1]}_spec\.rb} }
0
+ # 4 above
0
+ at.add_mapping(%r{^lib/merb-core/controller/mixins/([^/]*)\.rb$}) { |_, m| at.files_matching %r{^spec/(public|private)/(abstract_)?controller/#{m[1]}_spec\.rb} }
0
 
0
- # 5 above
0
- at.add_mapping(%r{^lib/merb-core/([^/]*)\.rb$}) { |_, m| at.files_matching %r{^spec/(public|private)/#{m[1]}/.*_spec\.rb} }
0
+ # 5 above
0
+ at.add_mapping(%r{^lib/merb-core/([^/]*)\.rb$}) { |_, m| at.files_matching %r{^spec/(public|private)/#{m[1]}/.*_spec\.rb} }
0
 
0
- # 6 above
0
- at.add_mapping(%r{^lib/merb\.rb$}) { at.files_matching %r{^spec/[^/]*_spec\.rb$} }
0
+ # 6 above
0
+ at.add_mapping(%r{^lib/merb\.rb$}) { at.files_matching %r{^spec/[^/]*_spec\.rb$} }
0
 
0
   end
0
 
0
@@ -57,12 +57,6 @@ class Autotest::MerbsourceRspec < Autotest
0
   
0
   attr_accessor :failures
0
 
0
- def tests_for_file(filename)
0
- super.select { |f| @files.has_key? f }
0
- end
0
-
0
- alias :specs_for_file :tests_for_file
0
-
0
   def failed_results(results)
0
     results.scan(/^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m)
0
   end
0
@@ -83,7 +77,7 @@ class Autotest::MerbsourceRspec < Autotest
0
   def consolidate_failures(failed)
0
     filters = Hash.new { |h,k| h[k] = [] }
0
     failed.each do |spec, failed_trace|
0
- @files.keys.select { |f| f =~ /spec\// }.each do |f|
0
+ find_files.keys.select { |f| f =~ /spec\// }.each do |f|
0
         if failed_trace =~ Regexp.new(f)
0
           filters[f] << spec
0
           break
0
@@ -98,7 +92,7 @@ class Autotest::MerbsourceRspec < Autotest
0
   end
0
 
0
   def test_cmd_options
0
- '-O specs/spec.opts' if File.exist?('specs/spec.opts')
0
+ # '-O specs/spec.opts' if File.exist?('specs/spec.opts')
0
   end
0
   
0
   # Finds the proper spec command to use. Precendence
0
@@ -113,16 +107,8 @@ class Autotest::MerbsourceRspec < Autotest
0
     end
0
   end
0
   
0
- # Autotest will look for spec commands in the following
0
- # locations, in this order:
0
- #
0
- # * bin/spec
0
- # * default spec bin/loader installed in Rubygems
0
+ # Merb specs must be run 1 at a time, so use our special runner
0
   def spec_commands
0
- if (spec = `which spec`.chomp) && !spec.empty?
0
- return [spec]
0
- end
0
- [File.join('bin', 'spec'),
0
- File.join(Config::CONFIG['bindir'], 'spec')]
0
+ [File.join('bin', 'merb-specs')]
0
   end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.