Class: Roby::Test::ExecutionExpectations::UnexpectedErrors

Inherits:
Minitest::Assertion
  • Object
show all
Defined in:
lib/roby/test/execution_expectations.rb

Instance Method Summary collapse

Constructor Details

#initialize(errors) ⇒ UnexpectedErrors

Returns a new instance of UnexpectedErrors.



395
396
397
398
399
# File 'lib/roby/test/execution_expectations.rb', line 395

def initialize(errors)
    super()

    @errors = errors
end

Instance Method Details

#droby_dump(peer) ⇒ Object



418
419
420
421
422
# File 'lib/roby/test/execution_expectations.rb', line 418

def droby_dump(peer)
    UnexpectedErrors.new(
        @errors.map { |e| peer.dump(e) }
    )
end

#each_execution_exceptionObject



401
402
403
404
405
406
407
# File 'lib/roby/test/execution_expectations.rb', line 401

def each_execution_exception
    return enum_for(__method__) unless block_given?

    @errors.each do |e|
        yield(e) if e.kind_of?(ExecutionException)
    end
end

#each_original_exceptionObject



409
410
411
412
413
414
415
416
# File 'lib/roby/test/execution_expectations.rb', line 409

def each_original_exception
    return enum_for(__method__) unless block_given?

    @errors.each do |e|
        yield(e) if e.kind_of?(Exception)
        yield(e.exception) if e.kind_of?(ExecutionException)
    end
end

#proxy(peer) ⇒ Object



424
425
426
427
428
# File 'lib/roby/test/execution_expectations.rb', line 424

def proxy(peer)
    UnexpectedErrors.new(
        @errors.map { |e| peer.local_object(e) }
    )
end

#to_sObject



430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
# File 'lib/roby/test/execution_expectations.rb', line 430

def to_s
    formatted_errors = @errors.each_with_index.map do |e, i|
        formatted_execution_exception =
            "[#{i + 1}/#{@errors.size}] " +
            Roby.format_exception(e).join("\n")

        e = e.exception if e.kind_of?(ExecutionException)
        if e.backtrace && !e.backtrace.empty?
            formatted_execution_exception +=
                "\n    #{e.backtrace.join("\n    ")}"
        end

        sub_exceptions = Roby.flatten_exception(e)
        sub_exceptions.delete(e)
        formatted_sub_exceptions =
            sub_exceptions.each_with_index.map do |sub_e, sub_i|
                formatted = "[#{sub_i}] " +
                            Roby.format_exception(sub_e).join("\n    ")
                backtrace = Roby.format_backtrace(sub_e)
                unless backtrace.empty?
                    formatted += "    #{backtrace.join("\n    ")}"
                end
                formatted
            end.join("\n  ")

        unless formatted_sub_exceptions.empty?
            formatted_execution_exception +=
                "\n  #{formatted_sub_exceptions}"
        end
        formatted_execution_exception
    end.join("\n")
    "#{@errors.size} unexpected errors\n#{formatted_errors}"
end