activegroonga 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/NEWS.ja.rdoc +4 -0
- data/NEWS.rdoc +4 -0
- data/Rakefile +2 -1
- data/lib/active_groonga/base.rb +10 -4
- data/lib/active_groonga/callbacks.rb +26 -0
- data/lib/active_groonga/column.rb +22 -1
- data/lib/active_groonga/observer.rb +29 -0
- data/lib/active_groonga/schema.rb +6 -2
- data/lib/active_groonga/schema_dumper.rb +1 -0
- data/lib/active_groonga/version.rb +1 -1
- data/lib/active_groonga.rb +2 -1
- data/test/test-callbacks.rb +30 -0
- data/test/test-schema.rb +12 -0
- data/test-unit/lib/test/unit/assertions.rb +5 -2
- data/test-unit/lib/test/unit/autorunner.rb +19 -4
- data/test-unit/lib/test/unit/collector/load.rb +3 -1
- data/test-unit/lib/test/unit/color-scheme.rb +5 -1
- data/test-unit/lib/test/unit/error.rb +7 -5
- data/test-unit/lib/test/unit/runner/tap.rb +8 -0
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +63 -8
- data/test-unit/lib/test/unit/ui/tap/testrunner.rb +92 -0
- data/test-unit/test/collector/test-load.rb +1 -5
- data/test-unit/test/test-color-scheme.rb +4 -0
- metadata +12 -11
- data/test/tmp/database/database.groonga +0 -0
- data/test/tmp/database/database.groonga.0000000 +0 -0
- data/test/tmp/database/database.groonga.0000100 +0 -0
- data/test/tmp/database/database.groonga.0000101 +0 -0
data/NEWS.ja.rdoc
CHANGED
data/NEWS.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -106,7 +106,8 @@ Hoe.spec('activegroonga') do |_project|
|
|
106
106
|
:extra_rdoc_files => Dir.glob("*.rdoc"),
|
107
107
|
}
|
108
108
|
project.readme_file = "README.ja.rdoc"
|
109
|
-
project.extra_deps = [["groonga", "=#{version}"],
|
109
|
+
project.extra_deps = [["groonga", "=#{version}"],
|
110
|
+
["activerecord", "=2.3.4"]]
|
110
111
|
|
111
112
|
news_of_current_release = File.read("NEWS.rdoc").split(/^==\s.*$/)[1]
|
112
113
|
project.changes = cleanup_white_space(news_of_current_release)
|
data/lib/active_groonga/base.rb
CHANGED
@@ -375,7 +375,7 @@ module ActiveGroonga
|
|
375
375
|
|
376
376
|
# Returns an array of column objects for the table associated with this class.
|
377
377
|
def columns
|
378
|
-
@columns ||= table.columns.collect do |column|
|
378
|
+
@columns ||= [IdColumn.new(table)] + table.columns.collect do |column|
|
379
379
|
Column.new(column)
|
380
380
|
end
|
381
381
|
end
|
@@ -428,7 +428,13 @@ module ActiveGroonga
|
|
428
428
|
elsif abstract_class?
|
429
429
|
"#{super}(abstract)"
|
430
430
|
elsif table_exists?
|
431
|
-
attr_list = columns.
|
431
|
+
attr_list = columns.collect do |column|
|
432
|
+
if column.id?
|
433
|
+
nil
|
434
|
+
else
|
435
|
+
"#{column.name}: #{column.type}"
|
436
|
+
end
|
437
|
+
end.compact.join(', ')
|
432
438
|
"#{super}(#{attr_list})"
|
433
439
|
else
|
434
440
|
"#{super}(Table doesn't exist)"
|
@@ -1571,7 +1577,7 @@ module ActiveGroonga
|
|
1571
1577
|
quoted = {}
|
1572
1578
|
attribute_names.each do |name|
|
1573
1579
|
column = column_for_attribute(name)
|
1574
|
-
next if column.nil?
|
1580
|
+
next if column.nil? or column.id?
|
1575
1581
|
|
1576
1582
|
value = read_attribute(name)
|
1577
1583
|
# We need explicit to_yaml because quote() does not properly convert Time/Date fields to YAML.
|
@@ -1602,7 +1608,7 @@ module ActiveGroonga
|
|
1602
1608
|
include Validations
|
1603
1609
|
include AttributeMethods
|
1604
1610
|
include Dirty
|
1605
|
-
include Timestamp
|
1611
|
+
include Callbacks, Observing, Timestamp
|
1606
1612
|
include Associations
|
1607
1613
|
include Aggregations, Reflection
|
1608
1614
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
10
|
+
# Lesser General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
13
|
+
# License along with this library; if not, write to the Free Software
|
14
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
15
|
+
|
16
|
+
module ActiveGroonga
|
17
|
+
module Callbacks
|
18
|
+
class << self
|
19
|
+
def included(base)
|
20
|
+
base.class_eval do
|
21
|
+
include ActiveRecord::Callbacks
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -24,6 +24,10 @@ module ActiveGroonga
|
|
24
24
|
@type = detect_type
|
25
25
|
end
|
26
26
|
|
27
|
+
def id?
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
27
31
|
def type_cast(value)
|
28
32
|
return nil if value.nil?
|
29
33
|
case type
|
@@ -65,7 +69,11 @@ module ActiveGroonga
|
|
65
69
|
end
|
66
70
|
|
67
71
|
def index_sources
|
68
|
-
@column
|
72
|
+
if @column
|
73
|
+
@column.sources
|
74
|
+
else
|
75
|
+
[]
|
76
|
+
end
|
69
77
|
end
|
70
78
|
|
71
79
|
def reference_type?
|
@@ -113,4 +121,17 @@ module ActiveGroonga
|
|
113
121
|
end
|
114
122
|
end
|
115
123
|
end
|
124
|
+
|
125
|
+
class IdColumn < Column
|
126
|
+
def initialize(table)
|
127
|
+
@column = nil
|
128
|
+
@table = table
|
129
|
+
@name = "id"
|
130
|
+
@type = :unsigned_integer
|
131
|
+
end
|
132
|
+
|
133
|
+
def id?
|
134
|
+
true
|
135
|
+
end
|
136
|
+
end
|
116
137
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
10
|
+
# Lesser General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
13
|
+
# License along with this library; if not, write to the Free Software
|
14
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
15
|
+
|
16
|
+
module ActiveGroonga
|
17
|
+
module Observing
|
18
|
+
class << self
|
19
|
+
def included(base)
|
20
|
+
base.class_eval do
|
21
|
+
include ActiveRecord::Observing
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Observer < ActiveRecord::Observer
|
28
|
+
end
|
29
|
+
end
|
@@ -46,8 +46,7 @@ module ActiveGroonga
|
|
46
46
|
if inserted.include?(v)
|
47
47
|
raise "Duplicate migration #{v}. Please renumber your migrations to resolve the conflict."
|
48
48
|
elsif v < version
|
49
|
-
migration = migrations_table.add
|
50
|
-
migration["version"] = v.to_s
|
49
|
+
migration = migrations_table.add(v.to_s)
|
51
50
|
inserted << v
|
52
51
|
end
|
53
52
|
end
|
@@ -83,6 +82,11 @@ module ActiveGroonga
|
|
83
82
|
end
|
84
83
|
|
85
84
|
def remove_column(table_name, *column_names)
|
85
|
+
if column_names.last.is_a?(Hash)
|
86
|
+
options = columns.pop
|
87
|
+
else
|
88
|
+
options = {}
|
89
|
+
end
|
86
90
|
options_with_context = options.merge(:context => Base.context)
|
87
91
|
Groonga::Schema.change_table(table_name, options_with_context) do |table|
|
88
92
|
column_names.each do |column_name|
|
data/lib/active_groonga.rb
CHANGED
@@ -28,7 +28,7 @@ require 'groonga'
|
|
28
28
|
|
29
29
|
module ActiveGroonga
|
30
30
|
def self.load_all!
|
31
|
-
[Base]
|
31
|
+
[Base, Column]
|
32
32
|
end
|
33
33
|
|
34
34
|
autoload :VERSION, 'active_groonga/version'
|
@@ -45,6 +45,7 @@ module ActiveGroonga
|
|
45
45
|
autoload :Calculations, 'active_groonga/calculations'
|
46
46
|
autoload :Callbacks, 'active_groonga/callbacks'
|
47
47
|
autoload :Column, 'active_groonga/column'
|
48
|
+
autoload :IdColumn, 'active_groonga/column'
|
48
49
|
autoload :Dirty, 'active_groonga/dirty'
|
49
50
|
autoload :DynamicRecordExpressionBuilder,
|
50
51
|
'active_groonga/dynamic_record_expression_builder'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License as published by the Free Software Foundation; either
|
6
|
+
# version 2.1 of the License.
|
7
|
+
#
|
8
|
+
# This library is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11
|
+
# Lesser General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Lesser General Public
|
14
|
+
# License along with this library; if not, write to the Free Software
|
15
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
16
|
+
|
17
|
+
class TestCallbacks < Test::Unit::TestCase
|
18
|
+
include ActiveGroongaTestUtils
|
19
|
+
|
20
|
+
def test_before_save
|
21
|
+
bookmark = Bookmark.new
|
22
|
+
def bookmark.before_save
|
23
|
+
@called = true
|
24
|
+
end
|
25
|
+
bookmark.instance_variable_set("@called", false)
|
26
|
+
assert_equal(false, bookmark.instance_variable_get("@called"))
|
27
|
+
bookmark.save
|
28
|
+
assert_equal(true, bookmark.instance_variable_get("@called"))
|
29
|
+
end
|
30
|
+
end
|
data/test/test-schema.rb
CHANGED
@@ -62,4 +62,16 @@ class TestSchema < Test::Unit::TestCase
|
|
62
62
|
|
63
63
|
assert_predicate(index_file, :exist?)
|
64
64
|
end
|
65
|
+
|
66
|
+
def test_remove_column
|
67
|
+
column_file = @tables_dir + "posts" + "columns" + "title.groonga"
|
68
|
+
assert_not_predicate(column_file, :exist?)
|
69
|
+
ActiveGroonga::Schema.create_table(:posts) do |table|
|
70
|
+
table.string :title
|
71
|
+
end
|
72
|
+
assert_predicate(column_file, :exist?)
|
73
|
+
|
74
|
+
ActiveGroonga::Schema.remove_column(:posts, :title)
|
75
|
+
assert_not_predicate(column_file, :exist?)
|
76
|
+
end
|
65
77
|
end
|
@@ -880,7 +880,7 @@ EOT
|
|
880
880
|
MaybeContainer.new(value, &formatter)
|
881
881
|
end
|
882
882
|
|
883
|
-
MAX_DIFF_TARGET_STRING_SIZE =
|
883
|
+
MAX_DIFF_TARGET_STRING_SIZE = 1000
|
884
884
|
def diff_target_string?(string)
|
885
885
|
if string.respond_to?(:bytesize)
|
886
886
|
string.bytesize < MAX_DIFF_TARGET_STRING_SIZE
|
@@ -930,7 +930,10 @@ EOM
|
|
930
930
|
if use_pp
|
931
931
|
begin
|
932
932
|
require 'pp' unless defined?(PP)
|
933
|
-
|
933
|
+
begin
|
934
|
+
return PP.pp(object, '').chomp
|
935
|
+
rescue NameError
|
936
|
+
end
|
934
937
|
rescue LoadError
|
935
938
|
self.use_pp = false
|
936
939
|
end
|
@@ -102,15 +102,23 @@ module Test
|
|
102
102
|
@to_run = []
|
103
103
|
@color_scheme = ColorScheme.default
|
104
104
|
@runner_options = {}
|
105
|
+
@default_arguments = []
|
105
106
|
@workdir = nil
|
106
|
-
|
107
|
-
|
107
|
+
config_file = "test-unit.yml"
|
108
|
+
if File.exist?(config_file)
|
109
|
+
load_config(config_file)
|
110
|
+
else
|
111
|
+
global_config_file = File.expand_path("~/.test-unit.xml")
|
112
|
+
load_config(global_config_file) if File.exist?(global_config_file)
|
113
|
+
end
|
108
114
|
yield(self) if block_given?
|
109
115
|
end
|
110
116
|
|
111
117
|
def process_args(args = ARGV)
|
118
|
+
default_arguments = @default_arguments.dup
|
112
119
|
begin
|
113
|
-
|
120
|
+
@default_arguments.concat(args)
|
121
|
+
options.order!(@default_arguments) {|arg| @to_run << arg}
|
114
122
|
rescue OptionParser::ParseError => e
|
115
123
|
puts e
|
116
124
|
puts options
|
@@ -119,6 +127,8 @@ module Test
|
|
119
127
|
@filters << proc{false} unless(@filters.empty?)
|
120
128
|
end
|
121
129
|
not @to_run.empty?
|
130
|
+
ensure
|
131
|
+
@default_arguments = default_arguments
|
122
132
|
end
|
123
133
|
|
124
134
|
def options
|
@@ -304,7 +314,11 @@ module Test
|
|
304
314
|
(config["#{runner_name}_options"] || {}).each do |key, value|
|
305
315
|
key = key.to_sym
|
306
316
|
value = ColorScheme[value] if key == :color_scheme
|
307
|
-
|
317
|
+
if key == :arguments
|
318
|
+
@default_arguments.concat(value.split)
|
319
|
+
else
|
320
|
+
runner_options[key.to_sym] = value
|
321
|
+
end
|
308
322
|
end
|
309
323
|
@runner_options = @runner_options.merge(runner_options)
|
310
324
|
end
|
@@ -327,3 +341,4 @@ end
|
|
327
341
|
|
328
342
|
require 'test/unit/runner/console'
|
329
343
|
require 'test/unit/runner/emacs'
|
344
|
+
require 'test/unit/runner/tap'
|
@@ -76,7 +76,9 @@ module Test
|
|
76
76
|
sub_test_suites << sub_test_suite unless sub_test_suite.empty?
|
77
77
|
end
|
78
78
|
else
|
79
|
-
|
79
|
+
unless excluded_file?(path.basename.to_s)
|
80
|
+
collect_file(path, sub_test_suites, already_gathered)
|
81
|
+
end
|
80
82
|
end
|
81
83
|
|
82
84
|
test_suite = TestSuite.new(path.basename.to_s)
|
@@ -14,7 +14,11 @@ module Test
|
|
14
14
|
"omission" => Color.new("blue", :bold => true),
|
15
15
|
"notification" => Color.new("cyan", :bold => true),
|
16
16
|
"error" => Color.new("yellow", :bold => true) +
|
17
|
-
Color.new("black", :foreground => false)
|
17
|
+
Color.new("black", :foreground => false),
|
18
|
+
"case" => Color.new("white", :bold => true) +
|
19
|
+
Color.new("blue", :foreground => false),
|
20
|
+
"suite" => Color.new("white", :bold => true) +
|
21
|
+
Color.new("green", :foreground => false))
|
18
22
|
end
|
19
23
|
|
20
24
|
@@schemes = {}
|
@@ -69,18 +69,20 @@ module Test
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
+
NOT_PASS_THROUGH_EXCEPTIONS = []
|
72
73
|
PASS_THROUGH_EXCEPTIONS = [NoMemoryError, SignalException, Interrupt,
|
73
74
|
SystemExit]
|
74
75
|
private
|
75
76
|
def handle_all_exception(exception)
|
76
77
|
case exception
|
78
|
+
when *NOT_PASS_THROUGH_EXCEPTIONS
|
77
79
|
when *PASS_THROUGH_EXCEPTIONS
|
78
|
-
false
|
79
|
-
else
|
80
|
-
problem_occurred
|
81
|
-
add_error(exception)
|
82
|
-
true
|
80
|
+
return false
|
83
81
|
end
|
82
|
+
|
83
|
+
problem_occurred
|
84
|
+
add_error(exception)
|
85
|
+
true
|
84
86
|
end
|
85
87
|
|
86
88
|
def add_error(exception)
|
@@ -1,7 +1,9 @@
|
|
1
1
|
#--
|
2
2
|
#
|
3
3
|
# Author:: Nathaniel Talbott.
|
4
|
-
# Copyright::
|
4
|
+
# Copyright::
|
5
|
+
# * Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
|
6
|
+
# * Copyright (c) 2008-2009 Kouhei Sutou <kou@clear-code.com>
|
5
7
|
# License:: Ruby license.
|
6
8
|
|
7
9
|
require 'test/unit/color-scheme'
|
@@ -36,6 +38,9 @@ module Test
|
|
36
38
|
@progress_row_max = @options[:progress_row_max]
|
37
39
|
@progress_row_max ||= guess_progress_row_max
|
38
40
|
@already_outputted = false
|
41
|
+
@n_successes = 0
|
42
|
+
@indent = 0
|
43
|
+
@top_level = true
|
39
44
|
@faults = []
|
40
45
|
end
|
41
46
|
|
@@ -68,6 +73,8 @@ module Test
|
|
68
73
|
@mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished))
|
69
74
|
@mediator.add_listener(TestCase::STARTED, &method(:test_started))
|
70
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))
|
71
78
|
end
|
72
79
|
|
73
80
|
def start_mediator
|
@@ -91,8 +98,6 @@ module Test
|
|
91
98
|
|
92
99
|
def finished(elapsed_time)
|
93
100
|
nl if output?(NORMAL) and !output?(VERBOSE)
|
94
|
-
nl
|
95
|
-
output("Finished in #{elapsed_time} seconds.")
|
96
101
|
@faults.each_with_index do |fault, index|
|
97
102
|
nl
|
98
103
|
output_single("%3d) " % (index + 1))
|
@@ -101,25 +106,75 @@ module Test
|
|
101
106
|
output(detail)
|
102
107
|
end
|
103
108
|
nl
|
109
|
+
output("Finished in #{elapsed_time} seconds.")
|
110
|
+
nl
|
104
111
|
output(@result, result_color)
|
112
|
+
n_tests = @result.run_count
|
113
|
+
if n_tests.zero?
|
114
|
+
pass_percentage = 0
|
115
|
+
else
|
116
|
+
pass_percentage = 100.0 * (@n_successes / n_tests.to_f)
|
117
|
+
end
|
118
|
+
output("%g%% passed" % pass_percentage, result_color)
|
105
119
|
end
|
106
120
|
|
107
121
|
def format_fault(fault)
|
108
122
|
fault.long_display
|
109
123
|
end
|
110
|
-
|
124
|
+
|
111
125
|
def test_started(name)
|
112
|
-
|
126
|
+
return unless output?(VERBOSE)
|
127
|
+
|
128
|
+
name = name.sub(/\(.+?\)\z/, '')
|
129
|
+
right_space = 8 * 2
|
130
|
+
left_space = @progress_row_max - right_space
|
131
|
+
left_space = left_space - indent.size - name.size
|
132
|
+
tab_stop = "\t" * ((left_space - 1) / 8)
|
133
|
+
output_single("#{indent}#{name}:#{tab_stop}", nil, VERBOSE)
|
134
|
+
@test_start = Time.now
|
113
135
|
end
|
114
|
-
|
136
|
+
|
115
137
|
def test_finished(name)
|
116
138
|
unless @already_outputted
|
139
|
+
@n_successes += 1
|
117
140
|
output_progress(".", color("success"))
|
118
141
|
end
|
119
|
-
nl(VERBOSE)
|
120
142
|
@already_outputted = false
|
143
|
+
|
144
|
+
return unless output?(VERBOSE)
|
145
|
+
|
146
|
+
output(": (%f)" % (Time.now - @test_start), nil, VERBOSE)
|
121
147
|
end
|
122
|
-
|
148
|
+
|
149
|
+
def test_suite_started(name)
|
150
|
+
if @top_level
|
151
|
+
@top_level = false
|
152
|
+
return
|
153
|
+
end
|
154
|
+
|
155
|
+
output_single(indent, nil, VERBOSE)
|
156
|
+
if /\A[A-Z]/ =~ name
|
157
|
+
_color = color("case")
|
158
|
+
else
|
159
|
+
_color = color("suite")
|
160
|
+
end
|
161
|
+
output_single(name, _color, VERBOSE)
|
162
|
+
output(": ", nil, VERBOSE)
|
163
|
+
@indent += 2
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_suite_finished(name)
|
167
|
+
@indent -= 2
|
168
|
+
end
|
169
|
+
|
170
|
+
def indent
|
171
|
+
if output?(VERBOSE)
|
172
|
+
" " * @indent
|
173
|
+
else
|
174
|
+
""
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
123
178
|
def nl(level=NORMAL)
|
124
179
|
output("", nil, level)
|
125
180
|
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
#--
|
2
|
+
#
|
3
|
+
# Author:: Kouhei Sutou.
|
4
|
+
# Copyright:: Copyright (c) 2009 Kouhei Sutou <kou@clear-code.com>.
|
5
|
+
# License:: Ruby license.
|
6
|
+
|
7
|
+
require 'test/unit/ui/testrunner'
|
8
|
+
require 'test/unit/ui/testrunnermediator'
|
9
|
+
|
10
|
+
module Test
|
11
|
+
module Unit
|
12
|
+
module UI
|
13
|
+
module Tap
|
14
|
+
|
15
|
+
# Runs a Test::Unit::TestSuite and outputs result
|
16
|
+
# as TAP format.
|
17
|
+
class TestRunner < UI::TestRunner
|
18
|
+
def initialize(suite, options={})
|
19
|
+
super
|
20
|
+
@output = @options[:output] || STDOUT
|
21
|
+
@n_tests = 0
|
22
|
+
@already_outputted = false
|
23
|
+
end
|
24
|
+
|
25
|
+
# Begins the test run.
|
26
|
+
def start
|
27
|
+
setup_mediator
|
28
|
+
result = start_mediator
|
29
|
+
def result.passed?
|
30
|
+
true # for prove commend :<
|
31
|
+
end
|
32
|
+
result
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
def setup_mediator
|
37
|
+
@mediator = TestRunnerMediator.new(@suite)
|
38
|
+
attach_to_mediator
|
39
|
+
end
|
40
|
+
|
41
|
+
def attach_to_mediator
|
42
|
+
@mediator.add_listener(TestResult::FAULT, &method(:add_fault))
|
43
|
+
@mediator.add_listener(TestRunnerMediator::STARTED, &method(:started))
|
44
|
+
@mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished))
|
45
|
+
@mediator.add_listener(TestCase::STARTED, &method(:test_started))
|
46
|
+
@mediator.add_listener(TestCase::FINISHED, &method(:test_finished))
|
47
|
+
end
|
48
|
+
|
49
|
+
def start_mediator
|
50
|
+
@mediator.run_suite
|
51
|
+
end
|
52
|
+
|
53
|
+
def add_fault(fault)
|
54
|
+
puts("not ok #{@n_tests} - #{fault.short_display}")
|
55
|
+
fault.long_display.each_line do |line|
|
56
|
+
puts("# #{line}")
|
57
|
+
end
|
58
|
+
@already_outputted = true
|
59
|
+
end
|
60
|
+
|
61
|
+
def started(result)
|
62
|
+
@result = result
|
63
|
+
puts("1..#{@suite.size}")
|
64
|
+
end
|
65
|
+
|
66
|
+
def finished(elapsed_time)
|
67
|
+
puts("# Finished in #{elapsed_time} seconds.")
|
68
|
+
@result.to_s.each_line do |line|
|
69
|
+
puts("# #{line}")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_started(name)
|
74
|
+
@n_tests += 1
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_finished(name)
|
78
|
+
unless @already_outputted
|
79
|
+
puts("ok #{@n_tests} - #{name}")
|
80
|
+
end
|
81
|
+
@already_outputted = false
|
82
|
+
end
|
83
|
+
|
84
|
+
def puts(*args)
|
85
|
+
@output.puts(*args)
|
86
|
+
@output.flush
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -240,11 +240,7 @@ EOT
|
|
240
240
|
[:test, {:name => "test1_2"}]]],
|
241
241
|
@test_case1.to_s)
|
242
242
|
|
243
|
-
assert_collect(
|
244
|
-
[:suite, {:name => _test_case_name("NoLoadSubTestCase5")},
|
245
|
-
[:test, {:name => "test5_1"}],
|
246
|
-
[:test, {:name => "test5_2"}]]],
|
247
|
-
@no_load_sub_test_case5.to_s)
|
243
|
+
assert_collect(nil, @no_load_sub_test_case5.to_s)
|
248
244
|
end
|
249
245
|
|
250
246
|
def test_nil_pattern
|
@@ -8,6 +8,10 @@ class TestUnitColorScheme < Test::Unit::TestCase
|
|
8
8
|
"notification" => color("cyan", :bold => true),
|
9
9
|
"error" => color("yellow", :bold => true) +
|
10
10
|
color("black", :foreground => false),
|
11
|
+
"case" => color("white", :bold => true) +
|
12
|
+
color("blue", :foreground => false),
|
13
|
+
"suite" => color("white", :bold => true) +
|
14
|
+
color("green", :foreground => false),
|
11
15
|
},
|
12
16
|
Test::Unit::ColorScheme.default.to_hash)
|
13
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activegroonga
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouhei Sutou
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-02 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - "="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.
|
23
|
+
version: 0.0.7
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activerecord
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.3.
|
33
|
+
version: 2.3.4
|
34
34
|
version:
|
35
35
|
description: |-
|
36
36
|
groonga provides both of full text search and column store
|
@@ -44,9 +44,9 @@ executables: []
|
|
44
44
|
extensions: []
|
45
45
|
|
46
46
|
extra_rdoc_files:
|
47
|
-
- README.rdoc
|
48
|
-
- NEWS.ja.rdoc
|
49
47
|
- README.ja.rdoc
|
48
|
+
- NEWS.ja.rdoc
|
49
|
+
- README.rdoc
|
50
50
|
- NEWS.rdoc
|
51
51
|
files:
|
52
52
|
- AUTHORS
|
@@ -61,11 +61,13 @@ files:
|
|
61
61
|
- lib/active_groonga/associations/belongs_to_association.rb
|
62
62
|
- lib/active_groonga/attribute_methods.rb
|
63
63
|
- lib/active_groonga/base.rb
|
64
|
+
- lib/active_groonga/callbacks.rb
|
64
65
|
- lib/active_groonga/column.rb
|
65
66
|
- lib/active_groonga/dirty.rb
|
66
67
|
- lib/active_groonga/dynamic_record_expression_builder.rb
|
67
68
|
- lib/active_groonga/fixtures.rb
|
68
69
|
- lib/active_groonga/migration.rb
|
70
|
+
- lib/active_groonga/observer.rb
|
69
71
|
- lib/active_groonga/rails_support.rb
|
70
72
|
- lib/active_groonga/reflection.rb
|
71
73
|
- lib/active_groonga/schema.rb
|
@@ -121,12 +123,14 @@ files:
|
|
121
123
|
- test-unit/lib/test/unit/priority.rb
|
122
124
|
- test-unit/lib/test/unit/runner/console.rb
|
123
125
|
- test-unit/lib/test/unit/runner/emacs.rb
|
126
|
+
- test-unit/lib/test/unit/runner/tap.rb
|
124
127
|
- test-unit/lib/test/unit/testcase.rb
|
125
128
|
- test-unit/lib/test/unit/testresult.rb
|
126
129
|
- test-unit/lib/test/unit/testsuite.rb
|
127
130
|
- test-unit/lib/test/unit/ui/console/outputlevel.rb
|
128
131
|
- test-unit/lib/test/unit/ui/console/testrunner.rb
|
129
132
|
- test-unit/lib/test/unit/ui/emacs/testrunner.rb
|
133
|
+
- test-unit/lib/test/unit/ui/tap/testrunner.rb
|
130
134
|
- test-unit/lib/test/unit/ui/testrunner.rb
|
131
135
|
- test-unit/lib/test/unit/ui/testrunnermediator.rb
|
132
136
|
- test-unit/lib/test/unit/ui/testrunnerutilities.rb
|
@@ -175,12 +179,9 @@ files:
|
|
175
179
|
- test/run-test.rb
|
176
180
|
- test/test-associations.rb
|
177
181
|
- test/test-base.rb
|
182
|
+
- test/test-callbacks.rb
|
178
183
|
- test/test-schema-dumper.rb
|
179
184
|
- test/test-schema.rb
|
180
|
-
- test/tmp/database/database.groonga
|
181
|
-
- test/tmp/database/database.groonga.0000000
|
182
|
-
- test/tmp/database/database.groonga.0000100
|
183
|
-
- test/tmp/database/database.groonga.0000101
|
184
185
|
has_rdoc: true
|
185
186
|
homepage: http://groonga.rubyforge.org/
|
186
187
|
licenses: []
|
@@ -206,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
207
|
requirements: []
|
207
208
|
|
208
209
|
rubyforge_project: groonga
|
209
|
-
rubygems_version: 1.3.
|
210
|
+
rubygems_version: 1.3.5
|
210
211
|
signing_key:
|
211
212
|
specification_version: 3
|
212
213
|
summary: A library to use groonga with ActiveRecord like API.
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|