Skip to content

Commit

Permalink
tests : TestLogger always on
Browse files Browse the repository at this point in the history
  • Loading branch information
jmettraux committed May 19, 2009
1 parent 27ea55b commit 91a68d0
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 11 deletions.
4 changes: 4 additions & 0 deletions TODO.txt
Expand Up @@ -8,6 +8,8 @@
[o] emit :processes :launch :wfid
[o] emit :processes :terminate :wfid only
[o] arch doc
[o] verbose always on

[ ] NullParticipant
[ ] wfid_gen : rufus-mnemo
[ ] ev : :participants :register/:unregister
Expand All @@ -22,5 +24,7 @@
[ ] on_error
[ ] on_cancel

[ ] forget

[ ] fs_error_journal

11 changes: 2 additions & 9 deletions test/functional/base.rb
Expand Up @@ -41,6 +41,8 @@ def setup

@engine = determine_engine_class(ac).new(ac)

@engine.add_service(:s_logger, Ruote::TestLogger)

@terminated_processes = []
@engine.wqueue.subscribe(:processes) do |eclass, emsg, eargs|
@terminated_processes << eargs[:wfid] if emsg == :terminate
Expand Down Expand Up @@ -75,18 +77,9 @@ def assert_trace (launch_thing, expected_trace, opts={})
protected

def noisy (on=true)
verbose(true) if on and ( ! @engine.context[:s_logger])
@engine.context[:noisy] = on
end

def verbose (on=true)
if on
@engine.add_service(:s_logger, Ruote::TestLogger)
else
@engine.remove_service(:s_logger)
end
end

def logger
@engine.context[:s_logger]
end
Expand Down
1 change: 0 additions & 1 deletion test/functional/eft_3_participant.rb
Expand Up @@ -22,7 +22,6 @@ def test_participant
end

#noisy
verbose

assert_trace pdef, 'alpha'
assert_equal 1, logger.log.select { |e| e[1] == :dispatching }.size
Expand Down
2 changes: 1 addition & 1 deletion test/functional/ft_0_wqueue.rb
Expand Up @@ -15,7 +15,7 @@ class FtWorkqueueTest < Test::Unit::TestCase

def test_launch_terminate

verbose
#noisy

pdef = Ruote.process_definition do
end
Expand Down
49 changes: 49 additions & 0 deletions test/functional/ft_3_participant_registration.rb
@@ -0,0 +1,49 @@

#
# Testing Ruote (OpenWFEru)
#
# Mon May 18 22:25:57 JST 2009
#

require File.dirname(__FILE__) + '/base'


class FtParticipantRegistrationTest < Test::Unit::TestCase
include FunctionalBase

def test_participant_register

#noisy

@engine.register_participant :alpha do |workitem|
@tracer << 'alpha'
end

wait

entry = logger.log.last
assert_equal :registered, entry[1]
assert_equal :alpha, entry.last[:regex]
assert_equal Ruote::BlockParticipant, entry.last[:participant]

assert_equal [ /^alpha$/ ], @engine.plist.list.collect { |e| e.first }
end

def test_participant_unregister

#noisy

@engine.register_participant :alpha do |workitem|
@tracer << 'alpha'
end

@engine.unregister_participant :alpha

entry = logger.log.last
assert_equal :unregistered, entry[1]
assert_equal :alpha, entry.last[:regex]

assert_equal 0, @engine.plist.list.size
end
end

0 comments on commit 91a68d0

Please sign in to comment.