test/flowtestbase.rb in openwferu-0.9.13 vs test/flowtestbase.rb in openwferu-0.9.14

- old
+ new

@@ -40,10 +40,13 @@ module FlowTestBase attr_reader \ :engine, :tracer + # + # SETUP + # def setup @engine = $WORKFLOW_ENGINE_CLASS.new @engine.application_context[:ruby_eval_allowed] = true @@ -78,17 +81,26 @@ @engine.register_participant('p-toto') do |workitem| @tracer << "toto" end end + # + # TEARDOWN + # def teardown - - @engine.stop if @engine + if @engine + $OWFE_LOG.level = Logger::INFO + @engine.stop + end end protected + def log_level_to_debug + $OWFE_LOG.level = Logger::DEBUG + end + def print_exp_list (l) puts l.each do |fexp| puts " - #{fexp.fei.to_debug_s}" end @@ -98,17 +110,18 @@ def name_of_test s = caller(1)[0] i = s.index('`') #s = s[i+1..s.length-2] s = s[i+6..s.length-2] - return s + s end # # dotest() # - def dotest (flowDef, expectedTrace, join=false, allowRemainingExpressions=false) + def dotest ( + flowDef, expectedTrace, join=false, allowRemainingExpressions=false) @tracer.clear li = if flowDef.kind_of? OpenWFE::LaunchItem flowDef @@ -116,10 +129,12 @@ OpenWFE::LaunchItem.new(flowDef) end fei = @engine.launch(li) + $OWFE_LOG.info { "dotest() launched #{fei.to_s}" } + if join.is_a?(Numeric) sleep join else @engine.wait_for fei end @@ -159,31 +174,44 @@ '#{expectedTrace}' """ end if allowRemainingExpressions - engine.get_expression_storages.each do |storage| - storage.purge - end + + purge_engine + return fei end exp_storage = engine.get_expression_storage + size = exp_storage.size - if exp_storage.length != 1 + if size != 1 puts puts " remaining expressions : #{exp_storage.length}" puts puts exp_storage.to_s puts + puts OpenWFE::caller_to_s(0, 2) + puts + + purge_engine end - assert \ - exp_storage.length == 1, + assert_equal( + size, + 1, "there are expressions remaining in the expression pool " + - "(#{exp_storage.length})" + "(#{exp_storage.length})") - return fei + fei + end + + def purge_engine + + @engine.get_expression_storages.each do |storage| + storage.purge + end end end #