Geminstaller C0 Coverage Information - RCov

spec/helper/embedded_gem_server.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
spec/helper/embedded_gem_server.rb 59 53
74.58%
71.70%

Key

Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.

Coverage Details

1 module GemInstaller
2   class EmbeddedGemServer
3     include GemInstaller::SpecUtils
4     @@gem_server_pid = nil
5     def self.start
6       return if @@gem_server_pid
7       print "Starting embedded gem server at #{embedded_gem_dir}...\n"
8       Gem.clear_paths
9       cmd_args = "--dir=#{embedded_gem_dir} --port=#{embedded_gem_server_port}"
10       if windows?
11         server_cmd = (GemInstaller::RubyGemsVersionChecker.matches?('<= 0.9.4') ? 'gem_server.bat' : "#{gem_cmd} server")
12         gem_server_process = IO.popen("#{server_cmd} #{cmd_args}")
13         @@gem_server_pid = gem_server_process.pid
14       else
15         server_cmd = (GemInstaller::RubyGemsVersionChecker.matches?('<= 0.9.4') ? "#{ruby_cmd} #{rubygems_bin_dir}/gem_server" : "#{gem_cmd} server")
16         # Don't daemonize, it spawns a child process that I don't know how to kill.  There's an error
17         # in the 0.9.5 daemon option anyway.  Just dump everything to /dev/null (but not while I'm still fixing against rubygems 1.0.0)
18         gem_server_process = IO.popen("#{server_cmd} #{cmd_args}")
19         @@gem_server_pid = gem_server_process.pid
20       end
21       print "Started embedded gem server at #{embedded_gem_dir}, pid = #{@@gem_server_pid}\n"
22       trap("INT") { Process.kill(9,@@gem_server_pid); exit! }
23       # TODO: avoid sleep by detecting when gem_server port comes up
24       sleep 3
25     end
26     
27     def self.embedded_gem_dir
28       File.dirname(__FILE__) + "/../fixture/gems"
29     end
30     
31     def self.stop
32       stopped = false
33       if @@gem_server_pid
34         print "Killing embedded gem server at pid = #{@@gem_server_pid}\n"
35         kill_result = Process.kill(8,@@gem_server_pid)
36         if windows?
37           kill_result.each do |pid|
38             print "  Killed pid: #{pid}\n"
39           end
40           print "NOTE: On windows, there is an orphaned gem_server ruby
41       process left, which was a grandchild of the top-level ruby
42       process which runs the tests, and a child of the cmd process
43       which runs gem_server.bat.  Apparently, there's no way to kill
44       this, other than using the ruby-services package, which I haven't
45       done yet:
46       http://rubyforge.org/tracker/index.php?func=detail&aid=8957&group_id=85&atid=412
47       \n"
48         end
49         stopped = true
50         @@gem_server_pid = nil
51       end
52       return stopped
53     end
54     
55     def self.windows?
56       RUBY_PLATFORM =~ /mswin/
57     end
58   end
59 end

Generated on Mon May 10 23:40:29 -0700 2010 with rcov 0.9.8