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.



1228
1229
1230
1231
1232
1233
1234
1235
# File 'lib/roby/test/execution_expectations.rb', line 1228

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



1280
1281
1282
# File 'lib/roby/test/execution_expectations.rb', line 1280

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


1237
1238
1239
1240
1241
# File 'lib/roby/test/execution_expectations.rb', line 1237

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

#relates_to_error?(exception) ⇒ Boolean

Returns:

  • (Boolean)


1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
# File 'lib/roby/test/execution_expectations.rb', line 1259

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



1284
1285
1286
# File 'lib/roby/test/execution_expectations.rb', line 1284

def return_object
    @task.failure_reason
end

#to_sObject



1288
1289
1290
# File 'lib/roby/test/execution_expectations.rb', line 1288

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

#unachievable?(_propagation_info) ⇒ Boolean

Returns:

  • (Boolean)


1253
1254
1255
1256
1257
# File 'lib/roby/test/execution_expectations.rb', line 1253

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

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

#update_match(_propagation_info) ⇒ Object



1243
1244
1245
1246
1247
1248
1249
1250
1251
# File 'lib/roby/test/execution_expectations.rb', line 1243

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