Top Level Namespace
Defined Under Namespace
Modules: ColorfulMessages, Erubis, Gem, GemManagement, Kernel, Merb, Spec Classes: Class, Exception, Hash, MemCache, Memcached, Object, String
Instance Method Summary collapse
- #run_spec(spec, base_dir) ⇒ Object
-
#run_specs(globs, spec_cmd = 'spec', run_opts = "-c", except = []) ⇒ Object
Runs specs in all files matching the file pattern.
Instance Method Details
#run_spec(spec, base_dir) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/merb-core/test/run_spec.rb', line 23 def run_spec(spec, base_dir) $VERBOSE = nil err, out = StringIO.new, StringIO.new def out.tty?() true end = Spec::Runner::OptionParser.parse(%W(#{spec} -fs --color), 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 |
#run_specs(globs, spec_cmd = 'spec', run_opts = "-c", except = []) ⇒ Object
Runs specs in all files matching the file pattern.
Parameters
- globs<String, Array>
-
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>
-
File paths to skip.
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 131 132 133 |
# File 'lib/merb-core/test/run_specs.rb', line 93 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) end Process.wait else `NOW=1 #{Gem.ruby} #{File.dirname(__FILE__) / "run_spec.rb"} \"#{spec}\"` end 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) end end end Process.waitall counter.time = time counter.report FileUtils.rm_rf(base_dir / "results") exit!(counter.failed? ? -1 : 0) end |