| Path: | merb-core/lib/merb-core/test/run_specs.rb |
| Last Update: | Tue Jul 28 08:32:52 +0200 2009 |
Runs specs in all files matching the file pattern.
| globs<String, Array[String]>: | File patterns to look for. |
| spec_cmd<~to_s>: | The spec command. Defaults to "spec". |
| run_opts<String>: | Options to pass to spec commands, for instance, if you want to use profiling formatter. |
| except<Array[String]>: | File paths to skip. |
# File merb-core/lib/merb-core/test/run_specs.rb, line 93
93: def run_specs(globs, spec_cmd='spec', run_opts = "-c", except = [])
94: require "optparse"
95: require "spec"
96: globs = globs.is_a?(Array) ? globs : [globs]
97:
98: forking = (ENV["FORK"] ? ENV["FORK"] == "1" : Merb.forking_environment?)
99: base_dir = File.expand_path(File.dirname(__FILE__) / ".." / ".." / "..")
100:
101: counter = Merb::Counter.new
102: forks = 0
103: failure = false
104:
105: FileUtils.rm_rf(base_dir / "results")
106: FileUtils.mkdir_p(base_dir / "results")
107:
108: time = Benchmark.measure do
109: files = {}
110: globs.each do |glob|
111: Dir[glob].each do |spec|
112: if forking
113: Kernel.fork do
114: run_spec(spec, base_dir)
115: end
116: Process.wait
117: else
118: `NOW=1 #{Gem.ruby} #{File.dirname(__FILE__) / "run_spec.rb"} \"#{spec}\"`
119: end
120: out = File.read(base_dir / "results" / "#{File.basename(spec)}_out")
121: err = File.read(base_dir / "results" / "#{File.basename(spec)}_err")
122: counter.add(spec, out, err)
123: end
124: end
125: end
126:
127: Process.waitall
128:
129: counter.time = time
130: counter.report
131: FileUtils.rm_rf(base_dir / "results")
132: exit!(counter.failed? ? -1 : 0)
133: end