rroonga 9.0.3 → 11.0.0
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 +4 -4
- data/.yardopts +1 -0
- data/Rakefile +26 -135
- data/doc/text/news.md +79 -1
- data/doc/text/tutorial.md +1 -1
- data/ext/groonga/extconf.rb +19 -74
- data/ext/groonga/rb-grn-accessor.c +2 -2
- data/ext/groonga/rb-grn-column-cache.c +3 -3
- data/ext/groonga/rb-grn-column.c +4 -4
- data/ext/groonga/rb-grn-context.c +109 -58
- data/ext/groonga/rb-grn-data-column.c +4 -4
- data/ext/groonga/rb-grn-database.c +45 -26
- data/ext/groonga/rb-grn-double-array-trie.c +2 -2
- data/ext/groonga/rb-grn-encoding-support.c +2 -2
- data/ext/groonga/rb-grn-exception.c +14 -0
- data/ext/groonga/rb-grn-expression-builder.c +3 -3
- data/ext/groonga/rb-grn-expression.c +3 -3
- data/ext/groonga/rb-grn-fix-size-column.c +2 -2
- data/ext/groonga/rb-grn-flushable.c +9 -1
- data/ext/groonga/rb-grn-hash.c +2 -2
- data/ext/groonga/rb-grn-index-column.c +30 -2
- data/ext/groonga/rb-grn-index-cursor.c +21 -2
- data/ext/groonga/rb-grn-inverted-index-cursor.c +3 -3
- data/ext/groonga/rb-grn-logger.c +17 -3
- data/ext/groonga/rb-grn-object.c +266 -31
- data/ext/groonga/rb-grn-operator.c +100 -259
- data/ext/groonga/rb-grn-patricia-trie.c +2 -2
- data/ext/groonga/rb-grn-plugin.c +34 -22
- data/ext/groonga/rb-grn-request-timer-id.c +2 -2
- data/ext/groonga/rb-grn-snippet.c +3 -3
- data/ext/groonga/rb-grn-table-cursor-key-support.c +2 -2
- data/ext/groonga/rb-grn-table-cursor.c +3 -3
- data/ext/groonga/rb-grn-table-key-support.c +28 -9
- data/ext/groonga/rb-grn-table.c +180 -130
- data/ext/groonga/rb-grn-type.c +5 -1
- data/ext/groonga/rb-grn-utils.c +17 -1
- data/ext/groonga/rb-grn-variable-size-column.c +2 -2
- data/ext/groonga/rb-grn-variable.c +2 -2
- data/ext/groonga/rb-grn.h +11 -14
- data/ext/groonga/rb-groonga.c +6 -2
- data/lib/groonga.rb +3 -7
- data/lib/groonga/context.rb +32 -0
- data/lib/groonga/dumper.rb +3 -0
- data/lib/groonga/record.rb +2 -2
- data/rroonga-build.rb +5 -4
- data/rroonga.gemspec +8 -6
- data/test/groonga-test-utils.rb +37 -5
- data/test/run-test.rb +1 -3
- data/test/test-accessor.rb +63 -7
- data/test/test-column.rb +12 -1
- data/test/test-context.rb +25 -0
- data/test/test-exception.rb +5 -0
- data/test/test-flushable.rb +51 -6
- data/test/test-index-column.rb +70 -9
- data/test/test-index-cursor.rb +26 -0
- data/test/test-logger.rb +56 -11
- data/test/test-plugin.rb +1 -0
- data/test/test-query-logger.rb +4 -3
- data/test/test-ractor.rb +65 -0
- data/test/test-record.rb +2 -1
- data/test/test-remote.rb +58 -10
- data/test/test-schema-dumper.rb +13 -0
- data/test/test-schema.rb +9 -1
- data/test/test-table-arrow.rb +22 -10
- data/test/test-table.rb +21 -1
- data/test/test-variable.rb +23 -7
- metadata +72 -97
data/test/run-test.rb
CHANGED
@@ -17,8 +17,6 @@
|
|
17
17
|
|
18
18
|
$VERBOSE = true
|
19
19
|
|
20
|
-
$KCODE = "u" if RUBY_VERSION < "1.9"
|
21
|
-
|
22
20
|
base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
23
21
|
ext_dir = File.join(base_dir, "ext", "groonga")
|
24
22
|
lib_dir = File.join(base_dir, "lib")
|
@@ -39,7 +37,7 @@ end
|
|
39
37
|
require "test-unit"
|
40
38
|
require "test/unit/priority"
|
41
39
|
|
42
|
-
Test::Unit::Priority.enable
|
40
|
+
Test::Unit::Priority.enable unless ENV["CI"]
|
43
41
|
|
44
42
|
|
45
43
|
groonga_command_dir = File.join(base_dir, "..", "groonga-command")
|
data/test/test-accessor.rb
CHANGED
@@ -19,12 +19,13 @@ class AccessorTest < Test::Unit::TestCase
|
|
19
19
|
|
20
20
|
def setup
|
21
21
|
setup_database
|
22
|
-
@posts = Groonga::Hash.create(:name => "Posts",
|
22
|
+
@posts = Groonga::Hash.create(:name => "Posts",
|
23
|
+
:key_type => "ShortText",
|
24
|
+
:value_type => "UInt32")
|
25
|
+
@grouped_posts = @posts.group("_key")
|
23
26
|
@id = @posts.column("_id")
|
24
|
-
|
25
|
-
|
26
|
-
def teardown
|
27
|
-
@id = nil
|
27
|
+
@key = @posts.column("_key")
|
28
|
+
@value = @posts.column("_value")
|
28
29
|
end
|
29
30
|
|
30
31
|
def test_name
|
@@ -51,9 +52,8 @@ class AccessorTest < Test::Unit::TestCase
|
|
51
52
|
|
52
53
|
sub_test_case "#key_accessor?" do
|
53
54
|
test "true" do
|
54
|
-
key = @posts.column("_key")
|
55
55
|
assert do
|
56
|
-
key.key_accessor?
|
56
|
+
@key.key_accessor?
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -63,4 +63,60 @@ class AccessorTest < Test::Unit::TestCase
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
66
|
+
|
67
|
+
sub_test_case "#id_accessor?" do
|
68
|
+
test "true" do
|
69
|
+
assert do
|
70
|
+
@id.id_accessor?
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
test "false" do
|
75
|
+
assert do
|
76
|
+
not @key.id_accessor?
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
sub_test_case "#value_accessor?" do
|
82
|
+
test "true" do
|
83
|
+
assert do
|
84
|
+
@value.value_accessor?
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
test "false" do
|
89
|
+
assert do
|
90
|
+
not @key.value_accessor?
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
sub_test_case "#score_accessor?" do
|
96
|
+
test "true" do
|
97
|
+
assert do
|
98
|
+
@posts.select.column("_score").score_accessor?
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
test "false" do
|
103
|
+
assert do
|
104
|
+
not @key.score_accessor?
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
sub_test_case "#n_sub_records_accessor?" do
|
110
|
+
test "true" do
|
111
|
+
assert do
|
112
|
+
@grouped_posts.column("_nsubrecs").n_sub_records_accessor?
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
test "false" do
|
117
|
+
assert do
|
118
|
+
not @key.n_sub_records_accessor?
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
66
122
|
end
|
data/test/test-column.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2009-
|
1
|
+
# Copyright (C) 2009-2020 Sutou Kouhei <kou@clear-code.com>
|
2
2
|
# Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
|
3
3
|
#
|
4
4
|
# This library is free software; you can redistribute it and/or
|
@@ -307,6 +307,17 @@ class ColumnTest < Test::Unit::TestCase
|
|
307
307
|
assert_false(post["hidden"])
|
308
308
|
end
|
309
309
|
|
310
|
+
def test_float32
|
311
|
+
need_groonga(10, 0, 2)
|
312
|
+
|
313
|
+
numbers = Groonga::Array.create(:name => "Numbers")
|
314
|
+
numbers.define_column("data", "Float32")
|
315
|
+
|
316
|
+
number = numbers.add
|
317
|
+
number["data"] = 1.1
|
318
|
+
assert_in_delta(1.1, number["data"])
|
319
|
+
end
|
320
|
+
|
310
321
|
def test_indexes
|
311
322
|
Groonga::Schema.define do |schema|
|
312
323
|
schema.create_table("Comments") do |table|
|
data/test/test-context.rb
CHANGED
@@ -132,6 +132,31 @@ class ContextTest < Test::Unit::TestCase
|
|
132
132
|
assert_equal(-1, context.match_escalation_threshold)
|
133
133
|
end
|
134
134
|
|
135
|
+
sub_test_case("#force_match_escalation?") do
|
136
|
+
def setup
|
137
|
+
default_force_match_escalation = context.force_match_escalation?
|
138
|
+
begin
|
139
|
+
yield
|
140
|
+
ensure
|
141
|
+
context.force_match_escalation = default_force_match_escalation
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_true
|
146
|
+
context.force_match_escalation = true
|
147
|
+
assert do
|
148
|
+
context.force_match_escalation?
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_false
|
153
|
+
context.force_match_escalation = false
|
154
|
+
assert do
|
155
|
+
not context.force_match_escalation?
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
135
160
|
def test_close
|
136
161
|
context = Groonga::Context.new
|
137
162
|
assert_false(context.closed?)
|
data/test/test-exception.rb
CHANGED
@@ -108,11 +108,16 @@ class TooManyOpenFilesTest < Test::Unit::TestCase
|
|
108
108
|
include GroongaTestUtils
|
109
109
|
|
110
110
|
def setup
|
111
|
+
@sub_context = nil
|
112
|
+
unless Process.const_defined?(:RLIMIT_NOFILE)
|
113
|
+
omit("No Process::RLIMIT_NOFILE")
|
114
|
+
end
|
111
115
|
setup_database
|
112
116
|
@sub_context = create_sub_context
|
113
117
|
end
|
114
118
|
|
115
119
|
def teardown
|
120
|
+
return if @sub_context.nil?
|
116
121
|
@sub_context.database.close
|
117
122
|
@sub_context.close
|
118
123
|
end
|
data/test/test-flushable.rb
CHANGED
@@ -18,32 +18,77 @@ class FlushableTest < Test::Unit::TestCase
|
|
18
18
|
|
19
19
|
setup :setup_database
|
20
20
|
|
21
|
+
def normalize_query_log(log)
|
22
|
+
log.lines.collect do |line|
|
23
|
+
line.chomp.gsub(/\A.*?:\d+ /, "")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
21
27
|
def test_flush_table
|
22
28
|
table = Groonga::Hash.create
|
23
|
-
|
29
|
+
log = collect_query_log do
|
24
30
|
table.flush
|
25
31
|
end
|
32
|
+
assert_equal([
|
33
|
+
"flush[(anonymous:table:hash_key)]",
|
34
|
+
],
|
35
|
+
normalize_query_log(log))
|
26
36
|
end
|
27
37
|
|
28
38
|
def test_flush_column
|
29
39
|
table = Groonga::Hash.create(:name => "Users")
|
30
40
|
column = table.define_column("name", "ShortText")
|
31
|
-
|
41
|
+
log = collect_query_log do
|
32
42
|
column.flush
|
33
43
|
end
|
44
|
+
assert_equal([
|
45
|
+
"flush[Users.name]",
|
46
|
+
],
|
47
|
+
normalize_query_log(log))
|
34
48
|
end
|
35
49
|
|
36
50
|
def test_flush_database
|
37
|
-
|
51
|
+
table = Groonga::Hash.create(:name => "Users")
|
52
|
+
table.define_column("name", "ShortText")
|
53
|
+
log = collect_query_log do
|
38
54
|
@database.flush
|
39
55
|
end
|
56
|
+
assert_equal([
|
57
|
+
"flush[Users.name]",
|
58
|
+
"flush[Users]",
|
59
|
+
"flush[(anonymous:table:dat_key)]",
|
60
|
+
"flush[(anonymous:column:var_size)]",
|
61
|
+
"flush[(anonymous:table:hash_key)]",
|
62
|
+
"flush[(anonymous:column:var_size)]",
|
63
|
+
"flush[(DB)]",
|
64
|
+
],
|
65
|
+
normalize_query_log(log))
|
40
66
|
end
|
41
67
|
|
42
68
|
def test_flush_not_recursive
|
43
|
-
table = Groonga::Hash.create
|
44
|
-
table.
|
45
|
-
|
69
|
+
table = Groonga::Hash.create(:name => "Users")
|
70
|
+
table.define_column("name", "ShortText")
|
71
|
+
log = collect_query_log do
|
46
72
|
table.flush(:recursive => false)
|
47
73
|
end
|
74
|
+
assert_equal([
|
75
|
+
"flush[Users]",
|
76
|
+
],
|
77
|
+
normalize_query_log(log))
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_flush_dependent
|
81
|
+
referenced_table = Groonga::Hash.create(name: "Names")
|
82
|
+
table = Groonga::Hash.create(:name => "Users")
|
83
|
+
table.define_column("name", referenced_table)
|
84
|
+
log = collect_query_log do
|
85
|
+
table.flush(:recursive => false, :dependent => true)
|
86
|
+
end
|
87
|
+
assert_equal([
|
88
|
+
"flush[Names]",
|
89
|
+
"flush[Users.name]",
|
90
|
+
"flush[Users]",
|
91
|
+
],
|
92
|
+
normalize_query_log(log))
|
48
93
|
end
|
49
94
|
end
|
data/test/test-index-column.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Copyright (C) 2009-2016 Kouhei Sutou <kou@clear-code.com>
|
1
|
+
# Copyright (C) 2009-2021 Sutou Kouhei <kou@clear-code.com>
|
4
2
|
# Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
|
5
3
|
#
|
6
4
|
# This library is free software; you can redistribute it and/or
|
@@ -33,11 +31,11 @@ class IndexColumnTest < Test::Unit::TestCase
|
|
33
31
|
articles = Groonga::Array.create(:name => "Articles")
|
34
32
|
articles.define_column("content", "Text")
|
35
33
|
|
36
|
-
terms = Groonga::Hash.create(:name => "Terms",
|
37
|
-
|
38
|
-
|
39
|
-
@index = terms.define_index_column("content", articles,
|
40
|
-
|
34
|
+
@terms = Groonga::Hash.create(:name => "Terms",
|
35
|
+
:key_type => "ShortText",
|
36
|
+
:default_tokenizer => "TokenBigram")
|
37
|
+
@index = @terms.define_index_column("content", articles,
|
38
|
+
:with_section => true)
|
41
39
|
end
|
42
40
|
|
43
41
|
def test_index?
|
@@ -63,6 +61,20 @@ class IndexColumnTest < Test::Unit::TestCase
|
|
63
61
|
not @index.data?
|
64
62
|
end
|
65
63
|
end
|
64
|
+
|
65
|
+
sub_test_case("#lexicon?") do
|
66
|
+
def test_true
|
67
|
+
assert do
|
68
|
+
@terms.lexicon?
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_false
|
73
|
+
assert do
|
74
|
+
not @index.lexicon?
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
66
78
|
end
|
67
79
|
|
68
80
|
class CRUDTest < self
|
@@ -189,6 +201,8 @@ class IndexColumnTest < Test::Unit::TestCase
|
|
189
201
|
end
|
190
202
|
|
191
203
|
def test_reindex
|
204
|
+
check_mecab_availability
|
205
|
+
|
192
206
|
Groonga::Schema.define do |schema|
|
193
207
|
schema.create_table("Memos", :type => :array) do |table|
|
194
208
|
table.short_text("title")
|
@@ -438,11 +452,35 @@ class IndexColumnTest < Test::Unit::TestCase
|
|
438
452
|
])
|
439
453
|
end
|
440
454
|
|
455
|
+
def test_large
|
456
|
+
Groonga::Schema.define do |schema|
|
457
|
+
schema.create_table("Tags",
|
458
|
+
:type => :patricia_trie,
|
459
|
+
:key_type => "ShortText") do |table|
|
460
|
+
table.index("Articles.tags",
|
461
|
+
:name => "large",
|
462
|
+
:size => :large)
|
463
|
+
table.index("Articles.tags",
|
464
|
+
:name => "default")
|
465
|
+
end
|
466
|
+
end
|
467
|
+
|
468
|
+
assert_equal([
|
469
|
+
true,
|
470
|
+
false,
|
471
|
+
],
|
472
|
+
[
|
473
|
+
context["Tags.large"].large?,
|
474
|
+
context["Tags.default"].large?,
|
475
|
+
])
|
476
|
+
end
|
477
|
+
|
441
478
|
def test_invalid
|
442
479
|
Groonga::Schema.create_table("Tags",
|
443
480
|
:type => :patricia_trie,
|
444
481
|
:key_type => "ShortText")
|
445
|
-
message =
|
482
|
+
message =
|
483
|
+
":size must be nil, :small, :medium or :large: <invalid>"
|
446
484
|
assert_raise(ArgumentError.new(message)) do
|
447
485
|
tags = context["Tags"]
|
448
486
|
tags.define_index_column("small",
|
@@ -818,5 +856,28 @@ class IndexColumnTest < Test::Unit::TestCase
|
|
818
856
|
">",
|
819
857
|
index.inspect)
|
820
858
|
end
|
859
|
+
|
860
|
+
def test_large_size
|
861
|
+
Groonga::Schema.define do |schema|
|
862
|
+
schema.create_table("Tags",
|
863
|
+
:type => :hash,
|
864
|
+
:key_type => "ShortText") do |tags|
|
865
|
+
tags.index("Articles.tag", :size => :large)
|
866
|
+
end
|
867
|
+
end
|
868
|
+
|
869
|
+
index = context["Tags.Articles_tag"]
|
870
|
+
source_column_names = index.sources.collect(&:local_name).join(",")
|
871
|
+
assert_equal("\#<Groonga::IndexColumn " +
|
872
|
+
"id: <#{index.id}>, " +
|
873
|
+
"name: <#{index.name}>, " +
|
874
|
+
"path: <#{index.path}>, " +
|
875
|
+
"domain: <#{index.domain.name}>, " +
|
876
|
+
"range: <#{index.range.name}>, " +
|
877
|
+
"flags: <LARGE>, " +
|
878
|
+
"sources: <#{source_column_names}>" +
|
879
|
+
">",
|
880
|
+
index.inspect)
|
881
|
+
end
|
821
882
|
end
|
822
883
|
end
|
data/test/test-index-cursor.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Copyright (C) 2012-2017 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
# Copyright (C) 2019 Horimoto Yasuhiro <horimoto@clear-code.com>
|
2
3
|
#
|
3
4
|
# This library is free software; you can redistribute it and/or
|
4
5
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -155,6 +156,31 @@ class IndexCursorTest < Test::Unit::TestCase
|
|
155
156
|
assert_equal("l", term.key)
|
156
157
|
end
|
157
158
|
|
159
|
+
sub_test_case(".set_min?") do
|
160
|
+
def setup
|
161
|
+
default_set_min = Groonga::IndexCursor.set_min?
|
162
|
+
begin
|
163
|
+
yield
|
164
|
+
ensure
|
165
|
+
Groonga::IndexCursor.set_min = default_set_min
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_true
|
170
|
+
Groonga::IndexCursor.set_min = true
|
171
|
+
assert do
|
172
|
+
Groonga::IndexCursor.set_min?
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def test_false
|
177
|
+
Groonga::IndexCursor.set_min = false
|
178
|
+
assert do
|
179
|
+
not Groonga::IndexCursor.set_min?
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
158
184
|
private
|
159
185
|
def create_hashes(keys, values)
|
160
186
|
hashes = []
|
data/test/test-logger.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2010-
|
1
|
+
# Copyright (C) 2010-2019 Kouhei Sutou <kou@clear-code.com>
|
2
2
|
# Copyright (C) 2016 Masafumi Yokoyama <yokoyama@clear-code.com>
|
3
3
|
#
|
4
4
|
# This library is free software; you can redistribute it and/or
|
@@ -21,15 +21,18 @@ class LoggerTest < Test::Unit::TestCase
|
|
21
21
|
@default_log_path = Groonga::Logger.path
|
22
22
|
@default_log_max_level = Groonga::Logger.max_level
|
23
23
|
@default_rotate_threshold_size = Groonga::Logger.rotate_threshold_size
|
24
|
+
@default_flags = Groonga::Logger.flags
|
24
25
|
end
|
25
26
|
|
26
27
|
def teardown
|
27
28
|
Groonga::Logger.path = @default_log_path
|
28
29
|
Groonga::Logger.max_level = @default_log_max_level
|
29
30
|
Groonga::Logger.rotate_threshold_size = @default_rotate_threshold_size
|
31
|
+
Groonga::Logger.flags = @default_flags
|
30
32
|
end
|
31
33
|
|
32
34
|
def test_reopen
|
35
|
+
only_not_windows
|
33
36
|
Groonga::Logger.unregister
|
34
37
|
Groonga::Logger.path = @log_path.to_s
|
35
38
|
if @log_path.exist?
|
@@ -46,12 +49,22 @@ class LoggerTest < Test::Unit::TestCase
|
|
46
49
|
assert_equal(:debug, Groonga::Logger.max_level)
|
47
50
|
end
|
48
51
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
sub_test_case ".flags" do
|
53
|
+
def test_default
|
54
|
+
assert_equal(Groonga::Logger::Flags::TIME |
|
55
|
+
Groonga::Logger::Flags::MESSAGE,
|
56
|
+
Groonga::Logger.flags)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_location
|
60
|
+
Groonga::Logger.flags = Groonga::Logger::Flags::LOCATION
|
61
|
+
assert_equal(Groonga::Logger::Flags::LOCATION, Groonga::Logger.flags)
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_thread_id
|
65
|
+
Groonga::Logger.flags = Groonga::Logger::Flags::THREAD_ID
|
66
|
+
assert_equal(Groonga::Logger::Flags::THREAD_ID, Groonga::Logger.flags)
|
67
|
+
end
|
55
68
|
end
|
56
69
|
|
57
70
|
sub_test_case ".log" do
|
@@ -89,7 +102,8 @@ class LoggerTest < Test::Unit::TestCase
|
|
89
102
|
|
90
103
|
test "default location" do
|
91
104
|
locations = []
|
92
|
-
Groonga::Logger.register do |
|
105
|
+
Groonga::Logger.register(thread_id: false) do |*args|
|
106
|
+
location = args[5]
|
93
107
|
locations << location
|
94
108
|
end
|
95
109
|
Groonga::Logger.log("message"); line = __LINE__
|
@@ -102,7 +116,8 @@ class LoggerTest < Test::Unit::TestCase
|
|
102
116
|
|
103
117
|
test ":file" do
|
104
118
|
locations = []
|
105
|
-
Groonga::Logger.register do |
|
119
|
+
Groonga::Logger.register(thread_id: false) do |*args|
|
120
|
+
location = args[5]
|
106
121
|
locations << location
|
107
122
|
end
|
108
123
|
Groonga::Logger.log("message", :file => "file.rb")
|
@@ -118,7 +133,8 @@ class LoggerTest < Test::Unit::TestCase
|
|
118
133
|
|
119
134
|
test ":line" do
|
120
135
|
locations = []
|
121
|
-
Groonga::Logger.register do |
|
136
|
+
Groonga::Logger.register(thread_id: false) do |*args|
|
137
|
+
location = args[5]
|
122
138
|
locations << location
|
123
139
|
end
|
124
140
|
Groonga::Logger.log("message", :line => 100)
|
@@ -134,7 +150,8 @@ class LoggerTest < Test::Unit::TestCase
|
|
134
150
|
|
135
151
|
test ":function" do
|
136
152
|
locations = []
|
137
|
-
Groonga::Logger.register do |
|
153
|
+
Groonga::Logger.register(thread_id: false) do |*args|
|
154
|
+
location = args[5]
|
138
155
|
locations << location
|
139
156
|
end
|
140
157
|
Groonga::Logger.log("message", :function => "method_name")
|
@@ -149,6 +166,34 @@ class LoggerTest < Test::Unit::TestCase
|
|
149
166
|
end
|
150
167
|
end
|
151
168
|
|
169
|
+
sub_test_case ".register" do
|
170
|
+
setup do
|
171
|
+
GC.disable
|
172
|
+
end
|
173
|
+
|
174
|
+
teardown do
|
175
|
+
Groonga::Logger.unregister
|
176
|
+
GC.enable
|
177
|
+
end
|
178
|
+
|
179
|
+
test ":thread_id" do
|
180
|
+
locations = []
|
181
|
+
Groonga::Logger.register(location: false,
|
182
|
+
thread_id: true) do |*args|
|
183
|
+
location = args[5]
|
184
|
+
locations << location
|
185
|
+
end
|
186
|
+
Groonga::Logger.log("message")
|
187
|
+
locations = locations.collect do |location|
|
188
|
+
location.gsub(/\A([a-f\d]+)\z/, "THREAD_ID")
|
189
|
+
end
|
190
|
+
assert_equal([
|
191
|
+
"THREAD_ID",
|
192
|
+
],
|
193
|
+
locations)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
152
197
|
def test_rotate_threshold_size
|
153
198
|
Groonga::Logger.unregister
|
154
199
|
Groonga::Logger.path = @log_path.to_s
|