This file is indexed.

/usr/lib/ruby/vendor_ruby/test/unit/error.rb is in ruby-test-unit 3.2.5-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  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
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#--
#
# Author:: Nathaniel Talbott.
# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
# License:: Ruby license.

require 'test/unit/util/backtracefilter'

module Test
  module Unit

    # Encapsulates an error in a test. Created by
    # Test::Unit::TestCase when it rescues an exception thrown
    # during the processing of a test.
    class Error
      include Util::BacktraceFilter

      attr_reader :test_name, :exception
      attr_reader :method_name

      SINGLE_CHARACTER = 'E'
      LABEL = "Error"

      # Creates a new Error with the given test_name and
      # exception.
      def initialize(test_name, exception, options={})
        @test_name = test_name
        @exception = exception
        @method_name = options[:method_name]
      end

      # Returns a single character representation of an error.
      def single_character_display
        SINGLE_CHARACTER
      end

      def label
        LABEL
      end

      # Returns the message associated with the error.
      def message
        "#{@exception.class.name}: #{@exception.message}"
      end

      # Returns a brief version of the error description.
      def short_display
        "#@test_name: #{message.split("\n")[0]}"
      end

      # Returns a verbose version of the error description.
      def long_display
        backtrace_display = location.join("\n    ")
        "#{label}:\n#@test_name:\n#{message}\n    #{backtrace_display}"
      end

      def location
        @location ||= filter_backtrace(@exception.backtrace)
      end
      alias_method :backtrace, :location # Deprecated

      # Overridden to return long_display.
      def to_s
        long_display
      end

      def critical?
        true
      end
    end

    module ErrorHandler
      class << self
        def included(base)
          base.exception_handler(:handle_all_exception)
        end
      end

      NOT_PASS_THROUGH_EXCEPTIONS = []
      NOT_PASS_THROUGH_EXCEPTION_NAMES = ["Timeout::Error"]
      PASS_THROUGH_EXCEPTIONS = [
        NoMemoryError,
        SignalException,
        Interrupt,
        SystemExit,
      ]
      PASS_THROUGH_EXCEPTION_NAMES = []
      private
      def handle_all_exception(exception)
        return false if pass_through_exception?(exception)

        problem_occurred
        add_error(exception)
        true
      end

      def pass_through_exception?(exception)
        case exception
        when *NOT_PASS_THROUGH_EXCEPTIONS
          return false
        end
        case exception.class.name
        when *NOT_PASS_THROUGH_EXCEPTION_NAMES
          return false
        end

        case exception
        when *PASS_THROUGH_EXCEPTIONS
          return true
        end
        case exception.class.name
        when *PASS_THROUGH_EXCEPTION_NAMES
          return true
        end

        false
      end

      def add_error(exception)
        error = Error.new(name, exception, :method_name => @method_name)
        current_result.add_error(error)
      end
    end

    module TestResultErrorSupport
      attr_reader :errors

      # Records a Test::Unit::Error.
      def add_error(error)
        @errors << error
        notify_fault(error)
        notify_changed
      end

      # Returns the number of errors this TestResult has
      # recorded.
      def error_count
        @errors.size
      end

      def error_occurred?
        not @errors.empty?
      end

      private
      def initialize_containers
        super
        @errors = []
        @summary_generators << :error_summary
        @problem_checkers << :error_occurred?
      end

      def error_summary
        "#{error_count} errors"
      end
    end
  end
end