trace-util-adv 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Advanced TraceUtils tutorial.pdf +0 -0
- data/CHANGELOG +4 -8
- data/{lib/TODO.txt → TODO.txt} +8 -0
- data/VERSION +1 -1
- data/lib/action_handler/action_handler.rb +40 -0
- data/lib/{action_handler.rb → action_handler/action_handler_registration.rb} +3 -41
- data/lib/appenders/appender.rb +1 -13
- data/lib/appenders/appender_mappings.rb +13 -0
- data/lib/appenders/base_appender.rb +2 -11
- data/lib/appenders/file_appender.rb +21 -13
- data/lib/appenders/include.rb +4 -0
- data/lib/appenders/types/README-NOTE.txt +2 -0
- data/lib/appenders/{html_appender.rb → types/html_appender.rb} +4 -20
- data/lib/appenders/{logger_appender.rb → types/logger_appender.rb} +0 -0
- data/lib/appenders/{stream_appender.rb → types/stream_appender.rb} +0 -0
- data/lib/appenders/{template_log_appender.rb → types/template_log_appender.rb} +0 -0
- data/lib/appenders/{xml_appender.rb → types/xml_appender.rb} +1 -1
- data/lib/extensions/array_extensions.rb +42 -0
- data/lib/extensions/hash_extensions.rb +181 -0
- data/lib/extensions/hash_rule_extensions.rb +50 -0
- data/lib/extensions/include.rb +1 -0
- data/lib/extensions/nilclass_extensions.rb +10 -0
- data/lib/extensions/object_extensions.rb +19 -0
- data/lib/extensions/string_extensions.rb +35 -0
- data/lib/extensions/symbol_extensions.rb +30 -0
- data/lib/filters/composite/composite_class_filter.rb +25 -0
- data/lib/filters/composite/composite_module_filter.rb +53 -0
- data/lib/filters/executor/filter_exec.rb +74 -0
- data/lib/filters/filter.rb +43 -0
- data/lib/filters/filter_factory.rb +1 -1
- data/lib/filters/filter_mappings.rb +36 -0
- data/lib/filters/{tracing_filter.rb → filter_registration.rb} +6 -49
- data/lib/filters/filter_use.rb +10 -0
- data/lib/filters/include.rb +8 -0
- data/lib/filters/list/README-NOTE.txt +1 -0
- data/lib/filters/list/list_instance_var_filter.rb +27 -0
- data/lib/filters/{message_filters.rb → msg_context/message_context_filters.rb} +3 -12
- data/lib/filters/simple/argument_filter.rb +24 -0
- data/lib/filters/simple/class_filter.rb +15 -0
- data/lib/filters/simple/instance_var_filter.rb +25 -0
- data/lib/filters/simple/method_filter.rb +17 -0
- data/lib/filters/simple/module_filter.rb +14 -0
- data/lib/{templates/trace_output_handler.rb → output_handler/output_handler.rb} +0 -0
- data/lib/rules/rule_mappings.rb +10 -0
- data/lib/{rule_match.rb → rules/rule_match.rb} +5 -3
- data/lib/targets/README-NOTE.txt +2 -0
- data/lib/targets/file_target.rb +65 -0
- data/lib/targets/stream_target.rb +9 -0
- data/lib/targets/string_target.rb +9 -0
- data/lib/templates/base_template.rb +3 -2
- data/lib/templates/html_template.rb +1 -2
- data/lib/templates/include.rb +2 -0
- data/lib/templates/string_template.rb +24 -25
- data/lib/templates/template_mappings.rb +10 -0
- data/lib/templates/xml_template.rb +28 -29
- data/lib/trace-util-adv.rb +24 -4
- data/lib/{trace_calls.rb → trace_calls/trace_calls.rb} +0 -0
- data/lib/trace_calls/trace_configuration.rb +29 -0
- data/lib/{trace_ext.rb → trace_calls/trace_ext.rb} +10 -9
- data/test/{test_action_handler.rb → action_handler/test_action_handler.rb} +1 -5
- data/test/action_handler/test_create_action_handler.rb +31 -0
- data/test/appenders/test_appender_filters.rb +0 -0
- data/test/appenders/test_appender_tracers.rb +56 -0
- data/test/appenders/test_create_appender.rb +49 -0
- data/test/{test_html_appender.rb → appenders/test_html_appender.rb} +3 -7
- data/test/appenders/test_stream_appender.rb +41 -0
- data/test/appenders/test_template_log_appender.rb +18 -0
- data/test/{test_xml_appender.rb → appenders/test_xml_appender.rb} +0 -0
- data/test/extensions/test_filters_creation.rb +36 -0
- data/test/extensions/test_hash_extensions.rb +208 -0
- data/test/extensions/test_hash_filter_extensions.rb +65 -0
- data/test/extensions/test_set_context.rb +94 -0
- data/test/extensions/test_string_extensions.rb +55 -0
- data/test/extensions/test_symbol_extensions.rb +35 -0
- data/test/{test_filters_chain.rb → filters/chain/test_filters_chain.rb} +2 -1
- data/test/filters/composite/test_composite_class_filter.rb +78 -0
- data/test/filters/composite/test_composite_module_filter.rb +82 -0
- data/test/filters/composite/test_composite_var_filter.rb +103 -0
- data/test/filters/executor/test_filter_exec.rb +80 -0
- data/test/filters/msg_context/test_custom_filters.rb +54 -0
- data/test/filters/simple/test_base_filter.rb +56 -0
- data/test/filters/simple/test_class_filter.rb +75 -0
- data/test/filters/simple/test_instancevar_filter.rb +82 -0
- data/test/filters/simple/test_method_filter.rb +77 -0
- data/test/filters/simple/test_module_filter.rb +63 -0
- data/test/samples/include.rb +1 -0
- data/test/samples/sample_classes.rb +23 -0
- data/test/samples/sample_composite_filters.rb +50 -0
- data/test/samples/sample_filters.rb +58 -0
- data/test/sandbox/matcher.rb +7 -0
- data/test/sandbox/sandbox.rb +25 -0
- data/test/{test_xml_gen.rb → sandbox/test_xml_gen.rb} +0 -0
- data/test/trace_calls/test_configure_.rb +70 -0
- data/test/trace_calls/tracing/test_html_tracing.rb +20 -0
- data/test/trace_calls/tracing/test_logger_tracing.rb +18 -0
- data/test/trace_calls/tracing/test_stream_tracing.rb +17 -0
- data/test/trace_calls/tracing/test_teamplate_log_tracing.rb +18 -0
- data/test/trace_calls/tracing/test_xml_tracing.rb +18 -0
- data/test/tracers/test_create_tracers.rb +46 -0
- data/test/tracers/test_exec_tracers.rb +11 -0
- data/trace-util-adv.gemspec +91 -32
- metadata +91 -32
- data/lib/core_extensions.rb +0 -101
- data/lib/filters/base_filters.rb +0 -178
- data/lib/filters/composite_filters.rb +0 -71
- data/lib/output_templates.rb +0 -5
- data/lib/sample_filters.rb +0 -97
- data/lib/trace_appenders.rb +0 -9
- data/lib/trace_filters.rb +0 -4
- data/test/test_appender.rb +0 -29
- data/test/test_file_appender.rb +0 -32
- data/test/test_filters.rb +0 -112
- data/test/test_filters_create.rb +0 -28
- data/test/test_special_filters.rb +0 -78
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
module Tracing
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
end
|
|
2
|
+
class StringTemplate < BaseTemplate
|
|
3
|
+
def before_template(context)
|
|
4
|
+
template = <<-EOF
|
|
5
|
+
<<= <%= context[:method_full_name] %> : BEGIN
|
|
6
|
+
-----------------------------------------------
|
|
7
|
+
<%= context[:args].inspect %>
|
|
8
|
+
===============================================
|
|
9
|
+
EOF
|
|
10
|
+
end
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def end_template(context)
|
|
21
|
-
template = <<-EOF
|
|
22
|
-
<<= <%= context[:method_full_name] %> : END
|
|
23
|
-
-----------------------------------------------
|
|
24
|
-
<%= context[:result] %>
|
|
25
|
-
===============================================
|
|
26
|
-
EOF
|
|
27
|
-
end
|
|
12
|
+
def before_block_template
|
|
13
|
+
template = <<-EOF
|
|
14
|
+
(and a block)
|
|
15
|
+
-----------------------------------------------
|
|
16
|
+
EOF
|
|
28
17
|
end
|
|
18
|
+
|
|
19
|
+
def end_template(context)
|
|
20
|
+
template = <<-EOF
|
|
21
|
+
<<= <%= context[:method_full_name] %> : END
|
|
22
|
+
-----------------------------------------------
|
|
23
|
+
<%= context[:result] %>
|
|
24
|
+
===============================================
|
|
25
|
+
EOF
|
|
26
|
+
end
|
|
29
27
|
end
|
|
28
|
+
end
|
|
30
29
|
end
|
|
@@ -1,36 +1,35 @@
|
|
|
1
1
|
module Tracing
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
end
|
|
2
|
+
class XmlTemplate < BaseTemplate
|
|
3
|
+
def before_template(context)
|
|
4
|
+
template = <<-EOF
|
|
5
|
+
<method name="<%= context[:method_full_name] %>">
|
|
6
|
+
<modules><%= context[:full_module_name] %></modules>
|
|
7
|
+
<class><%= context[:class_name].join(',') %></class>
|
|
8
|
+
<args><%= context[:args].inspect %></args>
|
|
9
|
+
#block#
|
|
10
|
+
EOF
|
|
11
|
+
end
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
def before_block_template
|
|
14
|
+
template = <<-EOF
|
|
15
|
+
<block-arg>true</block-arg>
|
|
16
|
+
EOF
|
|
17
|
+
end
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
def end_template(context)
|
|
20
|
+
template = <<-EOF
|
|
21
|
+
<result><%= context[:result] %></result>
|
|
22
|
+
</method>
|
|
23
|
+
EOF
|
|
24
|
+
end
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
end
|
|
26
|
+
# override
|
|
27
|
+
def handle_before_call(context)
|
|
28
|
+
template = before_template(context)
|
|
29
|
+
block_replace = context[:block] ? before_block_template : ""
|
|
30
|
+
template.gsub!(/#block#/, block_replace)
|
|
31
|
+
output(template, context)
|
|
34
32
|
end
|
|
35
33
|
end
|
|
34
|
+
end
|
|
36
35
|
end
|
data/lib/trace-util-adv.rb
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'duration'
|
|
3
|
+
|
|
4
|
+
def include_folder_rec(name)
|
|
5
|
+
Dir.glob(File.join(File.dirname(__FILE__), "#{name}/**/*.rb")).each {|f|
|
|
6
|
+
puts f
|
|
7
|
+
require f
|
|
8
|
+
}
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def include_folder(name)
|
|
12
|
+
Dir.glob(File.join(File.dirname(__FILE__), "#{name}/*.rb")).each {|f|
|
|
13
|
+
puts f
|
|
14
|
+
require f
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
include_folder_rec('rules')
|
|
19
|
+
include_folder_rec('extensions')
|
|
20
|
+
require 'filters/include'
|
|
21
|
+
include_folder('output_handler')
|
|
22
|
+
require 'appenders/include'
|
|
23
|
+
include_folder_rec('action_handlers')
|
|
24
|
+
include_folder_rec('targets')
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Tracing
|
|
2
|
+
class Configuration
|
|
3
|
+
class << self
|
|
4
|
+
def apply(options)
|
|
5
|
+
in_module = options[:module]
|
|
6
|
+
classes_to_trace = options[:classes]
|
|
7
|
+
classes_to_trace.each do |cls|
|
|
8
|
+
eval "#{in_module}::#{cls}.class_eval { include Tracing::TraceCalls }"
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
include Tracing::Filter::Registration
|
|
14
|
+
include Tracing::ActionHandler::Registration
|
|
15
|
+
|
|
16
|
+
attr_accessor :final_yield_action
|
|
17
|
+
|
|
18
|
+
def initialize(options)
|
|
19
|
+
register_filters(options.filters)
|
|
20
|
+
register_action_handlers(options.action_handlers)
|
|
21
|
+
@final_yield_action = options.final_yield_action
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require '
|
|
3
|
-
require
|
|
4
|
-
require '
|
|
1
|
+
require 'extensions/include'
|
|
2
|
+
require 'appenders/include'
|
|
3
|
+
require "templates/include"
|
|
4
|
+
require 'output_handler/output_handler'
|
|
5
|
+
require 'action_handler/action_handler'
|
|
6
|
+
require 'filters/filter_use'
|
|
7
|
+
require "duration"
|
|
5
8
|
|
|
6
9
|
module Tracing
|
|
7
10
|
module TraceExt
|
|
8
|
-
# include Tracing::Filter::Registration
|
|
9
11
|
include Tracing::Filter::Exec
|
|
10
12
|
|
|
11
13
|
class << self
|
|
14
|
+
# supports
|
|
15
|
+
# - Filter registration
|
|
16
|
+
# - ActionHandler registration
|
|
12
17
|
include Tracing::Filter::Registration
|
|
13
18
|
include Tracing::ActionHandler::Registration
|
|
14
19
|
|
|
@@ -27,10 +32,6 @@ module Tracing
|
|
|
27
32
|
|
|
28
33
|
end
|
|
29
34
|
|
|
30
|
-
def method_full_name(context)
|
|
31
|
-
"#{context[:class_name]}.#{context[:method_name]}"
|
|
32
|
-
end
|
|
33
|
-
|
|
34
35
|
def trace_method?(context)
|
|
35
36
|
filters_allow?('', context)
|
|
36
37
|
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require "core_extensions"
|
|
2
|
+
require "trace_calls"
|
|
3
|
+
require "sample_filters"
|
|
4
|
+
require "rubygems"
|
|
5
|
+
require "duration"
|
|
6
|
+
require "test/unit"
|
|
7
|
+
|
|
8
|
+
class TestCreateActionHandler < Test::Unit::TestCase
|
|
9
|
+
|
|
10
|
+
def test_action_handlers
|
|
11
|
+
config = {:action_handlers => []}
|
|
12
|
+
result = config.action_handlers
|
|
13
|
+
assert_equal result.blank?, true, "Should result in empty action_handler list"
|
|
14
|
+
|
|
15
|
+
config = {:action_handlers => {:appenders => :html}}
|
|
16
|
+
result = config.action_handlers
|
|
17
|
+
assert_equal Tracing::HtmlAppender, result.appenders[0].class, "Should result in action handler with HtmlAppender registered"
|
|
18
|
+
|
|
19
|
+
config = {:action_handlers => {:filters => {:i_method_filter => "a,b"}}}
|
|
20
|
+
result = config.action_handlers
|
|
21
|
+
assert_equal Tracing::MethodFilter, result.filters[0].class, "Should result in action handler with MethodFilter registered"
|
|
22
|
+
|
|
23
|
+
ah1 = {:filters => {:i_method_filter => "a,b"}, :appenders => :html}
|
|
24
|
+
ah2 = {:filters => {:x_method_filter => "c,d"}, :appenders => :xml}
|
|
25
|
+
|
|
26
|
+
config = {:action_handlers => [ah1, ah2]}
|
|
27
|
+
result = config.action_handlers
|
|
28
|
+
assert_equal Tracing::MethodFilter, result[0].filters[0].class, "Should result in action handler with MethodFilter registered"
|
|
29
|
+
assert_equal Tracing::MethodFilter, result[1].filters[0].class, "Should result in action handler with MethodFilter registered"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'extensions/core_extensions'
|
|
2
|
+
require 'filters/base_filters'
|
|
3
|
+
require 'rules/hash_rule_extensions'
|
|
4
|
+
require "test/unit"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class TestAppenderTracers < Test::Unit::TestCase
|
|
8
|
+
|
|
9
|
+
def setup
|
|
10
|
+
# Trace filters
|
|
11
|
+
im_filter_1 = {:i_method_filter => "a,b"}
|
|
12
|
+
xym_class_1 = {:xy_class_filter => "C,D"}
|
|
13
|
+
@filters = [im_filter_1, xym_class_1]
|
|
14
|
+
|
|
15
|
+
@app_filter_1 = {:x_class_filter => "Dryml"}
|
|
16
|
+
@app_filter_2 = {:i_class_filter => "Template"}
|
|
17
|
+
|
|
18
|
+
@xml_tracer = {:type => :xml, :to_file => 'log_files/xml/traced.xml'}.tracer
|
|
19
|
+
@html_tracer = {:type => :html, :default_path => 'log_files/html/'}.tracer
|
|
20
|
+
@log_tracer = {:type => :log}.tracer
|
|
21
|
+
@stream_tracer = {:type => :stream}.tracer
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def test_appender_register_tracer
|
|
26
|
+
# Trace configuration
|
|
27
|
+
appender_1 = {:tracer => @xml_tracer}.appender
|
|
28
|
+
assert_equal Tracing::XmlAppender, appender_1.class, "Should create instance of XmlAppender"
|
|
29
|
+
|
|
30
|
+
appender_2 = {:tracer => @html_tracer}.appender
|
|
31
|
+
assert_equal Tracing::HtmlAppender, appender_2.class, "Should create instance of HtmlAppender"
|
|
32
|
+
|
|
33
|
+
appender_3 = {:tracer => @log_tracer}.appender
|
|
34
|
+
assert_equal Tracing::HtmlAppender, appender_3.class, "Should create instance of LogAppender"
|
|
35
|
+
|
|
36
|
+
appender_4 = {:tracer => @stream_tracer}.appender
|
|
37
|
+
assert_equal Tracing::StreamAppender, appender_4.class, "Should create instance of Streamppender"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_appender_register_tracer_and_filters
|
|
42
|
+
# Trace configuration
|
|
43
|
+
appender_1 = {:tracer => @xml_tracer, :filters => @app_filter_1}.appender
|
|
44
|
+
assert_equal Tracing::XmlAppender, appender_1.class, "Should create instance of XmlAppender"
|
|
45
|
+
|
|
46
|
+
appender_2 = {:tracer => @html_tracer, :filters => @app_filter_1}.appender
|
|
47
|
+
assert_equal Tracing::HtmlAppender, appender_2.class, "Should create instance of HtmlAppender"
|
|
48
|
+
|
|
49
|
+
appender_3 = {:tracer => @log_tracer, :filters => @app_filter_1}.appender
|
|
50
|
+
assert_equal Tracing::HtmlAppender, appender_3.class, "Should create instance of LogAppender"
|
|
51
|
+
|
|
52
|
+
appender_4 = {:tracer => @stream_tracer, :filters => @app_filter_1}.appender
|
|
53
|
+
assert_equal Tracing::StreamAppender, appender_4.class, "Should create instance of Streamppender"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require 'extensions/core_extensions'
|
|
2
|
+
require "test/unit"
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class TestAppenderTracers < Test::Unit::TestCase
|
|
6
|
+
|
|
7
|
+
def test_exec_xml_tracer
|
|
8
|
+
xml_tracer = {:type => :xml, :to_file => 'log_files/xml/traced.xml'}.tracer
|
|
9
|
+
assert_equal Tracing::XmlAppender, xml_tracer.class, "Should create instance of XmlTracer"
|
|
10
|
+
|
|
11
|
+
xml_tracer.trace('hello world')
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_exec_html_tracer
|
|
15
|
+
html_tracer = {:type => :html, :default_path => 'log_files/html'}.tracer
|
|
16
|
+
assert_equal Tracing::HtmlAppender, html_tracer.class, "Should create instance of HtmlTracer"
|
|
17
|
+
|
|
18
|
+
html_tracer.trace('hello world')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_exec_log_tracer
|
|
22
|
+
log_tracer = {:type => :log, :default_path => 'log_files'}.tracer
|
|
23
|
+
assert_equal Tracing::LoggerAppender, log_tracer.class, "Should create instance of LogTracer"
|
|
24
|
+
|
|
25
|
+
log_tracer.trace('hello world')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_exec_log_tracer
|
|
29
|
+
appender = {:type => :stream, :stream => :STDOUT}.tracer
|
|
30
|
+
assert_equal Tracing::StreamAppender, log_tracer.class, "Should create instance of StreamTracer"
|
|
31
|
+
|
|
32
|
+
stream_tracer.trace('hello world')
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_create_appenders
|
|
36
|
+
config = {:appenders => []}
|
|
37
|
+
result = config.appenders
|
|
38
|
+
assert_equal result.blank?, true, "Should result in empty appender list"
|
|
39
|
+
|
|
40
|
+
config = {:appenders => :html}
|
|
41
|
+
result = config.appenders
|
|
42
|
+
assert_equal result.class, Tracing::HtmlAppender, "Should result in empty appender list"
|
|
43
|
+
|
|
44
|
+
config = {:appenders => [:xml, :html]}
|
|
45
|
+
result = config.appenders
|
|
46
|
+
assert_equal Tracing::XmlAppender, result[0].class, "Should result in xml appender"
|
|
47
|
+
assert_equal Tracing::HtmlAppender, result[1].class, "Should also result in html appender"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -20,17 +20,13 @@ class TestFilter < Test::Unit::TestCase
|
|
|
20
20
|
def teardown
|
|
21
21
|
## Nothing really
|
|
22
22
|
end
|
|
23
|
-
|
|
24
|
-
def method_full_name(context)
|
|
25
|
-
"#{context[:class_name]}.#{context[:method_name]}"
|
|
26
|
-
end
|
|
27
|
-
|
|
23
|
+
|
|
28
24
|
def test_filter
|
|
29
25
|
cls_name = "Alpha::Beta::Gamma"
|
|
30
26
|
name = "my_method"
|
|
31
27
|
my_instance_variables = {:template_path => 'taglibs/rapid_core.dryml'}
|
|
32
28
|
args = {:a => 7}
|
|
33
|
-
|
|
29
|
+
context =
|
|
34
30
|
:modules => cls_name.modules,
|
|
35
31
|
:class_name => cls_name.class_name,
|
|
36
32
|
:full_class_name => cls_name,
|
|
@@ -46,7 +42,7 @@ class TestFilter < Test::Unit::TestCase
|
|
|
46
42
|
name = "my_other_method"
|
|
47
43
|
|
|
48
44
|
@context[:method_name] = name
|
|
49
|
-
@context[:method_full_name] = method_full_name(@
|
|
45
|
+
@context[:method_full_name] = method_full_name(@contex)
|
|
50
46
|
|
|
51
47
|
@ah1.allow_append("BEGIN #{name}", @context)
|
|
52
48
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require "core_extensions"
|
|
2
|
+
require "trace_calls"
|
|
3
|
+
require "output_templates"
|
|
4
|
+
require "sample_filters"
|
|
5
|
+
require "rubygems"
|
|
6
|
+
require "duration"
|
|
7
|
+
require "test/unit"
|
|
8
|
+
|
|
9
|
+
class TestStreamAppender < Test::Unit::TestCase
|
|
10
|
+
|
|
11
|
+
attr_reader :ah1, :filters
|
|
12
|
+
|
|
13
|
+
def setup
|
|
14
|
+
@stream_app = {:tracer => :stream, :stream => :out}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_filter
|
|
18
|
+
context = Testing.default_context
|
|
19
|
+
|
|
20
|
+
@ah1.allow_append("BEGIN #{name}", @context)
|
|
21
|
+
|
|
22
|
+
name = "my_other_method"
|
|
23
|
+
context.method_name = name
|
|
24
|
+
|
|
25
|
+
@ah1.allow_append("BEGIN #{name}", @context)
|
|
26
|
+
|
|
27
|
+
context.result = "32"
|
|
28
|
+
|
|
29
|
+
@ah1.allow_append("END #{name}", @context)
|
|
30
|
+
|
|
31
|
+
name = "my_method"
|
|
32
|
+
context.method_name = name
|
|
33
|
+
|
|
34
|
+
context.result = "27"
|
|
35
|
+
|
|
36
|
+
@ah1.allow_append("END #{name}", @context)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require "trace_util_adv"
|
|
2
|
+
require "samples/include"
|
|
3
|
+
|
|
4
|
+
class TestDrymlTemplateLogging < Test::Unit::TestCase
|
|
5
|
+
|
|
6
|
+
def test_dryml_template_tracing
|
|
7
|
+
classes_to_trace = [ 'My']
|
|
8
|
+
Tracing::TemplateLogAppender.default_path = 'log_files/templates'
|
|
9
|
+
Tracing::TraceCalls.configure(:type => :template_log, :filters => Method_filter_dryml)
|
|
10
|
+
my = Me::My.new
|
|
11
|
+
my.hello
|
|
12
|
+
my.hi_there
|
|
13
|
+
my.blip
|
|
14
|
+
my.blap
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
|
|
File without changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'extensions/core_extensions'
|
|
2
|
+
require 'filters/base_filters'
|
|
3
|
+
require 'rules/hash_rule_extensions'
|
|
4
|
+
require "test/unit"
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class TestFiltersCreation < Test::Unit::TestCase
|
|
8
|
+
|
|
9
|
+
def test_try_create_method_include_filter
|
|
10
|
+
hash = {:i_method_filter => 'a,b'}
|
|
11
|
+
filter_hash = hash.create_filter
|
|
12
|
+
expected = {:method_filter => {:include => "a,b"}}
|
|
13
|
+
puts filter_hash.inspect
|
|
14
|
+
assert_equal expected, filter_hash, "Should create method include filter"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_filters_creation
|
|
18
|
+
# config = {:filters => []}
|
|
19
|
+
# result = config.filters
|
|
20
|
+
# assert_equal result.blank?, true, "Should result in empty filters list"
|
|
21
|
+
|
|
22
|
+
im_filter = {:i_method_filter => "a,b"}
|
|
23
|
+
config = {:filters => im_filter}
|
|
24
|
+
|
|
25
|
+
res = im_filter.filters
|
|
26
|
+
puts "res: #{res.inspect}"
|
|
27
|
+
|
|
28
|
+
result = config.filters
|
|
29
|
+
puts "result: #{result.inspect}"
|
|
30
|
+
# assert_equal Tracing::MethodFilter, result.class, "Should result in method filter"
|
|
31
|
+
|
|
32
|
+
# puts "rules: #{result.rules.inspect}"
|
|
33
|
+
# expected = {:method_filter => {:include => "a, b"} }
|
|
34
|
+
# assert_equal expected, result.rules, "Should result in method rules"
|
|
35
|
+
end
|
|
36
|
+
end
|