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,48 +0,0 @@
|
|
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 Util
|
10
|
-
|
11
|
-
# Allows the storage of a Proc passed through '&' in a
|
12
|
-
# hash.
|
13
|
-
#
|
14
|
-
# Note: this may be inefficient, since the hash being
|
15
|
-
# used is not necessarily very good. In Observable,
|
16
|
-
# efficiency is not too important, since the hash is
|
17
|
-
# only accessed when adding and removing listeners,
|
18
|
-
# not when notifying.
|
19
|
-
|
20
|
-
class ProcWrapper
|
21
|
-
|
22
|
-
# Creates a new wrapper for a_proc.
|
23
|
-
def initialize(a_proc)
|
24
|
-
@a_proc = a_proc
|
25
|
-
@hash = a_proc.inspect.sub(/^(#<#{a_proc.class}:)/){''}.sub(/(>)$/){''}.hex
|
26
|
-
end
|
27
|
-
|
28
|
-
def hash
|
29
|
-
return @hash
|
30
|
-
end
|
31
|
-
|
32
|
-
def ==(other)
|
33
|
-
case(other)
|
34
|
-
when ProcWrapper
|
35
|
-
return @a_proc == other.to_proc
|
36
|
-
else
|
37
|
-
return super
|
38
|
-
end
|
39
|
-
end
|
40
|
-
alias :eql? :==
|
41
|
-
|
42
|
-
def to_proc
|
43
|
-
return @a_proc
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
data/test-unit/sample/adder.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# Author:: Nathaniel Talbott.
|
2
|
-
# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
|
3
|
-
# License:: Ruby license.
|
4
|
-
|
5
|
-
class Adder
|
6
|
-
def initialize(number)
|
7
|
-
@number = number
|
8
|
-
end
|
9
|
-
def add(number)
|
10
|
-
return @number + number
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# Author:: Nathaniel Talbott.
|
2
|
-
# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
|
3
|
-
# License:: Ruby license.
|
4
|
-
|
5
|
-
class Subtracter
|
6
|
-
def initialize(number)
|
7
|
-
@number = number
|
8
|
-
end
|
9
|
-
def subtract(number)
|
10
|
-
return @number - number
|
11
|
-
end
|
12
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# Author:: Nathaniel Talbott.
|
2
|
-
# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
|
3
|
-
# License:: Ruby license.
|
4
|
-
|
5
|
-
require 'test/unit'
|
6
|
-
require 'adder'
|
7
|
-
|
8
|
-
class TestAdder < Test::Unit::TestCase
|
9
|
-
def setup
|
10
|
-
@adder = Adder.new(5)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_add
|
14
|
-
assert_equal(7, @adder.add(2), "Should have added correctly")
|
15
|
-
end
|
16
|
-
|
17
|
-
def teardown
|
18
|
-
@adder = nil
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# Author:: Nathaniel Talbott.
|
2
|
-
# Copyright:: Copyright (c) 2000-2002 Nathaniel Talbott. All rights reserved.
|
3
|
-
# License:: Ruby license.
|
4
|
-
|
5
|
-
require 'test/unit'
|
6
|
-
require 'subtracter'
|
7
|
-
|
8
|
-
class TestSubtracter < Test::Unit::TestCase
|
9
|
-
def setup
|
10
|
-
@subtracter = Subtracter.new(5)
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_subtract
|
14
|
-
assert_equal(3, @subtracter.subtract(2), "Should have subtracted correctly")
|
15
|
-
end
|
16
|
-
|
17
|
-
def teardown
|
18
|
-
@subtracter = nil
|
19
|
-
end
|
20
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# nested test case example.
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
class UserTest < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@user = "me"
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_full_name
|
10
|
-
assert_equal("me", @user)
|
11
|
-
end
|
12
|
-
|
13
|
-
class ProfileTest < UserTest
|
14
|
-
setup
|
15
|
-
def setup_profile
|
16
|
-
@user += ": profile"
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_has_profile
|
20
|
-
assert_match(/: profile/, @user)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,133 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'test/unit/collector/descendant'
|
3
|
-
|
4
|
-
class TestUnitCollectorDescendant < Test::Unit::TestCase
|
5
|
-
def setup
|
6
|
-
@previous_descendants = Test::Unit::TestCase::DESCENDANTS.dup
|
7
|
-
Test::Unit::TestCase::DESCENDANTS.clear
|
8
|
-
|
9
|
-
@test_case1 = Class.new(Test::Unit::TestCase) do
|
10
|
-
def self.name
|
11
|
-
"test-case1"
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_1
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_2
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
@test_case2 = Class.new(Test::Unit::TestCase) do
|
22
|
-
def self.name
|
23
|
-
"test-case2"
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_0
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
@no_test_case = Class.new do
|
31
|
-
def self.name
|
32
|
-
"no-test-case"
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_4
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def teardown
|
41
|
-
Test::Unit::TestCase::DESCENDANTS.replace(@previous_descendants)
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_basic_collection
|
45
|
-
assert_collect(full_suite("name"), "name")
|
46
|
-
|
47
|
-
assert_collect(full_suite("name"), "name") do |collector|
|
48
|
-
collector.filter = []
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_filtered_collection
|
53
|
-
assert_collect(empty_suite) do |collector|
|
54
|
-
collector.filter = Proc.new {false}
|
55
|
-
end
|
56
|
-
|
57
|
-
assert_collect(full_suite) do |collector|
|
58
|
-
collector.filter = Proc.new {true}
|
59
|
-
end
|
60
|
-
|
61
|
-
assert_collect(full_suite) do |collector|
|
62
|
-
collector.filter = Proc.new {nil}
|
63
|
-
end
|
64
|
-
|
65
|
-
assert_collect(empty_suite) do |collector|
|
66
|
-
collector.filter = [Proc.new {false}, Proc.new {true}]
|
67
|
-
end
|
68
|
-
|
69
|
-
assert_collect(empty_suite) do |collector|
|
70
|
-
collector.filter = [Proc.new {true}, Proc.new {false}]
|
71
|
-
end
|
72
|
-
|
73
|
-
assert_collect(empty_suite) do |collector|
|
74
|
-
collector.filter = [Proc.new {nil}, Proc.new {false}]
|
75
|
-
end
|
76
|
-
|
77
|
-
assert_collect(full_suite) do |collector|
|
78
|
-
collector.filter = [Proc.new {nil}, Proc.new {true}]
|
79
|
-
end
|
80
|
-
|
81
|
-
expected = empty_suite
|
82
|
-
suite1 = Test::Unit::TestSuite.new(@test_case1.name)
|
83
|
-
suite1 << @test_case1.new("test_1")
|
84
|
-
suite2 = Test::Unit::TestSuite.new(@test_case2.name)
|
85
|
-
suite2 << @test_case2.new("test_0")
|
86
|
-
expected << suite1 << suite2
|
87
|
-
assert_collect(expected) do |collector|
|
88
|
-
collector.filter = Proc.new do |test|
|
89
|
-
['test_1', 'test_0'].include?(test.method_name)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
suite1 = Test::Unit::TestSuite.new(@test_case1.name)
|
94
|
-
suite1 << @test_case1.new("test_1")
|
95
|
-
suite2 = Test::Unit::TestSuite.new(@test_case2.name)
|
96
|
-
suite2 << @test_case2.new("test_0")
|
97
|
-
assert_collect(empty_suite) do |collector|
|
98
|
-
filters = [Proc.new {|test| test.method_name == 'test_1' ? true : nil},
|
99
|
-
Proc.new {|test| test.method_name == 'test_0' ? true : nil},
|
100
|
-
Proc.new {false}]
|
101
|
-
collector.filter = filters
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
private
|
106
|
-
def assert_collect(expected, *collect_args)
|
107
|
-
collector = Test::Unit::Collector::Descendant.new
|
108
|
-
yield(collector) if block_given?
|
109
|
-
assert_equal(expected, collector.send(:collect, *collect_args))
|
110
|
-
end
|
111
|
-
|
112
|
-
def default_name
|
113
|
-
Test::Unit::Collector::Descendant::NAME
|
114
|
-
end
|
115
|
-
|
116
|
-
def empty_suite(name=nil)
|
117
|
-
Test::Unit::TestSuite.new(name || default_name)
|
118
|
-
end
|
119
|
-
|
120
|
-
def full_suite(name=nil)
|
121
|
-
sub_suite1 = Test::Unit::TestSuite.new(@test_case1.name)
|
122
|
-
sub_suite1 << @test_case1.new('test_1')
|
123
|
-
sub_suite1 << @test_case1.new('test_2')
|
124
|
-
|
125
|
-
sub_suite2 = Test::Unit::TestSuite.new(@test_case2.name)
|
126
|
-
sub_suite2 << @test_case2.new('test_0')
|
127
|
-
|
128
|
-
suite = empty_suite(name)
|
129
|
-
suite << sub_suite1
|
130
|
-
suite << sub_suite2
|
131
|
-
suite
|
132
|
-
end
|
133
|
-
end
|
@@ -1,329 +0,0 @@
|
|
1
|
-
require 'tmpdir'
|
2
|
-
require 'pathname'
|
3
|
-
|
4
|
-
require 'test/unit'
|
5
|
-
require 'test/unit/collector/load'
|
6
|
-
|
7
|
-
class TestUnitCollectorLoad < Test::Unit::TestCase
|
8
|
-
def setup
|
9
|
-
@previous_descendants = Test::Unit::TestCase::DESCENDANTS.dup
|
10
|
-
Test::Unit::TestCase::DESCENDANTS.clear
|
11
|
-
|
12
|
-
@temporary_test_cases_module_name = "TempTestCases"
|
13
|
-
::Object.const_set(@temporary_test_cases_module_name, Module.new)
|
14
|
-
|
15
|
-
@test_dir = Pathname(Dir.tmpdir) + "test-unit"
|
16
|
-
@test_dir.rmtree if @test_dir.exist?
|
17
|
-
@test_dir.mkpath
|
18
|
-
end
|
19
|
-
|
20
|
-
setup
|
21
|
-
def setup_top_level_test_cases
|
22
|
-
@test_case1 = @test_dir + "test_case1.rb"
|
23
|
-
@test_case2 = @test_dir + "test_case2.rb"
|
24
|
-
@no_load_test_case3 = @test_dir + "case3.rb"
|
25
|
-
|
26
|
-
@test_case1.open("w") do |test_case|
|
27
|
-
test_case.puts(<<-EOT)
|
28
|
-
module #{@temporary_test_cases_module_name}
|
29
|
-
class TestCase1 < Test::Unit::TestCase
|
30
|
-
def test1_1
|
31
|
-
end
|
32
|
-
|
33
|
-
def test1_2
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
EOT
|
38
|
-
end
|
39
|
-
|
40
|
-
@test_case2.open("w") do |test_case|
|
41
|
-
test_case.puts(<<-EOT)
|
42
|
-
module #{@temporary_test_cases_module_name}
|
43
|
-
class TestCase2 < Test::Unit::TestCase
|
44
|
-
def test2
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
EOT
|
49
|
-
end
|
50
|
-
|
51
|
-
@no_load_test_case3.open("w") do |test_case|
|
52
|
-
test_case.puts(<<-EOT)
|
53
|
-
module #{@temporary_test_cases_module_name}
|
54
|
-
class NoLoadTestCase3 < Test::Unit::TestCase
|
55
|
-
def test3
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
EOT
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
setup
|
64
|
-
def setup_sub_level_test_cases
|
65
|
-
@sub_test_dir = @test_dir + "sub"
|
66
|
-
@sub_test_dir.mkpath
|
67
|
-
|
68
|
-
@sub_test_case4 = @sub_test_dir + "test_case4.rb"
|
69
|
-
@no_load_sub_test_case5 = @sub_test_dir + "case5.rb"
|
70
|
-
@sub_test_case6 = @sub_test_dir + "test_case6.rb"
|
71
|
-
|
72
|
-
@sub_test_case4.open("w") do |test_case|
|
73
|
-
test_case.puts(<<-EOT)
|
74
|
-
module #{@temporary_test_cases_module_name}
|
75
|
-
class SubTestCase4 < Test::Unit::TestCase
|
76
|
-
def test4_1
|
77
|
-
end
|
78
|
-
|
79
|
-
def test4_2
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
EOT
|
84
|
-
end
|
85
|
-
|
86
|
-
@no_load_sub_test_case5.open("w") do |test_case|
|
87
|
-
test_case.puts(<<-EOT)
|
88
|
-
module #{@temporary_test_cases_module_name}
|
89
|
-
class NoLoadSubTestCase5 < Test::Unit::TestCase
|
90
|
-
def test5_1
|
91
|
-
end
|
92
|
-
|
93
|
-
def test5_2
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
EOT
|
98
|
-
end
|
99
|
-
|
100
|
-
@sub_test_case6.open("w") do |test_case|
|
101
|
-
test_case.puts(<<-EOT)
|
102
|
-
module #{@temporary_test_cases_module_name}
|
103
|
-
class SubTestCase6 < Test::Unit::TestCase
|
104
|
-
def test6
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
EOT
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
setup
|
113
|
-
def setup_sub_level_test_cases2
|
114
|
-
@sub2_test_dir = @test_dir + "sub2"
|
115
|
-
@sub2_test_dir.mkpath
|
116
|
-
|
117
|
-
@no_load_sub2_test_case7 = @sub2_test_dir + "case7.rb"
|
118
|
-
@sub2_test_case8 = @sub2_test_dir + "test_case8.rb"
|
119
|
-
@sub2_test_case9 = @sub2_test_dir + "test_case9.rb"
|
120
|
-
|
121
|
-
@no_load_sub2_test_case7.open("w") do |test_case|
|
122
|
-
test_case.puts(<<-EOT)
|
123
|
-
module #{@temporary_test_cases_module_name}
|
124
|
-
class NoLoadSub2TestCase7 < Test::Unit::TestCase
|
125
|
-
def test7_1
|
126
|
-
end
|
127
|
-
|
128
|
-
def test7_2
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
EOT
|
133
|
-
end
|
134
|
-
|
135
|
-
@sub2_test_case8.open("w") do |test_case|
|
136
|
-
test_case.puts(<<-EOT)
|
137
|
-
module #{@temporary_test_cases_module_name}
|
138
|
-
class Sub2TestCase8 < Test::Unit::TestCase
|
139
|
-
def test8_1
|
140
|
-
end
|
141
|
-
|
142
|
-
def test8_2
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
EOT
|
147
|
-
end
|
148
|
-
|
149
|
-
@sub2_test_case9.open("w") do |test_case|
|
150
|
-
test_case.puts(<<-EOT)
|
151
|
-
module #{@temporary_test_cases_module_name}
|
152
|
-
class Sub2TestCase9 < Test::Unit::TestCase
|
153
|
-
def test9
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
EOT
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
setup
|
162
|
-
def setup_svn_test_cases
|
163
|
-
@svn_test_dir = @test_dir + ".svn"
|
164
|
-
@svn_test_dir.mkpath
|
165
|
-
|
166
|
-
@svn_test_case10 = @svn_test_dir + "test_case10.rb"
|
167
|
-
|
168
|
-
@svn_test_case10.open("w") do |test_case|
|
169
|
-
test_case.puts(<<-EOT)
|
170
|
-
module #{@temporary_test_cases_module_name}
|
171
|
-
class SvnTestCase10 < Test::Unit::TestCase
|
172
|
-
def test7
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
EOT
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
setup
|
181
|
-
def setup_sub_cvs_test_cases
|
182
|
-
@sub_cvs_test_dir = @sub_test_dir + "CVS"
|
183
|
-
@sub_cvs_test_dir.mkpath
|
184
|
-
|
185
|
-
@sub_cvs_test_case11 = @sub_cvs_test_dir + "test_case11.rb"
|
186
|
-
|
187
|
-
@sub_cvs_test_case11.open("w") do |test_case|
|
188
|
-
test_case.puts(<<-EOT)
|
189
|
-
module #{@temporary_test_cases_module_name}
|
190
|
-
class SubCVSTestCase11 < Test::Unit::TestCase
|
191
|
-
def test11
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
EOT
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
def teardown
|
200
|
-
@test_dir.rmtree if @test_dir.exist?
|
201
|
-
::Object.send(:remove_const, @temporary_test_cases_module_name)
|
202
|
-
Test::Unit::TestCase::DESCENDANTS.replace(@previous_descendants)
|
203
|
-
end
|
204
|
-
|
205
|
-
def test_simple_collect
|
206
|
-
assert_collect([:suite, {:name => @sub_test_dir.basename.to_s},
|
207
|
-
[:suite, {:name => _test_case_name("SubTestCase4")},
|
208
|
-
[:test, {:name => "test4_1"}],
|
209
|
-
[:test, {:name => "test4_2"}]],
|
210
|
-
[:suite, {:name => _test_case_name("SubTestCase6")},
|
211
|
-
[:test, {:name => "test6"}]]],
|
212
|
-
@sub_test_dir.to_s)
|
213
|
-
end
|
214
|
-
|
215
|
-
def test_multilevel_collect
|
216
|
-
assert_collect([:suite, {:name => "."},
|
217
|
-
[:suite, {:name => _test_case_name("TestCase1")},
|
218
|
-
[:test, {:name => "test1_1"}],
|
219
|
-
[:test, {:name => "test1_2"}]],
|
220
|
-
[:suite, {:name => _test_case_name("TestCase2")},
|
221
|
-
[:test, {:name => "test2"}]],
|
222
|
-
[:suite, {:name => @sub_test_dir.basename.to_s},
|
223
|
-
[:suite, {:name => _test_case_name("SubTestCase4")},
|
224
|
-
[:test, {:name => "test4_1"}],
|
225
|
-
[:test, {:name => "test4_2"}]],
|
226
|
-
[:suite, {:name => _test_case_name("SubTestCase6")},
|
227
|
-
[:test, {:name => "test6"}]]],
|
228
|
-
[:suite, {:name => @sub2_test_dir.basename.to_s},
|
229
|
-
[:suite, {:name => _test_case_name("Sub2TestCase8")},
|
230
|
-
[:test, {:name => "test8_1"}],
|
231
|
-
[:test, {:name => "test8_2"}]],
|
232
|
-
[:suite, {:name => _test_case_name("Sub2TestCase9")},
|
233
|
-
[:test, {:name => "test9"}]]]])
|
234
|
-
end
|
235
|
-
|
236
|
-
def test_collect_file
|
237
|
-
assert_collect([:suite, {:name => @test_case1.basename.to_s},
|
238
|
-
[:suite, {:name => _test_case_name("TestCase1")},
|
239
|
-
[:test, {:name => "test1_1"}],
|
240
|
-
[:test, {:name => "test1_2"}]]],
|
241
|
-
@test_case1.to_s)
|
242
|
-
|
243
|
-
assert_collect(nil, @no_load_sub_test_case5.to_s)
|
244
|
-
end
|
245
|
-
|
246
|
-
def test_nil_pattern
|
247
|
-
assert_collect([:suite, {:name => @sub_test_dir.basename.to_s},
|
248
|
-
[:suite, {:name => _test_case_name("NoLoadSubTestCase5")},
|
249
|
-
[:test, {:name => "test5_1"}],
|
250
|
-
[:test, {:name => "test5_2"}]],
|
251
|
-
[:suite, {:name => _test_case_name("SubTestCase4")},
|
252
|
-
[:test, {:name => "test4_1"}],
|
253
|
-
[:test, {:name => "test4_2"}]],
|
254
|
-
[:suite, {:name => _test_case_name("SubTestCase6")},
|
255
|
-
[:test, {:name => "test6"}]]],
|
256
|
-
@sub_test_dir.to_s) do |collector|
|
257
|
-
collector.patterns.clear
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
def test_filtering
|
262
|
-
assert_collect([:suite, {:name => "."},
|
263
|
-
[:suite, {:name => _test_case_name("TestCase1")},
|
264
|
-
[:test, {:name => "test1_1"}],
|
265
|
-
[:test, {:name => "test1_2"}]]]) do |collector|
|
266
|
-
collector.filter = Proc.new do |test|
|
267
|
-
!/\Atest1/.match(test.method_name).nil?
|
268
|
-
end
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
def test_collect_multi
|
273
|
-
test_dirs = [@sub_test_dir.to_s, @sub2_test_dir.to_s]
|
274
|
-
assert_collect([:suite, {:name => "[#{test_dirs.join(', ')}]"},
|
275
|
-
[:suite, {:name => @sub_test_dir.basename.to_s},
|
276
|
-
[:suite, {:name => _test_case_name("SubTestCase4")},
|
277
|
-
[:test, {:name => "test4_1"}],
|
278
|
-
[:test, {:name => "test4_2"}]],
|
279
|
-
[:suite, {:name => _test_case_name("SubTestCase6")},
|
280
|
-
[:test, {:name => "test6"}]]],
|
281
|
-
[:suite, {:name => @sub2_test_dir.basename.to_s},
|
282
|
-
[:suite, {:name => _test_case_name("Sub2TestCase8")},
|
283
|
-
[:test, {:name => "test8_1"}],
|
284
|
-
[:test, {:name => "test8_2"}]],
|
285
|
-
[:suite, {:name => _test_case_name("Sub2TestCase9")},
|
286
|
-
[:test, {:name => "test9"}]]]],
|
287
|
-
*test_dirs)
|
288
|
-
end
|
289
|
-
|
290
|
-
private
|
291
|
-
def assert_collect(expected, *collect_args)
|
292
|
-
keep_required_files do
|
293
|
-
Dir.chdir(@test_dir.to_s) do
|
294
|
-
collector = Test::Unit::Collector::Load.new
|
295
|
-
yield(collector) if block_given?
|
296
|
-
actual = inspect_test_object(collector.send(:collect, *collect_args))
|
297
|
-
assert_equal(expected, actual)
|
298
|
-
end
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
def keep_required_files
|
303
|
-
required_files = $".dup
|
304
|
-
yield
|
305
|
-
ensure
|
306
|
-
$".replace(required_files)
|
307
|
-
end
|
308
|
-
|
309
|
-
def _test_case_name(test_case_class_name)
|
310
|
-
"#{@temporary_test_cases_module_name}::#{test_case_class_name}"
|
311
|
-
end
|
312
|
-
|
313
|
-
def inspect_test_object(test_object)
|
314
|
-
return nil if test_object.nil?
|
315
|
-
case test_object
|
316
|
-
when Test::Unit::TestSuite
|
317
|
-
sub_tests = test_object.tests.collect do |test|
|
318
|
-
inspect_test_object(test)
|
319
|
-
end.sort_by do |type, attributes, *children|
|
320
|
-
attributes[:name]
|
321
|
-
end
|
322
|
-
[:suite, {:name => test_object.name}, *sub_tests]
|
323
|
-
when Test::Unit::TestCase
|
324
|
-
[:test, {:name => test_object.method_name}]
|
325
|
-
else
|
326
|
-
raise "unexpected test object: #{test_object.inspect}"
|
327
|
-
end
|
328
|
-
end
|
329
|
-
end
|