groonga 0.9.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- metadata +38 -227
- data/AUTHORS +0 -5
- data/NEWS.ja.rdoc +0 -114
- data/NEWS.rdoc +0 -116
- data/README.ja.rdoc +0 -63
- data/README.rdoc +0 -64
- data/Rakefile +0 -216
- data/benchmark/common.rb +0 -49
- data/benchmark/read-write-many-small-items.rb +0 -144
- data/benchmark/write-many-small-items.rb +0 -135
- data/example/bookmark.rb +0 -161
- data/example/index-html.rb +0 -89
- data/example/search/config.ru +0 -211
- data/example/search/public/css/groonga.css +0 -122
- data/ext/.gitignore +0 -2
- data/ext/rb-grn-accessor.c +0 -52
- data/ext/rb-grn-array-cursor.c +0 -36
- data/ext/rb-grn-array.c +0 -210
- data/ext/rb-grn-column.c +0 -570
- data/ext/rb-grn-context.c +0 -655
- data/ext/rb-grn-database.c +0 -415
- data/ext/rb-grn-encoding-support.c +0 -64
- data/ext/rb-grn-encoding.c +0 -257
- data/ext/rb-grn-exception.c +0 -1110
- data/ext/rb-grn-expression-builder.c +0 -75
- data/ext/rb-grn-expression.c +0 -732
- data/ext/rb-grn-fix-size-column.c +0 -166
- data/ext/rb-grn-hash-cursor.c +0 -38
- data/ext/rb-grn-hash.c +0 -294
- data/ext/rb-grn-index-column.c +0 -488
- data/ext/rb-grn-logger.c +0 -325
- data/ext/rb-grn-object.c +0 -1335
- data/ext/rb-grn-operation.c +0 -198
- data/ext/rb-grn-patricia-trie-cursor.c +0 -39
- data/ext/rb-grn-patricia-trie.c +0 -488
- data/ext/rb-grn-procedure.c +0 -52
- data/ext/rb-grn-query.c +0 -260
- data/ext/rb-grn-record.c +0 -40
- data/ext/rb-grn-snippet.c +0 -328
- data/ext/rb-grn-table-cursor-key-support.c +0 -69
- data/ext/rb-grn-table-cursor.c +0 -246
- data/ext/rb-grn-table-key-support.c +0 -731
- data/ext/rb-grn-table.c +0 -2038
- data/ext/rb-grn-type.c +0 -181
- data/ext/rb-grn-utils.c +0 -769
- data/ext/rb-grn-variable-size-column.c +0 -36
- data/ext/rb-grn-variable.c +0 -108
- data/ext/rb-grn.h +0 -684
- data/ext/rb-groonga.c +0 -113
- data/extconf.rb +0 -216
- data/html/bar.svg +0 -153
- data/html/developer.html +0 -121
- data/html/developer.svg +0 -469
- data/html/download.svg +0 -253
- data/html/favicon.ico +0 -0
- data/html/favicon.xcf +0 -0
- data/html/footer.html.erb +0 -28
- data/html/head.html.erb +0 -4
- data/html/header.html.erb +0 -17
- data/html/index.html +0 -147
- data/html/install.svg +0 -636
- data/html/logo.xcf +0 -0
- data/html/ranguba.css +0 -248
- data/html/tutorial.svg +0 -559
- data/lib/groonga.rb +0 -83
- data/lib/groonga/expression-builder.rb +0 -285
- data/lib/groonga/patricia-trie.rb +0 -53
- data/lib/groonga/record.rb +0 -276
- data/lib/groonga/schema.rb +0 -916
- data/license/GPL +0 -340
- data/license/LGPL +0 -504
- data/license/RUBY +0 -59
- data/misc/grnop2ruby.rb +0 -49
- data/pkg-config.rb +0 -333
- data/src/rb-grn-table-cursor.c +0 -296
- data/test-unit/Rakefile +0 -40
- data/test-unit/TODO +0 -5
- data/test-unit/bin/testrb +0 -5
- data/test-unit/html/classic.html +0 -15
- data/test-unit/html/index.html +0 -25
- data/test-unit/html/index.html.ja +0 -27
- data/test-unit/lib/test/unit.rb +0 -323
- data/test-unit/lib/test/unit/assertionfailederror.rb +0 -25
- data/test-unit/lib/test/unit/assertions.rb +0 -1230
- data/test-unit/lib/test/unit/attribute.rb +0 -125
- data/test-unit/lib/test/unit/autorunner.rb +0 -353
- data/test-unit/lib/test/unit/collector.rb +0 -36
- data/test-unit/lib/test/unit/collector/descendant.rb +0 -23
- data/test-unit/lib/test/unit/collector/dir.rb +0 -108
- data/test-unit/lib/test/unit/collector/load.rb +0 -136
- data/test-unit/lib/test/unit/collector/objectspace.rb +0 -34
- data/test-unit/lib/test/unit/color-scheme.rb +0 -102
- data/test-unit/lib/test/unit/color.rb +0 -96
- data/test-unit/lib/test/unit/diff.rb +0 -724
- data/test-unit/lib/test/unit/error.rb +0 -130
- data/test-unit/lib/test/unit/exceptionhandler.rb +0 -39
- data/test-unit/lib/test/unit/failure.rb +0 -136
- data/test-unit/lib/test/unit/fixture.rb +0 -176
- data/test-unit/lib/test/unit/notification.rb +0 -129
- data/test-unit/lib/test/unit/omission.rb +0 -191
- data/test-unit/lib/test/unit/pending.rb +0 -150
- data/test-unit/lib/test/unit/priority.rb +0 -181
- data/test-unit/lib/test/unit/runner/console.rb +0 -52
- data/test-unit/lib/test/unit/runner/emacs.rb +0 -8
- data/test-unit/lib/test/unit/runner/tap.rb +0 -8
- data/test-unit/lib/test/unit/testcase.rb +0 -476
- data/test-unit/lib/test/unit/testresult.rb +0 -89
- data/test-unit/lib/test/unit/testsuite.rb +0 -110
- data/test-unit/lib/test/unit/ui/console/outputlevel.rb +0 -14
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +0 -464
- data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +0 -63
- data/test-unit/lib/test/unit/ui/tap/testrunner.rb +0 -92
- data/test-unit/lib/test/unit/ui/testrunner.rb +0 -28
- data/test-unit/lib/test/unit/ui/testrunnermediator.rb +0 -77
- data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +0 -41
- data/test-unit/lib/test/unit/util/backtracefilter.rb +0 -41
- data/test-unit/lib/test/unit/util/method-owner-finder.rb +0 -28
- data/test-unit/lib/test/unit/util/observable.rb +0 -90
- data/test-unit/lib/test/unit/util/procwrapper.rb +0 -48
- data/test-unit/lib/test/unit/version.rb +0 -7
- data/test-unit/sample/adder.rb +0 -13
- data/test-unit/sample/subtracter.rb +0 -12
- data/test-unit/sample/test_adder.rb +0 -20
- data/test-unit/sample/test_subtracter.rb +0 -20
- data/test-unit/sample/test_user.rb +0 -23
- data/test-unit/test/collector/test-descendant.rb +0 -133
- data/test-unit/test/collector/test-load.rb +0 -329
- data/test-unit/test/collector/test_dir.rb +0 -406
- data/test-unit/test/collector/test_objectspace.rb +0 -100
- data/test-unit/test/run-test.rb +0 -15
- data/test-unit/test/test-attribute.rb +0 -86
- data/test-unit/test/test-color-scheme.rb +0 -67
- data/test-unit/test/test-color.rb +0 -47
- data/test-unit/test/test-diff.rb +0 -518
- data/test-unit/test/test-emacs-runner.rb +0 -60
- data/test-unit/test/test-fixture.rb +0 -287
- data/test-unit/test/test-notification.rb +0 -33
- data/test-unit/test/test-omission.rb +0 -81
- data/test-unit/test/test-pending.rb +0 -70
- data/test-unit/test/test-priority.rb +0 -119
- data/test-unit/test/test-testcase.rb +0 -554
- data/test-unit/test/test_assertions.rb +0 -1151
- data/test-unit/test/test_error.rb +0 -26
- data/test-unit/test/test_failure.rb +0 -33
- data/test-unit/test/test_testresult.rb +0 -113
- data/test-unit/test/test_testsuite.rb +0 -129
- data/test-unit/test/testunit-test-util.rb +0 -14
- data/test-unit/test/ui/test_testrunmediator.rb +0 -20
- data/test-unit/test/util/test-method-owner-finder.rb +0 -38
- data/test-unit/test/util/test_backtracefilter.rb +0 -41
- data/test-unit/test/util/test_observable.rb +0 -102
- data/test-unit/test/util/test_procwrapper.rb +0 -36
- data/test/.gitignore +0 -1
- data/test/groonga-test-utils.rb +0 -106
- data/test/run-test.rb +0 -58
- data/test/test-array.rb +0 -97
- data/test/test-column.rb +0 -298
- data/test/test-context.rb +0 -73
- data/test/test-database.rb +0 -113
- data/test/test-encoding.rb +0 -33
- data/test/test-exception.rb +0 -93
- data/test/test-expression-builder.rb +0 -156
- data/test/test-expression.rb +0 -133
- data/test/test-fix-size-column.rb +0 -65
- data/test/test-gqtp.rb +0 -70
- data/test/test-hash.rb +0 -312
- data/test/test-index-column.rb +0 -81
- data/test/test-patricia-trie.rb +0 -189
- data/test/test-procedure.rb +0 -37
- data/test/test-query.rb +0 -22
- data/test/test-record.rb +0 -268
- data/test/test-remote.rb +0 -53
- data/test/test-schema.rb +0 -416
- data/test/test-snippet.rb +0 -121
- data/test/test-table-cursor.rb +0 -153
- data/test/test-table-offset-and-limit.rb +0 -102
- data/test/test-table-select-normalize.rb +0 -48
- data/test/test-table-select.rb +0 -145
- data/test/test-table.rb +0 -642
- data/test/test-type.rb +0 -61
- data/test/test-variable-size-column.rb +0 -98
- data/test/test-variable.rb +0 -28
- data/test/test-vector-column.rb +0 -76
- data/test/test-version.rb +0 -31
- data/text/TUTORIAL.ja.rdoc +0 -392
- data/text/expression.rdoc +0 -284
@@ -1,89 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Author:: Nathaniel Talbott.
|
3
|
-
# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
|
4
|
-
# License:: Ruby license.
|
5
|
-
|
6
|
-
require 'test/unit/util/observable'
|
7
|
-
require 'test/unit/failure'
|
8
|
-
require 'test/unit/error'
|
9
|
-
require 'test/unit/omission'
|
10
|
-
require 'test/unit/pending'
|
11
|
-
require 'test/unit/notification'
|
12
|
-
|
13
|
-
module Test
|
14
|
-
module Unit
|
15
|
-
module NullResultContainerInitializer
|
16
|
-
private
|
17
|
-
def initialize_containers
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# Collects Test::Unit::Failure and Test::Unit::Error so that
|
22
|
-
# they can be displayed to the user. To this end, observers
|
23
|
-
# can be added to it, allowing the dynamic updating of, say, a
|
24
|
-
# UI.
|
25
|
-
class TestResult
|
26
|
-
include Util::Observable
|
27
|
-
include NullResultContainerInitializer
|
28
|
-
include TestResultFailureSupport
|
29
|
-
include TestResultErrorSupport
|
30
|
-
include TestResultPendingSupport
|
31
|
-
include TestResultOmissionSupport
|
32
|
-
include TestResultNotificationSupport
|
33
|
-
|
34
|
-
CHANGED = "CHANGED"
|
35
|
-
FAULT = "FAULT"
|
36
|
-
|
37
|
-
attr_reader :run_count, :assertion_count, :faults
|
38
|
-
|
39
|
-
# Constructs a new, empty TestResult.
|
40
|
-
def initialize
|
41
|
-
@run_count, @assertion_count = 0, 0
|
42
|
-
@summary_generators = []
|
43
|
-
@problem_checkers = []
|
44
|
-
@faults = []
|
45
|
-
initialize_containers
|
46
|
-
end
|
47
|
-
|
48
|
-
# Records a test run.
|
49
|
-
def add_run
|
50
|
-
@run_count += 1
|
51
|
-
notify_changed
|
52
|
-
end
|
53
|
-
|
54
|
-
# Records an individual assertion.
|
55
|
-
def add_assertion
|
56
|
-
@assertion_count += 1
|
57
|
-
notify_changed
|
58
|
-
end
|
59
|
-
|
60
|
-
# Returns a string contain the recorded runs, assertions,
|
61
|
-
# failures and errors in this TestResult.
|
62
|
-
def summary
|
63
|
-
["#{run_count} tests",
|
64
|
-
"#{assertion_count} assertions",
|
65
|
-
*@summary_generators.collect {|generator| send(generator)}].join(", ")
|
66
|
-
end
|
67
|
-
|
68
|
-
def to_s
|
69
|
-
summary
|
70
|
-
end
|
71
|
-
|
72
|
-
# Returns whether or not this TestResult represents
|
73
|
-
# successful completion.
|
74
|
-
def passed?
|
75
|
-
@problem_checkers.all? {|checker| not send(checker)}
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
79
|
-
def notify_changed
|
80
|
-
notify_listeners(CHANGED, self)
|
81
|
-
end
|
82
|
-
|
83
|
-
def notify_fault(fault)
|
84
|
-
@faults << fault
|
85
|
-
notify_listeners(FAULT, fault)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,110 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
#
|
3
|
-
# Author:: Nathaniel Talbott.
|
4
|
-
# Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
|
5
|
-
# License:: Ruby license.
|
6
|
-
|
7
|
-
require 'test/unit/error'
|
8
|
-
|
9
|
-
module Test
|
10
|
-
module Unit
|
11
|
-
|
12
|
-
# A collection of tests which can be #run.
|
13
|
-
#
|
14
|
-
# Note: It is easy to confuse a TestSuite instance with
|
15
|
-
# something that has a static suite method; I know because _I_
|
16
|
-
# have trouble keeping them straight. Think of something that
|
17
|
-
# has a suite method as simply providing a way to get a
|
18
|
-
# meaningful TestSuite instance.
|
19
|
-
class TestSuite
|
20
|
-
attr_reader :name, :tests
|
21
|
-
|
22
|
-
STARTED = name + "::STARTED"
|
23
|
-
FINISHED = name + "::FINISHED"
|
24
|
-
|
25
|
-
# Creates a new TestSuite with the given name.
|
26
|
-
def initialize(name="Unnamed TestSuite", test_case=nil)
|
27
|
-
@name = name
|
28
|
-
@tests = []
|
29
|
-
@test_case = test_case
|
30
|
-
end
|
31
|
-
|
32
|
-
# Runs the tests and/or suites contained in this
|
33
|
-
# TestSuite.
|
34
|
-
def run(result, &progress_block)
|
35
|
-
yield(STARTED, name)
|
36
|
-
run_startup(result)
|
37
|
-
@tests.each do |test|
|
38
|
-
test.run(result, &progress_block)
|
39
|
-
end
|
40
|
-
run_shutdown(result)
|
41
|
-
yield(FINISHED, name)
|
42
|
-
end
|
43
|
-
|
44
|
-
# Adds the test to the suite.
|
45
|
-
def <<(test)
|
46
|
-
@tests << test
|
47
|
-
self
|
48
|
-
end
|
49
|
-
|
50
|
-
def delete(test)
|
51
|
-
@tests.delete(test)
|
52
|
-
end
|
53
|
-
|
54
|
-
# Retuns the rolled up number of tests in this suite;
|
55
|
-
# i.e. if the suite contains other suites, it counts the
|
56
|
-
# tests within those suites, not the suites themselves.
|
57
|
-
def size
|
58
|
-
total_size = 0
|
59
|
-
@tests.each { |test| total_size += test.size }
|
60
|
-
total_size
|
61
|
-
end
|
62
|
-
|
63
|
-
def empty?
|
64
|
-
tests.empty?
|
65
|
-
end
|
66
|
-
|
67
|
-
# Overridden to return the name given the suite at
|
68
|
-
# creation.
|
69
|
-
def to_s
|
70
|
-
@name
|
71
|
-
end
|
72
|
-
|
73
|
-
# It's handy to be able to compare TestSuite instances.
|
74
|
-
def ==(other)
|
75
|
-
return false unless(other.kind_of?(self.class))
|
76
|
-
return false unless(@name == other.name)
|
77
|
-
@tests == other.tests
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
def run_startup(result)
|
82
|
-
return if @test_case.nil? or !@test_case.respond_to?(:startup)
|
83
|
-
begin
|
84
|
-
@test_case.startup
|
85
|
-
rescue Exception
|
86
|
-
raise unless handle_exception($!, result)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def run_shutdown(result)
|
91
|
-
return if @test_case.nil? or !@test_case.respond_to?(:shutdown)
|
92
|
-
begin
|
93
|
-
@test_case.shutdown
|
94
|
-
rescue Exception
|
95
|
-
raise unless handle_exception($!, result)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def handle_exception(exception, result)
|
100
|
-
case exception
|
101
|
-
when *ErrorHandler::PASS_THROUGH_EXCEPTIONS
|
102
|
-
false
|
103
|
-
else
|
104
|
-
result.add_error(Error.new(@test_case.name, exception))
|
105
|
-
true
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
@@ -1,464 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
#
|
3
|
-
# Author:: Nathaniel Talbott.
|
4
|
-
# Copyright::
|
5
|
-
# * Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
|
6
|
-
# * Copyright (c) 2008-2009 Kouhei Sutou <kou@clear-code.com>
|
7
|
-
# License:: Ruby license.
|
8
|
-
|
9
|
-
require 'test/unit/color-scheme'
|
10
|
-
require 'test/unit/ui/testrunner'
|
11
|
-
require 'test/unit/ui/testrunnermediator'
|
12
|
-
require 'test/unit/ui/console/outputlevel'
|
13
|
-
|
14
|
-
module Test
|
15
|
-
module Unit
|
16
|
-
module UI
|
17
|
-
module Console
|
18
|
-
|
19
|
-
# Runs a Test::Unit::TestSuite on the console.
|
20
|
-
class TestRunner < UI::TestRunner
|
21
|
-
include OutputLevel
|
22
|
-
|
23
|
-
# Creates a new TestRunner for running the passed
|
24
|
-
# suite. If quiet_mode is true, the output while
|
25
|
-
# running is limited to progress dots, errors and
|
26
|
-
# failures, and the final result. io specifies
|
27
|
-
# where runner output should go to; defaults to
|
28
|
-
# STDOUT.
|
29
|
-
def initialize(suite, options={})
|
30
|
-
super
|
31
|
-
@output_level = @options[:output_level] || NORMAL
|
32
|
-
@output = @options[:output] || STDOUT
|
33
|
-
@use_color = @options[:use_color]
|
34
|
-
@use_color = guess_color_availability if @use_color.nil?
|
35
|
-
@color_scheme = @options[:color_scheme] || ColorScheme.default
|
36
|
-
@reset_color = Color.new("reset")
|
37
|
-
@progress_row = 0
|
38
|
-
@progress_row_max = @options[:progress_row_max]
|
39
|
-
@progress_row_max ||= guess_progress_row_max
|
40
|
-
@already_outputted = false
|
41
|
-
@n_successes = 0
|
42
|
-
@indent = 0
|
43
|
-
@top_level = true
|
44
|
-
@faults = []
|
45
|
-
end
|
46
|
-
|
47
|
-
# Begins the test run.
|
48
|
-
def start
|
49
|
-
setup_mediator
|
50
|
-
attach_to_mediator
|
51
|
-
return start_mediator
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
def setup_mediator
|
56
|
-
@mediator = create_mediator(@suite)
|
57
|
-
output_setup_end
|
58
|
-
end
|
59
|
-
|
60
|
-
def output_setup_end
|
61
|
-
suite_name = @suite.to_s
|
62
|
-
suite_name = @suite.name if @suite.kind_of?(Module)
|
63
|
-
output("Loaded suite #{suite_name}")
|
64
|
-
end
|
65
|
-
|
66
|
-
def create_mediator(suite)
|
67
|
-
return TestRunnerMediator.new(suite)
|
68
|
-
end
|
69
|
-
|
70
|
-
def attach_to_mediator
|
71
|
-
@mediator.add_listener(TestResult::FAULT, &method(:add_fault))
|
72
|
-
@mediator.add_listener(TestRunnerMediator::STARTED, &method(:started))
|
73
|
-
@mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished))
|
74
|
-
@mediator.add_listener(TestCase::STARTED, &method(:test_started))
|
75
|
-
@mediator.add_listener(TestCase::FINISHED, &method(:test_finished))
|
76
|
-
@mediator.add_listener(TestSuite::STARTED, &method(:test_suite_started))
|
77
|
-
@mediator.add_listener(TestSuite::FINISHED, &method(:test_suite_finished))
|
78
|
-
end
|
79
|
-
|
80
|
-
def start_mediator
|
81
|
-
return @mediator.run_suite
|
82
|
-
end
|
83
|
-
|
84
|
-
def add_fault(fault)
|
85
|
-
@faults << fault
|
86
|
-
output_progress(fault.single_character_display, fault_color(fault))
|
87
|
-
@already_outputted = true if fault.critical?
|
88
|
-
end
|
89
|
-
|
90
|
-
def started(result)
|
91
|
-
@result = result
|
92
|
-
output_started
|
93
|
-
end
|
94
|
-
|
95
|
-
def output_started
|
96
|
-
output("Started")
|
97
|
-
end
|
98
|
-
|
99
|
-
def finished(elapsed_time)
|
100
|
-
nl if output?(NORMAL) and !output?(VERBOSE)
|
101
|
-
@faults.each_with_index do |fault, index|
|
102
|
-
nl
|
103
|
-
output_single("%3d) " % (index + 1))
|
104
|
-
output_fault(fault)
|
105
|
-
end
|
106
|
-
nl
|
107
|
-
output("Finished in #{elapsed_time} seconds.")
|
108
|
-
nl
|
109
|
-
output(@result, result_color)
|
110
|
-
n_tests = @result.run_count
|
111
|
-
if n_tests.zero?
|
112
|
-
pass_percentage = 0
|
113
|
-
else
|
114
|
-
pass_percentage = 100.0 * (@n_successes / n_tests.to_f)
|
115
|
-
end
|
116
|
-
output("%g%% passed" % pass_percentage, result_color)
|
117
|
-
end
|
118
|
-
|
119
|
-
def output_fault(fault)
|
120
|
-
if @use_color and fault.is_a?(Failure) and
|
121
|
-
fault.inspected_expected and fault.inspected_actual
|
122
|
-
output_single(fault.label, fault_color(fault))
|
123
|
-
output(":")
|
124
|
-
output_fault_backtrace(fault)
|
125
|
-
output_fault_message(fault)
|
126
|
-
else
|
127
|
-
label, detail = format_fault(fault).split(/\r?\n/, 2)
|
128
|
-
output(label, fault_color(fault))
|
129
|
-
output(detail)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
def output_fault_backtrace(fault)
|
134
|
-
backtrace = fault.location
|
135
|
-
if backtrace.size == 1
|
136
|
-
output(fault.test_name +
|
137
|
-
backtrace[0].sub(/\A(.+:\d+).*/, ' [\\1]') +
|
138
|
-
":")
|
139
|
-
else
|
140
|
-
output(fault.test_name)
|
141
|
-
backtrace.each_with_index do |entry, i|
|
142
|
-
if i.zero?
|
143
|
-
prefix = "["
|
144
|
-
postfix = ""
|
145
|
-
elsif i == backtrace.size - 1
|
146
|
-
prefix = " "
|
147
|
-
postfix = "]:"
|
148
|
-
else
|
149
|
-
prefix = " "
|
150
|
-
postfix = ""
|
151
|
-
end
|
152
|
-
output(" #{prefix}#{entry}#{postfix}")
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def output_fault_message(fault)
|
158
|
-
output(fault.user_message) if fault.user_message
|
159
|
-
output_single("<")
|
160
|
-
output_single(fault.inspected_expected, color("success"))
|
161
|
-
output("> expected but was")
|
162
|
-
output_single("<")
|
163
|
-
output_single(fault.inspected_actual, color("failure"))
|
164
|
-
output(">")
|
165
|
-
from, to = prepare_for_diff(fault.expected, fault.actual)
|
166
|
-
if from and to
|
167
|
-
differ = ColorizedReadableDiffer.new(from.split(/\r?\n/),
|
168
|
-
to.split(/\r?\n/),
|
169
|
-
self)
|
170
|
-
if differ.need_diff?
|
171
|
-
output("")
|
172
|
-
output("diff:")
|
173
|
-
differ.diff
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
def format_fault(fault)
|
179
|
-
fault.long_display
|
180
|
-
end
|
181
|
-
|
182
|
-
def test_started(name)
|
183
|
-
return unless output?(VERBOSE)
|
184
|
-
|
185
|
-
name = name.sub(/\(.+?\)\z/, '')
|
186
|
-
right_space = 8 * 2
|
187
|
-
left_space = @progress_row_max - right_space
|
188
|
-
left_space = left_space - indent.size - name.size
|
189
|
-
tab_stop = "\t" * ((left_space - 1) / 8)
|
190
|
-
output_single("#{indent}#{name}:#{tab_stop}", nil, VERBOSE)
|
191
|
-
@test_start = Time.now
|
192
|
-
end
|
193
|
-
|
194
|
-
def test_finished(name)
|
195
|
-
unless @already_outputted
|
196
|
-
@n_successes += 1
|
197
|
-
output_progress(".", color("success"))
|
198
|
-
end
|
199
|
-
@already_outputted = false
|
200
|
-
|
201
|
-
return unless output?(VERBOSE)
|
202
|
-
|
203
|
-
output(": (%f)" % (Time.now - @test_start), nil, VERBOSE)
|
204
|
-
end
|
205
|
-
|
206
|
-
def test_suite_started(name)
|
207
|
-
if @top_level
|
208
|
-
@top_level = false
|
209
|
-
return
|
210
|
-
end
|
211
|
-
|
212
|
-
output_single(indent, nil, VERBOSE)
|
213
|
-
if /\A[A-Z]/ =~ name
|
214
|
-
_color = color("case")
|
215
|
-
else
|
216
|
-
_color = color("suite")
|
217
|
-
end
|
218
|
-
output_single(name, _color, VERBOSE)
|
219
|
-
output(": ", nil, VERBOSE)
|
220
|
-
@indent += 2
|
221
|
-
end
|
222
|
-
|
223
|
-
def test_suite_finished(name)
|
224
|
-
@indent -= 2
|
225
|
-
end
|
226
|
-
|
227
|
-
def indent
|
228
|
-
if output?(VERBOSE)
|
229
|
-
" " * @indent
|
230
|
-
else
|
231
|
-
""
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
def nl(level=NORMAL)
|
236
|
-
output("", nil, level)
|
237
|
-
end
|
238
|
-
|
239
|
-
def output(something, color=nil, level=NORMAL)
|
240
|
-
return unless output?(level)
|
241
|
-
output_single(something, color, level)
|
242
|
-
@output.puts
|
243
|
-
end
|
244
|
-
|
245
|
-
def output_single(something, color=nil, level=NORMAL)
|
246
|
-
return false unless output?(level)
|
247
|
-
if @use_color and color
|
248
|
-
something = "%s%s%s" % [color.escape_sequence,
|
249
|
-
something,
|
250
|
-
@reset_color.escape_sequence]
|
251
|
-
end
|
252
|
-
@output.write(something)
|
253
|
-
@output.flush
|
254
|
-
true
|
255
|
-
end
|
256
|
-
|
257
|
-
def output_progress(mark, color=nil)
|
258
|
-
if output_single(mark, color, PROGRESS_ONLY)
|
259
|
-
return unless @progress_row_max > 0
|
260
|
-
@progress_row += mark.size
|
261
|
-
if @progress_row >= @progress_row_max
|
262
|
-
nl unless @output_level == VERBOSE
|
263
|
-
@progress_row = 0
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
|
-
def output?(level)
|
269
|
-
level <= @output_level
|
270
|
-
end
|
271
|
-
|
272
|
-
def color(name)
|
273
|
-
@color_scheme[name] || ColorScheme.default[name]
|
274
|
-
end
|
275
|
-
|
276
|
-
def fault_color(fault)
|
277
|
-
color(fault.class.name.split(/::/).last.downcase)
|
278
|
-
end
|
279
|
-
|
280
|
-
def result_color
|
281
|
-
if @result.passed?
|
282
|
-
if @result.pending_count > 0
|
283
|
-
color("pending")
|
284
|
-
elsif @result.omission_count > 0
|
285
|
-
color("omission")
|
286
|
-
elsif @result.notification_count > 0
|
287
|
-
color("notification")
|
288
|
-
else
|
289
|
-
color("success")
|
290
|
-
end
|
291
|
-
elsif @result.error_count > 0
|
292
|
-
color("error")
|
293
|
-
elsif @result.failure_count > 0
|
294
|
-
color("failure")
|
295
|
-
end
|
296
|
-
end
|
297
|
-
|
298
|
-
def guess_color_availability
|
299
|
-
return false unless @output.tty?
|
300
|
-
case ENV["TERM"]
|
301
|
-
when /term(?:-color)?\z/, "screen"
|
302
|
-
true
|
303
|
-
else
|
304
|
-
return true if ENV["EMACS"] == "t"
|
305
|
-
false
|
306
|
-
end
|
307
|
-
end
|
308
|
-
|
309
|
-
def guess_progress_row_max
|
310
|
-
term_width = guess_term_width
|
311
|
-
if term_width.zero?
|
312
|
-
if ENV["EMACS"] == "t"
|
313
|
-
-1
|
314
|
-
else
|
315
|
-
79
|
316
|
-
end
|
317
|
-
else
|
318
|
-
term_width
|
319
|
-
end
|
320
|
-
end
|
321
|
-
|
322
|
-
def guess_term_width
|
323
|
-
Integer(ENV["TERM_WIDTH"] || 0)
|
324
|
-
rescue ArgumentError
|
325
|
-
0
|
326
|
-
end
|
327
|
-
end
|
328
|
-
|
329
|
-
class ColorizedReadableDiffer < Diff::ReadableDiffer
|
330
|
-
def initialize(from, to, runner)
|
331
|
-
@runner = runner
|
332
|
-
super(from, to)
|
333
|
-
end
|
334
|
-
|
335
|
-
def need_diff?(options={})
|
336
|
-
operations.each do |tag,|
|
337
|
-
return true if [:replace, :equal].include?(tag)
|
338
|
-
end
|
339
|
-
false
|
340
|
-
end
|
341
|
-
|
342
|
-
private
|
343
|
-
def output_single(something, color=nil)
|
344
|
-
@runner.send(:output_single, something, color)
|
345
|
-
end
|
346
|
-
|
347
|
-
def output(something, color=nil)
|
348
|
-
@runner.send(:output, something, color)
|
349
|
-
end
|
350
|
-
|
351
|
-
def color(name)
|
352
|
-
@runner.send(:color, name)
|
353
|
-
end
|
354
|
-
|
355
|
-
def cut_off_ratio
|
356
|
-
0
|
357
|
-
end
|
358
|
-
|
359
|
-
def default_ratio
|
360
|
-
0
|
361
|
-
end
|
362
|
-
|
363
|
-
def tag(mark, color_name, contents)
|
364
|
-
_color = color(color_name)
|
365
|
-
contents.each do |content|
|
366
|
-
output_single(mark, _color)
|
367
|
-
output_single(" ")
|
368
|
-
output(content)
|
369
|
-
end
|
370
|
-
end
|
371
|
-
|
372
|
-
def tag_deleted(contents)
|
373
|
-
tag("-", "diff-deleted-tag", contents)
|
374
|
-
end
|
375
|
-
|
376
|
-
def tag_inserted(contents)
|
377
|
-
tag("+", "diff-inserted-tag", contents)
|
378
|
-
end
|
379
|
-
|
380
|
-
def tag_equal(contents)
|
381
|
-
tag(" ", "normal", contents)
|
382
|
-
end
|
383
|
-
|
384
|
-
def tag_difference(contents)
|
385
|
-
tag("?", "diff-difference-tag", contents)
|
386
|
-
end
|
387
|
-
|
388
|
-
def diff_line(from_line, to_line)
|
389
|
-
to_operations = []
|
390
|
-
from_line, to_line, _operations = line_operations(from_line, to_line)
|
391
|
-
|
392
|
-
no_replace = true
|
393
|
-
_operations.each do |tag,|
|
394
|
-
if tag == :replace
|
395
|
-
no_replace = false
|
396
|
-
break
|
397
|
-
end
|
398
|
-
end
|
399
|
-
|
400
|
-
output_single("?", color("diff-difference-tag"))
|
401
|
-
output_single(" ")
|
402
|
-
_operations.each do |tag, from_start, from_end, to_start, to_end|
|
403
|
-
from_width = compute_width(from_line, from_start, from_end)
|
404
|
-
to_width = compute_width(to_line, to_start, to_end)
|
405
|
-
case tag
|
406
|
-
when :replace
|
407
|
-
output_single(from_line[from_start...from_end],
|
408
|
-
color("diff-deleted"))
|
409
|
-
if (from_width < to_width)
|
410
|
-
output_single(" " * (to_width - from_width))
|
411
|
-
end
|
412
|
-
to_operations << Proc.new do
|
413
|
-
output_single(to_line[to_start...to_end],
|
414
|
-
color("diff-inserted"))
|
415
|
-
if (to_width < from_width)
|
416
|
-
output_single(" " * (from_width - to_width))
|
417
|
-
end
|
418
|
-
end
|
419
|
-
when :delete
|
420
|
-
output_single(from_line[from_start...from_end],
|
421
|
-
color("diff-deleted"))
|
422
|
-
unless no_replace
|
423
|
-
to_operations << Proc.new {output_single(" " * from_width)}
|
424
|
-
end
|
425
|
-
when :insert
|
426
|
-
if no_replace
|
427
|
-
output_single(to_line[to_start...to_end],
|
428
|
-
color("diff-inserted"))
|
429
|
-
else
|
430
|
-
output_single(" " * to_width)
|
431
|
-
to_operations << Proc.new do
|
432
|
-
output_single(to_line[to_start...to_end],
|
433
|
-
color("diff-inserted"))
|
434
|
-
end
|
435
|
-
end
|
436
|
-
when :equal
|
437
|
-
output_single(from_line[from_start...from_end])
|
438
|
-
unless no_replace
|
439
|
-
to_operations << Proc.new {output_single(" " * to_width)}
|
440
|
-
end
|
441
|
-
else
|
442
|
-
raise "unknown tag: #{tag}"
|
443
|
-
end
|
444
|
-
end
|
445
|
-
output("")
|
446
|
-
|
447
|
-
unless to_operations.empty?
|
448
|
-
output_single("?", color("diff-difference-tag"))
|
449
|
-
output_single(" ")
|
450
|
-
to_operations.each do |operation|
|
451
|
-
operation.call
|
452
|
-
end
|
453
|
-
output("")
|
454
|
-
end
|
455
|
-
end
|
456
|
-
end
|
457
|
-
end
|
458
|
-
end
|
459
|
-
end
|
460
|
-
end
|
461
|
-
|
462
|
-
if __FILE__ == $0
|
463
|
-
Test::Unit::UI::Console::TestRunner.start_command_line_test
|
464
|
-
end
|