summaryrefslogtreecommitdiff
path: root/trunk/sample/coverage.rb
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-25 15:13:14 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-25 15:13:14 +0000
commitd0233291bc8a5068e52c69c210e5979e5324b5bc (patch)
tree7d9459449c33792c63eeb7baa071e76352e0baab /trunk/sample/coverage.rb
parent0dc342de848a642ecce8db697b8fecd83a63e117 (diff)
parent72eaacaa15256ab95c3b52ea386f88586fb9da40 (diff)
re-adding tag v1_9_0_4 as an alias of trunk@18848v1_9_0_4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_0_4@18849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'trunk/sample/coverage.rb')
-rw-r--r--trunk/sample/coverage.rb60
1 files changed, 0 insertions, 60 deletions
diff --git a/trunk/sample/coverage.rb b/trunk/sample/coverage.rb
deleted file mode 100644
index 3f45e9fc98..0000000000
--- a/trunk/sample/coverage.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-require "coverage.so"
-
-Coverage.start
-
-ext = ENV["COVERUBY_EXT"] || ".cov"
-accum = ENV["COVERUBY_ACCUM"]
-accum = !accum || accum == "" || !(%w(f n 0).include?(accum[0]))
-pwd = Dir.pwd
-
-at_exit do
- Dir.chdir(pwd) do
- Coverage.result.each do |sfile, covs|
- cfile = sfile + ext
-
- writable = proc do |f|
- File.writable?(f) || File.writable?(File.dirname(f))
- end
- unless writable[cfile]
- cfile = cfile.gsub(File.PATH_SEPARATOR, "#")
- next unless writable[cfile]
- end
-
- readlines = proc do |f|
- File.read(f).force_encoding("ASCII-8BIT").lines.to_a
- end
-
- sources = (readlines[sfile] rescue [])
-
- pcovs = []
- if accum
- pcovs = (readlines[cfile] rescue []).map.with_index do |line, idx|
- if line[/^\s*(?:(#####)|(\d+)|-):\s*\d+:(.*)$/n]
- cov, line = $1 ? 0 : ($2 ? $2.to_i : nil), $3
- if !sources[idx] || sources[idx].chomp != line.chomp
- warn("source file changed, ignoring: `#{ cfile }'")
- break []
- end
- cov
- else
- p line
- warn("coverage file corrupted, ignoring: #{ cfile }")
- break []
- end
- end
- unless pcovs.empty? || pcovs.size == covs.size
- warn("coverage file changed, ignoring: `#{ cfile }'")
- pcovs = []
- end
- end
-
- open(cfile, "w") do |out|
- covs.zip(sources, pcovs).each_with_index do |(cov, line, pcov), idx|
- cov += pcov || 0 if cov
- cov = (cov ? (cov == 0 ? "#####" : cov.to_s) : "-").rjust(9)
- out.puts("%s:% 5d:%s" % [cov, idx + 1, line])
- end
- end
- end
- end
-end