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.



1233
1234
1235
1236
1237
1238
1239
1240
# File 'lib/roby/test/execution_expectations.rb', line 1233

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



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

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


1242
1243
1244
1245
1246
# File 'lib/roby/test/execution_expectations.rb', line 1242

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

#relates_to_error?(exception) ⇒ Boolean

Returns:

  • (Boolean)


1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
# File 'lib/roby/test/execution_expectations.rb', line 1264

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



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

def return_object
    @task.failure_reason
end

#to_sObject



1293
1294
1295
# File 'lib/roby/test/execution_expectations.rb', line 1293

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

#unachievable?(_propagation_info) ⇒ Boolean

Returns:

  • (Boolean)


1258
1259
1260
1261
1262
# File 'lib/roby/test/execution_expectations.rb', line 1258

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

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

#update_match(_propagation_info) ⇒ Object



1248
1249
1250
1251
1252
1253
1254
1255
1256
# File 'lib/roby/test/execution_expectations.rb', line 1248

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