Module: Syskit::Test::Base

Included in:
Self, Spec
Defined in:
lib/syskit/test/base.rb

Overview

Base functionality for all testing cases

Instance Method Summary collapse

Instance Method Details

#assert_has_no_new_sample(reader, timeout = 0.2) ⇒ Object

Deprecated.

use the expectations on ExecutionExpectations instead



64
65
66
67
68
69
# File 'lib/syskit/test/base.rb', line 64

def assert_has_no_new_sample(reader, timeout = 0.2)
    Roby.warn_deprecated "#{__method__} is deprecated, use the have_no_new_sample expectation on expect_execution instead"
    expect_execution.to do
        have_no_new_sample(reader, at_least_during: timeout)
    end
end

#assert_has_one_new_sample(reader, timeout = 3) ⇒ Object

Deprecated.

use the expectations on ExecutionExpectations instead



72
73
74
75
76
77
# File 'lib/syskit/test/base.rb', line 72

def assert_has_one_new_sample(reader, timeout = 3)
    Roby.warn_deprecated "#{__method__} is deprecated, use the have_one_new_sample expectation on expect_execution instead"
    expect_execution.to do
        have_one_new_sample(reader)
    end
end

#plug_connection_managementObject



56
57
58
# File 'lib/syskit/test/base.rb', line 56

def plug_connection_management
    RobyApp::Plugin.plug_handler_in_roby(execution_engine, :connection_management)
end

#plug_requirement_modificationsObject



49
50
51
# File 'lib/syskit/test/base.rb', line 49

def plug_requirement_modifications
    RobyApp::Plugin.plug_handler_in_roby(execution_engine, :apply_requirement_modifications)
end

#setupObject



14
15
16
17
18
19
# File 'lib/syskit/test/base.rb', line 14

def setup
    @task_stubs = Array.new
    @old_loglevel = Orocos.logger.level

    super
end

#stub_type(name) ⇒ Object

Creates a new null type and returns it



80
81
82
83
# File 'lib/syskit/test/base.rb', line 80

def stub_type(name)
    Roby.app.default_loader.
        resolve_type(name, define_dummy_type: true)
end

#teardownObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/syskit/test/base.rb', line 21

def teardown
    # Disable log output to avoid spurious "stopped / interrupting"
    registered_plans.each do |p|
        if p.executable?
            p.find_tasks(Syskit::TaskContext).each do |t|
                flexmock(t).should_receive(:info)
            end
        end
    end

    plug_connection_management
    begin
        super
    rescue ::Exception => e
        teardown_failure = e
    end

    @task_stubs.each do |t|
        t.dispose
    end

ensure
    Orocos.logger.level = @old_loglevel if @old_loglevel
    if teardown_failure
        raise teardown_failure
    end
end

#unplug_connection_managementObject



59
60
61
# File 'lib/syskit/test/base.rb', line 59

def unplug_connection_management
    RobyApp::Plugin.unplug_handler_from_roby(execution_engine, :connection_management)
end

#unplug_requirement_modificationsObject



52
53
54
# File 'lib/syskit/test/base.rb', line 52

def unplug_requirement_modifications
    RobyApp::Plugin.unplug_handler_from_roby(execution_engine, :apply_requirement_modifications)
end