class Rcov::TextCoverageDiff
def compare_state
def compare_state return unless verify_diff_available begin format, prev_state = File.open(@state_file){|f| self.SERIALIZER.load(f) } rescue $stderr.puts <<-EOF Couldn't load coverage data from #{@state_file}. EOF return # ' end if !(Array === format) or FORMAT_VERSION[0] != format[0] || FORMAT_VERSION[1] < format[1] $stderr.puts <<-EOF Couldn't load coverage data from #{@state_file}. The file is saved in the format #{format.inspect[0..20]}. This rcov executable understands #{FORMAT_VERSION.inspect}. EOF return # ' end each_file_pair_sorted do |filename, fileinfo| old_data = Tempfile.new("#{mangle_filename(filename)}-old") new_data = Tempfile.new("#{mangle_filename(filename)}-new") if prev_state.has_key? filename old_code, old_cov = prev_state[filename].values_at(:lines, :coverage) old_code.each_with_index do |line, i| prefix = old_cov[i] ? " " : "!! " old_data.write "#{prefix}#{line}" end else old_data.write "" end old_data.close SCRIPT_LINES__[filename].each_with_index do |line, i| prefix = fileinfo.coverage[i] ? " " : "!! " new_data.write "#{prefix}#{line}" end new_data.close diff = `#{@diff_cmd} -u "#{old_data.path}" "#{new_data.path}"` new_uncovered_hunks = process_unified_diff(filename, diff) old_data.close! new_data.close! display_hunks(filename, new_uncovered_hunks) end end