Class: Roby::Test::ExecutionExpectations::FailsToStart

Inherits:
Expectation show all
Defined in:
lib/roby/test/execution_expectations.rb

Instance Attribute Summary

Attributes inherited from Expectation

#backtrace

Instance Method Summary collapse

Methods inherited from Expectation

#filter_result, #filter_result_with, #format_unachievable_explanation

Constructor Details

#initialize(task, reason, backtrace) ⇒ FailsToStart

Returns a new instance of FailsToStart.



1171
1172
1173
1174
1175
1176
1177
1178
# File 'lib/roby/test/execution_expectations.rb', line 1171

def initialize(task, reason, backtrace)
    super(backtrace)
    @task = task
    return unless reason.respond_to?(:to_execution_exception_matcher)

    @reason = reason.to_execution_exception_matcher
    @related_error_match = make_related_error_matcher(reason)
end

Instance Method Details

#explain_unachievable(_propagation_info) ⇒ Object



1223
1224
1225
# File 'lib/roby/test/execution_expectations.rb', line 1223

def explain_unachievable(_propagation_info)
    "#{@task.failure_reason} does not match #{@reason}"
end


1180
1181
1182
1183
1184
# File 'lib/roby/test/execution_expectations.rb', line 1180

def make_related_error_matcher(reason)
    LocalizedError.match
                  .with_original_exception(reason)
                  .to_execution_exception_matcher
end

#relates_to_error?(exception) ⇒ Boolean

Returns:

  • (Boolean)


1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
# File 'lib/roby/test/execution_expectations.rb', line 1202

def relates_to_error?(exception)
    return unless @task.failed_to_start?

    reason =
        if @reason
            @reason
        elsif @task.failure_reason
            Queries::ExecutionExceptionMatcher
            .new
            .with_exception(@task.failure_reason)
        end

    return unless reason

    related_error_matcher =
        @related_error_matcher ||
        make_related_error_matcher(reason)

    (reason === exception) || (related_error_matcher === exception)
end

#return_objectObject



1227
1228
1229
# File 'lib/roby/test/execution_expectations.rb', line 1227

def return_object
    @task.failure_reason
end

#to_sObject



1231
1232
1233
# File 'lib/roby/test/execution_expectations.rb', line 1231

def to_s
    "#{@generator} should fail to start"
end

#unachievable?(_propagation_info) ⇒ Boolean

Returns:

  • (Boolean)


1196
1197
1198
1199
1200
# File 'lib/roby/test/execution_expectations.rb', line 1196

def unachievable?(_propagation_info)
    return unless @reason && @task.failed_to_start?

    !(@reason === @task.failure_reason)
end

#update_match(_propagation_info) ⇒ Object



1186
1187
1188
1189
1190
1191
1192
1193
1194
# File 'lib/roby/test/execution_expectations.rb', line 1186

def update_match(_propagation_info)
    if !@task.failed_to_start?
        false
    elsif !@reason
        true
    else
        @reason === @task.failure_reason
    end
end