Top Level Namespace
Defined Under Namespace
Modules: DateAndTimeFormatting, Enumerable, Erubis, GetArgs, Haml, Kernel, Merb, MerbExceptions, Ordinalize, OrdinalizedFormatting, RSpec, Spec, Templater, TimeDSL Classes: Class, Date, Exception, Hash, MailFactory, MemCache, Memcached, Method, Numeric, Object, ParseTreeArray, String, Time, UnboundMethod
Instance Method Summary (collapse)
- - (Object) run_spec(spec, base_dir, run_opts = "-fs")
-
- (Object) run_specs(globs, spec_cmd = 'spec', run_opts = "-c", except = [])
Runs specs in all files matching the file pattern.
Instance Method Details
- (Object) run_spec(spec, base_dir, run_opts = "-fs")
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'merb-core/lib/merb-core/test/run_spec.rb', line 22 def run_spec(spec, base_dir, run_opts = "-fs") $VERBOSE = nil err, out = StringIO.new, StringIO.new def out.tty?() true end = Spec::Runner::OptionParser.parse(%W(#{spec} --color).concat(%W(#{run_opts})), err, out) .filename_pattern = File.(spec) failure = ! Spec::Runner::CommandLine.run() File.open(base_dir / "results" / "#{File.basename(spec)}_out", "w") do |file| file.puts out.string end File.open(base_dir / "results" / "#{File.basename(spec)}_err", "w") do |file| file.puts err.string end exit!(failure ? -1 : 0) end |
- (Object) run_specs(globs, spec_cmd = 'spec', run_opts = "-c", except = [])
Runs specs in all files matching the file pattern.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'merb-core/lib/merb-core/test/run_specs.rb', line 86 def run_specs(globs, spec_cmd='spec', run_opts = "-c", except = []) require "optparse" require "spec" globs = globs.is_a?(Array) ? globs : [globs] forking = (ENV["FORK"] ? ENV["FORK"] == "1" : Merb.forking_environment?) base_dir = File.(File.dirname(__FILE__) / ".." / ".." / "..") counter = Merb::Counter.new forks = 0 failure = false FileUtils.rm_rf(base_dir / "results") FileUtils.mkdir_p(base_dir / "results") time = Benchmark.measure do files = {} globs.each do |glob| Dir[glob].each do |spec| if forking Kernel.fork do run_spec(spec, base_dir, run_opts) end Process.wait else `NOW=1 #{Gem.ruby} #{File.dirname(__FILE__) / "run_spec.rb"} \"#{spec}\"` end begin out = File.read(base_dir / "results" / "#{File.basename(spec)}_out") err = File.read(base_dir / "results" / "#{File.basename(spec)}_err") counter.add(spec, out, err) rescue Errno::ENOENT => e STDOUT.puts e. end end end end Process.waitall counter.time = time counter.report FileUtils.rm_rf(base_dir / "results") exit!(counter.failed? ? -1 : 0) end |