piko-max-mod 0.0.1
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.
- checksums.yaml +7 -0
- data/piko-max-mod.gemspec +12 -0
- data/test-unit-3.7.8/BSDL +24 -0
- data/test-unit-3.7.8/COPYING +64 -0
- data/test-unit-3.7.8/PSFL +271 -0
- data/test-unit-3.7.8/README.md +108 -0
- data/test-unit-3.7.8/Rakefile +74 -0
- data/test-unit-3.7.8/bin/test-unit +5 -0
- data/test-unit-3.7.8/doc/text/getting-started.md +120 -0
- data/test-unit-3.7.8/doc/text/how-to.md +90 -0
- data/test-unit-3.7.8/doc/text/news.md +2070 -0
- data/test-unit-3.7.8/lib/test/unit/assertion-failed-error.rb +60 -0
- data/test-unit-3.7.8/lib/test/unit/assertions.rb +2536 -0
- data/test-unit-3.7.8/lib/test/unit/attribute-matcher.rb +26 -0
- data/test-unit-3.7.8/lib/test/unit/attribute.rb +228 -0
- data/test-unit-3.7.8/lib/test/unit/auto-runner-loader.rb +17 -0
- data/test-unit-3.7.8/lib/test/unit/autorunner.rb +654 -0
- data/test-unit-3.7.8/lib/test/unit/code-snippet-fetcher.rb +58 -0
- data/test-unit-3.7.8/lib/test/unit/collector/descendant.rb +20 -0
- data/test-unit-3.7.8/lib/test/unit/collector/dir.rb +110 -0
- data/test-unit-3.7.8/lib/test/unit/collector/load.rb +201 -0
- data/test-unit-3.7.8/lib/test/unit/collector/objectspace.rb +35 -0
- data/test-unit-3.7.8/lib/test/unit/collector/xml.rb +249 -0
- data/test-unit-3.7.8/lib/test/unit/collector.rb +104 -0
- data/test-unit-3.7.8/lib/test/unit/color-scheme.rb +225 -0
- data/test-unit-3.7.8/lib/test/unit/color.rb +134 -0
- data/test-unit-3.7.8/lib/test/unit/data-sets.rb +127 -0
- data/test-unit-3.7.8/lib/test/unit/data.rb +371 -0
- data/test-unit-3.7.8/lib/test/unit/diff.rb +745 -0
- data/test-unit-3.7.8/lib/test/unit/error.rb +158 -0
- data/test-unit-3.7.8/lib/test/unit/exception-handler.rb +82 -0
- data/test-unit-3.7.8/lib/test/unit/failure.rb +169 -0
- data/test-unit-3.7.8/lib/test/unit/fault-location-detector.rb +104 -0
- data/test-unit-3.7.8/lib/test/unit/fixture.rb +304 -0
- data/test-unit-3.7.8/lib/test/unit/notification.rb +138 -0
- data/test-unit-3.7.8/lib/test/unit/omission.rb +198 -0
- data/test-unit-3.7.8/lib/test/unit/pending.rb +155 -0
- data/test-unit-3.7.8/lib/test/unit/priority.rb +194 -0
- data/test-unit-3.7.8/lib/test/unit/process-test-result.rb +55 -0
- data/test-unit-3.7.8/lib/test/unit/process-worker.rb +87 -0
- data/test-unit-3.7.8/lib/test/unit/runner/console.rb +86 -0
- data/test-unit-3.7.8/lib/test/unit/runner/emacs.rb +8 -0
- data/test-unit-3.7.8/lib/test/unit/runner/xml.rb +15 -0
- data/test-unit-3.7.8/lib/test/unit/sub-test-result.rb +59 -0
- data/test-unit-3.7.8/lib/test/unit/test-process-run-context.rb +21 -0
- data/test-unit-3.7.8/lib/test/unit/test-run-context.rb +16 -0
- data/test-unit-3.7.8/lib/test/unit/test-suite-creator.rb +103 -0
- data/test-unit-3.7.8/lib/test/unit/test-suite-process-runner.rb +205 -0
- data/test-unit-3.7.8/lib/test/unit/test-suite-runner.rb +132 -0
- data/test-unit-3.7.8/lib/test/unit/test-suite-thread-runner.rb +96 -0
- data/test-unit-3.7.8/lib/test/unit/test-thread-run-context.rb +23 -0
- data/test-unit-3.7.8/lib/test/unit/testcase.rb +1058 -0
- data/test-unit-3.7.8/lib/test/unit/testresult.rb +132 -0
- data/test-unit-3.7.8/lib/test/unit/testsuite.rb +133 -0
- data/test-unit-3.7.8/lib/test/unit/ui/console/outputlevel.rb +15 -0
- data/test-unit-3.7.8/lib/test/unit/ui/console/testrunner.rb +891 -0
- data/test-unit-3.7.8/lib/test/unit/ui/emacs/testrunner.rb +49 -0
- data/test-unit-3.7.8/lib/test/unit/ui/testrunner.rb +53 -0
- data/test-unit-3.7.8/lib/test/unit/ui/testrunnermediator.rb +131 -0
- data/test-unit-3.7.8/lib/test/unit/ui/testrunnerutilities.rb +41 -0
- data/test-unit-3.7.8/lib/test/unit/ui/xml/testrunner.rb +225 -0
- data/test-unit-3.7.8/lib/test/unit/util/backtracefilter.rb +65 -0
- data/test-unit-3.7.8/lib/test/unit/util/memory-usage.rb +47 -0
- data/test-unit-3.7.8/lib/test/unit/util/method-owner-finder.rb +28 -0
- data/test-unit-3.7.8/lib/test/unit/util/observable.rb +86 -0
- data/test-unit-3.7.8/lib/test/unit/util/output.rb +32 -0
- data/test-unit-3.7.8/lib/test/unit/util/procwrapper.rb +48 -0
- data/test-unit-3.7.8/lib/test/unit/version.rb +5 -0
- data/test-unit-3.7.8/lib/test/unit/warning.rb +3 -0
- data/test-unit-3.7.8/lib/test/unit/worker-context.rb +20 -0
- data/test-unit-3.7.8/lib/test/unit.rb +521 -0
- data/test-unit-3.7.8/lib/test-unit.rb +19 -0
- data/test-unit-3.7.8/sample/adder.rb +13 -0
- data/test-unit-3.7.8/sample/subtracter.rb +12 -0
- data/test-unit-3.7.8/sample/test_adder.rb +20 -0
- data/test-unit-3.7.8/sample/test_subtracter.rb +20 -0
- data/test-unit-3.7.8/sample/test_user.rb +23 -0
- metadata +117 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require_relative '../console/testrunner'
|
|
2
|
+
|
|
3
|
+
module Test
|
|
4
|
+
module Unit
|
|
5
|
+
module UI
|
|
6
|
+
module Emacs
|
|
7
|
+
class TestRunner < Console::TestRunner
|
|
8
|
+
private
|
|
9
|
+
def output_setup_end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def output_started
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def format_fault(fault)
|
|
16
|
+
return super unless fault.respond_to?(:label)
|
|
17
|
+
format_method_name = "format_fault_#{fault.label.downcase}"
|
|
18
|
+
if respond_to?(format_method_name, true)
|
|
19
|
+
__send__(format_method_name, fault)
|
|
20
|
+
else
|
|
21
|
+
super
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def format_fault_failure(failure)
|
|
26
|
+
if failure.location.size == 1
|
|
27
|
+
location = failure.location[0]
|
|
28
|
+
location_display = location.sub(/\A(.+:\d+).*/, ' [\\1]')
|
|
29
|
+
else
|
|
30
|
+
location_display = "\n" + failure.location.join("\n")
|
|
31
|
+
end
|
|
32
|
+
result = "#{failure.label}:\n"
|
|
33
|
+
result += "#{failure.test_name}#{location_display}:\n"
|
|
34
|
+
result += failure.message
|
|
35
|
+
result
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def format_fault_error(error)
|
|
39
|
+
result = "#{error.label}:\n"
|
|
40
|
+
result += "#{error.test_name}:\n"
|
|
41
|
+
result += "#{error.message}\n"
|
|
42
|
+
result += error.backtrace.join("\n")
|
|
43
|
+
result
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require_relative 'testrunnerutilities'
|
|
2
|
+
|
|
3
|
+
module Test
|
|
4
|
+
module Unit
|
|
5
|
+
module UI
|
|
6
|
+
class TestRunner
|
|
7
|
+
extend TestRunnerUtilities
|
|
8
|
+
|
|
9
|
+
attr_reader :listeners
|
|
10
|
+
def initialize(suite, options={})
|
|
11
|
+
if suite.respond_to?(:suite)
|
|
12
|
+
@suite = suite.suite
|
|
13
|
+
else
|
|
14
|
+
@suite = suite
|
|
15
|
+
end
|
|
16
|
+
@options = options
|
|
17
|
+
@listeners = @options[:listeners] || []
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Begins the test run.
|
|
21
|
+
def start
|
|
22
|
+
setup_mediator
|
|
23
|
+
attach_to_mediator
|
|
24
|
+
attach_listeners
|
|
25
|
+
start_mediator
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
def setup_mediator
|
|
30
|
+
@mediator = TestRunnerMediator.new(@suite, @options)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def attach_listeners
|
|
34
|
+
@listeners.each do |listener|
|
|
35
|
+
listener.attach_to_mediator(@mediator)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def start_mediator
|
|
40
|
+
@mediator.run
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def diff_target_string?(string)
|
|
44
|
+
Assertions::AssertionMessage.diff_target_string?(string)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def prepare_for_diff(from, to)
|
|
48
|
+
Assertions::AssertionMessage.prepare_for_diff(from, to)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
#--
|
|
2
|
+
#
|
|
3
|
+
# Author:: Nathaniel Talbott.
|
|
4
|
+
# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
|
|
5
|
+
# License:: Ruby license.
|
|
6
|
+
|
|
7
|
+
require_relative '../util/observable'
|
|
8
|
+
require_relative '../testresult'
|
|
9
|
+
require_relative '../worker-context'
|
|
10
|
+
|
|
11
|
+
module Test
|
|
12
|
+
module Unit
|
|
13
|
+
module UI
|
|
14
|
+
|
|
15
|
+
# Provides an interface to write any given UI against,
|
|
16
|
+
# hopefully making it easy to write new UIs.
|
|
17
|
+
class TestRunnerMediator
|
|
18
|
+
RESET = name + "::RESET"
|
|
19
|
+
STARTED = name + "::STARTED"
|
|
20
|
+
FINISHED = name + "::FINISHED"
|
|
21
|
+
|
|
22
|
+
include Util::Observable
|
|
23
|
+
|
|
24
|
+
# Creates a new TestRunnerMediator initialized to run
|
|
25
|
+
# the passed suite.
|
|
26
|
+
def initialize(suite, options={})
|
|
27
|
+
@suite = suite
|
|
28
|
+
@options = options
|
|
29
|
+
@test_suite_runner_class = @options[:test_suite_runner_class]
|
|
30
|
+
@test_suite_runner_class ||= TestSuiteRunner
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Runs the suite the TestRunnerMediator was created
|
|
34
|
+
# with.
|
|
35
|
+
def run
|
|
36
|
+
AutoRunner.need_auto_run = false
|
|
37
|
+
|
|
38
|
+
result = create_result
|
|
39
|
+
options = @options.dup
|
|
40
|
+
# We should not keep @suite in @options because @options may
|
|
41
|
+
# be live longer than this instance. For example,
|
|
42
|
+
# AutoRunner's @runner_options is @options in this instance
|
|
43
|
+
# and AutoRunner is live longer than this instance. We can
|
|
44
|
+
# dup @options to avoid @suite's life time longer.
|
|
45
|
+
options[:test_suite] = @suite
|
|
46
|
+
options[:event_listener] = lambda do |channel, value|
|
|
47
|
+
notify_listeners(channel, value)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
Test::Unit.run_at_start_hooks
|
|
51
|
+
start_time = Time.now
|
|
52
|
+
begin
|
|
53
|
+
with_listener(result) do
|
|
54
|
+
@test_suite_runner_class.run_all_tests(result, options) do |run_context|
|
|
55
|
+
catch do |stop_tag|
|
|
56
|
+
result.stop_tag = stop_tag
|
|
57
|
+
notify_listeners(RESET, @suite.size)
|
|
58
|
+
notify_listeners(STARTED, result)
|
|
59
|
+
|
|
60
|
+
run_suite(result, run_context: run_context)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
ensure
|
|
65
|
+
elapsed_time = Time.now - start_time
|
|
66
|
+
notify_listeners(FINISHED, elapsed_time)
|
|
67
|
+
end
|
|
68
|
+
Test::Unit.run_at_exit_hooks
|
|
69
|
+
|
|
70
|
+
result
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Just for backward compatibility for NetBeans.
|
|
74
|
+
# NetBeans should not use monkey patching. NetBeans
|
|
75
|
+
# should use runner change public API.
|
|
76
|
+
#
|
|
77
|
+
# See GitHub#38
|
|
78
|
+
# https://github.com/test-unit/test-unit/issues/38
|
|
79
|
+
def run_suite(result=nil, run_context: nil)
|
|
80
|
+
if result.nil?
|
|
81
|
+
run
|
|
82
|
+
else
|
|
83
|
+
worker_context = WorkerContext.new(nil, run_context, result)
|
|
84
|
+
@suite.run(worker_context) do |channel, value|
|
|
85
|
+
notify_listeners(channel, value)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
private
|
|
91
|
+
# A factory method to create the result the mediator
|
|
92
|
+
# should run with. Can be overridden by subclasses if
|
|
93
|
+
# one wants to use a different result.
|
|
94
|
+
def create_result
|
|
95
|
+
TestResult.new
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def measure_time
|
|
99
|
+
begin_time = Time.now
|
|
100
|
+
yield
|
|
101
|
+
Time.now - begin_time
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def with_listener(result)
|
|
105
|
+
finished_listener = result.add_listener(TestResult::FINISHED) do |*args|
|
|
106
|
+
notify_listeners(TestResult::FINISHED, *args)
|
|
107
|
+
end
|
|
108
|
+
changed_listener = result.add_listener(TestResult::CHANGED) do |*args|
|
|
109
|
+
notify_listeners(TestResult::CHANGED, *args)
|
|
110
|
+
end
|
|
111
|
+
pass_assertion_listener = result.add_listener(TestResult::PASS_ASSERTION) do |*args|
|
|
112
|
+
notify_listeners(TestResult::PASS_ASSERTION, *args)
|
|
113
|
+
end
|
|
114
|
+
fault_listener = result.add_listener(TestResult::FAULT) do |*args|
|
|
115
|
+
notify_listeners(TestResult::FAULT, *args)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
begin
|
|
119
|
+
yield
|
|
120
|
+
ensure
|
|
121
|
+
result.remove_listener(TestResult::FAULT, fault_listener)
|
|
122
|
+
result.remove_listener(TestResult::CHANGED, changed_listener)
|
|
123
|
+
result.remove_listener(TestResult::FINISHED, finished_listener)
|
|
124
|
+
result.remove_listener(TestResult::PASS_ASSERTION,
|
|
125
|
+
pass_assertion_listener)
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#--
|
|
2
|
+
#
|
|
3
|
+
# Author:: Nathaniel Talbott.
|
|
4
|
+
# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
|
|
5
|
+
# License:: Ruby license.
|
|
6
|
+
|
|
7
|
+
module Test
|
|
8
|
+
module Unit
|
|
9
|
+
module UI
|
|
10
|
+
|
|
11
|
+
# Provides some utilities common to most, if not all,
|
|
12
|
+
# TestRunners.
|
|
13
|
+
#
|
|
14
|
+
#--
|
|
15
|
+
#
|
|
16
|
+
# Perhaps there ought to be a TestRunner superclass? There
|
|
17
|
+
# seems to be a decent amount of shared code between test
|
|
18
|
+
# runners.
|
|
19
|
+
|
|
20
|
+
module TestRunnerUtilities
|
|
21
|
+
|
|
22
|
+
# Creates a new TestRunner and runs the suite.
|
|
23
|
+
def run(suite, options={})
|
|
24
|
+
return new(suite, options).start
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Takes care of the ARGV parsing and suite
|
|
28
|
+
# determination necessary for running one of the
|
|
29
|
+
# TestRunners from the command line.
|
|
30
|
+
def start_command_line_test
|
|
31
|
+
if ARGV.empty?
|
|
32
|
+
puts "You should supply the name of a test suite file to the runner"
|
|
33
|
+
exit
|
|
34
|
+
end
|
|
35
|
+
require ARGV[0].gsub(/.+::/, '')
|
|
36
|
+
new(eval(ARGV[0])).start
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
#--
|
|
2
|
+
#
|
|
3
|
+
# Author:: Kouhei Sutou
|
|
4
|
+
# Copyright::
|
|
5
|
+
# * Copyright (c) 2011 Kouhei Sutou <kou@clear-code.com>
|
|
6
|
+
# License:: Ruby license.
|
|
7
|
+
|
|
8
|
+
require 'erb'
|
|
9
|
+
require 'time'
|
|
10
|
+
|
|
11
|
+
require_relative '../testrunner'
|
|
12
|
+
require_relative '../testrunnermediator'
|
|
13
|
+
|
|
14
|
+
module Test
|
|
15
|
+
module Unit
|
|
16
|
+
module UI
|
|
17
|
+
module XML
|
|
18
|
+
|
|
19
|
+
# Runs a Test::Unit::TestSuite and outputs XML.
|
|
20
|
+
class TestRunner < UI::TestRunner
|
|
21
|
+
include ERB::Util
|
|
22
|
+
|
|
23
|
+
# Creates a new TestRunner for running the passed
|
|
24
|
+
# suite. :output option specifies where runner
|
|
25
|
+
# output should go to; defaults to STDOUT.
|
|
26
|
+
def initialize(suite, options={})
|
|
27
|
+
super
|
|
28
|
+
@output = @options[:output] || STDOUT
|
|
29
|
+
if @options[:output_file_descriptor]
|
|
30
|
+
@output = IO.new(@options[:output_file_descriptor], "w")
|
|
31
|
+
end
|
|
32
|
+
@already_outputted = false
|
|
33
|
+
@indent = 0
|
|
34
|
+
@top_level = true
|
|
35
|
+
@current_test = nil
|
|
36
|
+
@current_test_suite = nil
|
|
37
|
+
@already_outputted = false
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
def attach_to_mediator
|
|
42
|
+
@mediator.add_listener(TestResult::PASS_ASSERTION,
|
|
43
|
+
&method(:result_pass_assertion))
|
|
44
|
+
@mediator.add_listener(TestResult::FAULT,
|
|
45
|
+
&method(:result_fault))
|
|
46
|
+
@mediator.add_listener(TestRunnerMediator::STARTED,
|
|
47
|
+
&method(:started))
|
|
48
|
+
@mediator.add_listener(TestRunnerMediator::FINISHED,
|
|
49
|
+
&method(:finished))
|
|
50
|
+
@mediator.add_listener(TestCase::STARTED_OBJECT,
|
|
51
|
+
&method(:test_started))
|
|
52
|
+
@mediator.add_listener(TestCase::FINISHED_OBJECT,
|
|
53
|
+
&method(:test_finished))
|
|
54
|
+
@mediator.add_listener(TestSuite::STARTED_OBJECT,
|
|
55
|
+
&method(:test_suite_started))
|
|
56
|
+
@mediator.add_listener(TestSuite::FINISHED_OBJECT,
|
|
57
|
+
&method(:test_suite_finished))
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def result_pass_assertion(result)
|
|
61
|
+
open_tag("pass-assertion") do
|
|
62
|
+
output_test(@current_test)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def result_fault(fault)
|
|
67
|
+
open_tag("test-result") do
|
|
68
|
+
open_tag("result") do
|
|
69
|
+
output_test_suite(@current_test_suite)
|
|
70
|
+
output_test(@current_test)
|
|
71
|
+
open_tag("backtrace") do
|
|
72
|
+
fault.location.each do |entry|
|
|
73
|
+
file, line, info = entry.split(/:/, 3)
|
|
74
|
+
open_tag("entry") do
|
|
75
|
+
add_content("file", file)
|
|
76
|
+
add_content("line", line)
|
|
77
|
+
add_content("info", info)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
if fault.respond_to?(:expected)
|
|
82
|
+
add_content("expected", fault.expected)
|
|
83
|
+
end
|
|
84
|
+
if fault.respond_to?(:actual)
|
|
85
|
+
add_content("actual", fault.actual)
|
|
86
|
+
end
|
|
87
|
+
add_content("detail", fault.message)
|
|
88
|
+
add_content("status", fault.label.downcase)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
@already_outputted = true if fault.critical?
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def started(result)
|
|
95
|
+
@result = result
|
|
96
|
+
output_started
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def output_started
|
|
100
|
+
open_tag("stream")
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def finished(elapsed_time)
|
|
104
|
+
add_content("success", @result.passed?)
|
|
105
|
+
close_tag("stream")
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def test_started(test)
|
|
109
|
+
@already_outputted = false
|
|
110
|
+
@current_test = test
|
|
111
|
+
open_tag("start-test") do
|
|
112
|
+
output_test(test)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def test_finished(test)
|
|
117
|
+
unless @already_outputted
|
|
118
|
+
open_tag("test-result") do
|
|
119
|
+
output_test(test)
|
|
120
|
+
open_tag("result") do
|
|
121
|
+
output_test_suite(@current_test_suite)
|
|
122
|
+
output_test(test)
|
|
123
|
+
add_content("status", "success")
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
open_tag("complete-test") do
|
|
129
|
+
output_test(test)
|
|
130
|
+
add_content("success", test.passed?)
|
|
131
|
+
end
|
|
132
|
+
@current_test = nil
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def test_suite_started(suite)
|
|
136
|
+
@current_test_suite = suite
|
|
137
|
+
if suite.test_case.nil?
|
|
138
|
+
open_tag("ready-test-suite") do
|
|
139
|
+
add_content("n-tests", suite.size)
|
|
140
|
+
end
|
|
141
|
+
open_tag("start-test-suite") do
|
|
142
|
+
output_test_suite(suite)
|
|
143
|
+
end
|
|
144
|
+
else
|
|
145
|
+
open_tag("ready-test-case") do
|
|
146
|
+
output_test_suite(suite)
|
|
147
|
+
add_content("n-tests", suite.size)
|
|
148
|
+
end
|
|
149
|
+
open_tag("start-test-case") do
|
|
150
|
+
output_test_suite(suite)
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def test_suite_finished(suite)
|
|
156
|
+
if suite.test_case.nil?
|
|
157
|
+
open_tag("complete-test-suite") do
|
|
158
|
+
output_test_suite(suite)
|
|
159
|
+
add_content("success", suite.passed?)
|
|
160
|
+
end
|
|
161
|
+
else
|
|
162
|
+
open_tag("complete-test-case") do
|
|
163
|
+
output_test_suite(suite)
|
|
164
|
+
add_content("success", suite.passed?)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
@current_test_suite = nil
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def indent
|
|
171
|
+
" " * @indent
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def open_tag(name)
|
|
175
|
+
@output.puts("#{indent}<#{name}>")
|
|
176
|
+
@indent += 2
|
|
177
|
+
if block_given?
|
|
178
|
+
yield
|
|
179
|
+
close_tag(name)
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def add_content(name, content)
|
|
184
|
+
return if content.nil?
|
|
185
|
+
case content
|
|
186
|
+
when Time
|
|
187
|
+
content = content.iso8601
|
|
188
|
+
end
|
|
189
|
+
@output.puts("#{indent}<#{name}>#{h(content)}</#{name}>")
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def close_tag(name)
|
|
193
|
+
@indent -= 2
|
|
194
|
+
@output.puts("#{indent}</#{name}>")
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def output_test(test)
|
|
198
|
+
open_tag("test") do
|
|
199
|
+
add_content("name", test.method_name)
|
|
200
|
+
add_content("start-time", test.start_time)
|
|
201
|
+
add_content("elapsed", test.elapsed_time)
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
def output_test_suite(test_suite)
|
|
206
|
+
test_case = test_suite.test_case
|
|
207
|
+
if test_case.nil?
|
|
208
|
+
open_tag("test-suite") do
|
|
209
|
+
add_content("name", test_suite.name)
|
|
210
|
+
add_content("start-time", test_suite.start_time)
|
|
211
|
+
add_content("elapsed", test_suite.elapsed_time)
|
|
212
|
+
end
|
|
213
|
+
else
|
|
214
|
+
open_tag("test-case") do
|
|
215
|
+
add_content("name", test_suite.name)
|
|
216
|
+
add_content("start-time", test_suite.start_time)
|
|
217
|
+
add_content("elapsed", test_suite.elapsed_time)
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
begin
|
|
2
|
+
$VERBOSE, verbose = nil, $VERBOSE
|
|
3
|
+
require 'power_assert'
|
|
4
|
+
rescue LoadError, SyntaxError
|
|
5
|
+
if defined?(::PowerAssert)
|
|
6
|
+
::Object.send(:remove_const, :PowerAssert)
|
|
7
|
+
end
|
|
8
|
+
ensure
|
|
9
|
+
$VERBOSE = verbose
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
module Test
|
|
13
|
+
module Unit
|
|
14
|
+
module Util
|
|
15
|
+
module BacktraceFilter
|
|
16
|
+
TESTUNIT_FILE_SEPARATORS = %r{[\\/:]}
|
|
17
|
+
TESTUNIT_PREFIX = __FILE__.split(TESTUNIT_FILE_SEPARATORS)[0..-3]
|
|
18
|
+
TESTUNIT_RB_FILE = /\.rb\Z/
|
|
19
|
+
|
|
20
|
+
POWERASSERT_PREFIX =
|
|
21
|
+
defined?(::PowerAssert) ?
|
|
22
|
+
::PowerAssert.method(:start).source_location[0].split(TESTUNIT_FILE_SEPARATORS)[0..-2] :
|
|
23
|
+
nil
|
|
24
|
+
|
|
25
|
+
module_function
|
|
26
|
+
def filter_backtrace(backtrace, prefix=nil)
|
|
27
|
+
return ["No backtrace"] unless backtrace
|
|
28
|
+
return backtrace if ENV["TEST_UNIT_ALL_BACKTRACE"]
|
|
29
|
+
|
|
30
|
+
if prefix
|
|
31
|
+
split_prefixes = [prefix.split(TESTUNIT_FILE_SEPARATORS)]
|
|
32
|
+
else
|
|
33
|
+
split_prefixes = [TESTUNIT_PREFIX, POWERASSERT_PREFIX].compact
|
|
34
|
+
end
|
|
35
|
+
test_unit_internal_p = lambda do |entry|
|
|
36
|
+
components = entry.split(TESTUNIT_FILE_SEPARATORS)
|
|
37
|
+
split_prefixes.any? do |split_prefix|
|
|
38
|
+
split_entry = components[0, split_prefix.size]
|
|
39
|
+
next false unless split_entry[0..-2] == split_prefix[0..-2]
|
|
40
|
+
split_entry[-1].sub(TESTUNIT_RB_FILE, '') == split_prefix[-1]
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
in_user_code = false
|
|
45
|
+
new_backtrace = backtrace.reverse.reject do |entry|
|
|
46
|
+
if test_unit_internal_p.call(entry)
|
|
47
|
+
in_user_code = true
|
|
48
|
+
true
|
|
49
|
+
else
|
|
50
|
+
not in_user_code
|
|
51
|
+
end
|
|
52
|
+
end.reverse
|
|
53
|
+
|
|
54
|
+
if new_backtrace.empty?
|
|
55
|
+
new_backtrace = backtrace.reject do |entry|
|
|
56
|
+
test_unit_internal_p.call(entry)
|
|
57
|
+
end
|
|
58
|
+
new_backtrace = backtrace if new_backtrace.empty?
|
|
59
|
+
end
|
|
60
|
+
new_backtrace
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
module Test
|
|
2
|
+
module Unit
|
|
3
|
+
module Util
|
|
4
|
+
class MemoryUsage
|
|
5
|
+
attr_reader :virtual
|
|
6
|
+
attr_reader :physical
|
|
7
|
+
def initialize
|
|
8
|
+
@virtual = nil
|
|
9
|
+
@physical = nil
|
|
10
|
+
collect_data
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def collected?
|
|
14
|
+
return false if @virtual.nil?
|
|
15
|
+
return false if @physical.nil?
|
|
16
|
+
true
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
def collect_data
|
|
21
|
+
collect_data_proc
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def collect_data_proc
|
|
25
|
+
status_file = "/proc/self/status"
|
|
26
|
+
return false unless File.exist?(status_file)
|
|
27
|
+
|
|
28
|
+
data = File.binread(status_file)
|
|
29
|
+
data.each_line do |line|
|
|
30
|
+
case line
|
|
31
|
+
when /\AVm(Size|RSS):\s*(\d+)\s*kB/
|
|
32
|
+
name = $1
|
|
33
|
+
value = Integer($2, 10) * 1024
|
|
34
|
+
case name
|
|
35
|
+
when "Size"
|
|
36
|
+
@virtual = value
|
|
37
|
+
when "RSS"
|
|
38
|
+
@physical = value
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
collected?
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Test
|
|
2
|
+
module Unit
|
|
3
|
+
module Util
|
|
4
|
+
module MethodOwnerFinder
|
|
5
|
+
module_function
|
|
6
|
+
def find(object, method_name)
|
|
7
|
+
method = object.method(method_name)
|
|
8
|
+
return method.owner if method.respond_to?(:owner)
|
|
9
|
+
|
|
10
|
+
if /\((.+?)\)\#/ =~ method.to_s
|
|
11
|
+
owner_name = $1
|
|
12
|
+
if /\A#</ =~ owner_name
|
|
13
|
+
ObjectSpace.each_object(Module) do |mod|
|
|
14
|
+
return mod if mod.to_s == owner_name
|
|
15
|
+
end
|
|
16
|
+
else
|
|
17
|
+
owner_name.split(/::/).inject(Object) do |parent, name|
|
|
18
|
+
parent.const_get(name)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
else
|
|
22
|
+
object.class
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|