test/distributed/test_communication.rb in roby-0.7.3 vs test/distributed/test_communication.rb in roby-0.8.0

- old
+ new

@@ -1,5 +1,6 @@ +$LOAD_PATH.unshift File.expand_path(File.join('..', '..', 'lib'), File.dirname(__FILE__)) require 'test/unit' require 'roby/distributed' require 'roby/test/distributed' require 'flexmock' @@ -41,11 +42,11 @@ end def setup super - peer2peer(true) do |remote| + peer2peer do |remote| def remote.install_fake_methods local_peer.local_server.extend FakePeerServerMethods end end @@ -76,19 +77,32 @@ remote_peer.enable_tx remote_peer.synchro_point end end + def disable_logging + remote.disable_logging + logger = Roby::Distributed.logger + old_loglevel = logger.level + logger.level = Logger::UNKNOWN + yield + ensure + remote.enable_logging + logger.level = old_loglevel + end + def test_transmit_error FlexMock.use do |mock| remote_peer.disable_tx remote_peer.transmit(:reply_error, 2) do |result| mock.block_called end mock.should_receive(:block_called).never - remote_peer.enable_tx - assert_raises(Roby::Distributed::DisconnectedError) { remote_peer.synchro_point } + disable_logging do + remote_peer.enable_tx + assert_raises(Roby::Distributed::DisconnectedError) { remote_peer.synchro_point } + end assert(!remote_peer.connected?) end end @@ -115,28 +129,30 @@ t1.value t2.value end def test_call_raises - Roby.logger.level = Logger::FATAL - assert_raises(RuntimeError) do - remote_peer.call(:reply_error, 2) - end + disable_logging do + assert_raises(RuntimeError) do + remote_peer.call(:reply_error, 2) + end + end end def test_call_disconnects - Roby.logger.level = Logger::FATAL remote_peer.disable_tx remote_peer.transmit(:reply_error, 2) sleep(0.5) - Thread.new do - sleep(0.5) - remote_peer.enable_tx - end - assert_raises(DisconnectedError) { remote_peer.call(:reply, nil, 42) } + disable_logging do + Thread.new do + sleep(0.5) + remote_peer.enable_tx + end + assert_raises(DisconnectedError) { remote_peer.call(:reply, nil, 42) } + end end def test_callback FlexMock.use do |mock| # Check that nothing is sent while the link is not alive @@ -147,11 +163,12 @@ assert_equal(42, remote_peer.call(:reply_with_callback, DRbObject.new(mock), 42)) end end def test_recursive_callbacks - Roby.logger.level = Logger::FATAL - assert_raises(DisconnectedError) { remote_peer.call(:recursive_callbacks) } + disable_logging do + assert_raises(DisconnectedError) { remote_peer.call(:recursive_callbacks) } + end end def test_synchro_point remote_peer.disable_tx remote.send_local_peer(:disable_tx)