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.



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

def initialize(errors)
    super()

    @errors = errors
end

Instance Method Details

#droby_dump(peer) ⇒ Object



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

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

#each_execution_exceptionObject



406
407
408
409
410
411
412
# File 'lib/roby/test/execution_expectations.rb', line 406

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



414
415
416
417
418
419
420
421
# File 'lib/roby/test/execution_expectations.rb', line 414

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



429
430
431
432
433
# File 'lib/roby/test/execution_expectations.rb', line 429

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

#to_sObject



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
463
464
465
466
467
# File 'lib/roby/test/execution_expectations.rb', line 435

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