GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
Report total spec suite run time.
Sat Apr 19 10:21:47 -0700 2008
commit  124f9dc07c6ce29df74e0d688f9d8794e644f819
tree    1c067de50d5e8f1762e9275e7a061d5586f896b6
parent  e4cb876d4c7d742bb0d4af89c8e811559902accd
...
1
 
2
3
4
...
6
7
8
9
 
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
 
 
 
 
 
 
 
 
 
 
 
24
 
 
25
26
27
28
29
30
 
31
32
33
...
36
37
38
 
 
39
40
...
1
2
3
4
5
...
7
8
9
 
10
11
12
13
14
15
 
 
 
 
 
 
 
 
 
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
 
32
33
34
35
36
37
38
...
41
42
43
44
45
46
47
0
@@ -1,4 +1,5 @@
0
 require 'open3'
0
+require 'benchmark'
0
 
0
 # Runs specs in all files matching the file pattern.
0
 #
0
@@ -6,28 +7,32 @@ require 'open3'
0
 # globs<String, Array[String]>:: File patterns to look for.
0
 # spec_cmd<~to_s>:: The spec command. Defaults to "spec".
0
 # run_opts<String>:: Options to pass to spec commands, for instance,
0
-# if you want to use profiling formatter.
0
+# if you want to use profiling formatter.
0
 def run_specs(globs, spec_cmd='spec', run_opts = "-c -f s")
0
   require "optparse"
0
   require "spec"
0
   globs = globs.is_a?(Array) ? globs : [globs]
0
   examples, failures, errors, pending = 0, 0, 0, 0
0
- globs.each do |glob|
0
- Dir[glob].each do |spec|
0
- response = Open3.popen3("#{spec_cmd} #{File.expand_path(spec)} #{run_opts}") 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
+
0
+ time = Benchmark.measure do
0
+ globs.each do |glob|
0
+ Dir[glob].each do |spec|
0
+ response = Open3.popen3("#{spec_cmd} #{File.expand_path(spec)} #{run_opts}") 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
- errors += 1 if e.is_a?(IO)
0
- STDOUT.puts e.read if e.is_a?(IO)
0
       end
0
     end
0
   end
0
+
0
   puts
0
   puts "*** TOTALS ***"
0
   if failures == 0
0
@@ -36,5 +41,7 @@ def run_specs(globs, spec_cmd='spec', run_opts = "-c -f s")
0
     print "\e[31m"
0
   end
0
   puts "#{examples} examples, #{failures} failures, #{errors} errors, #{pending} pending"
0
+
0
+ puts "suite run in #{time.real} seconds"
0
   print "\e[0m"
0
 end

Comments

    No one has commented yet.