activeldap 0.10.0 → 1.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.
- data/CHANGES +6 -30
- data/README +4 -2
- data/Rakefile +7 -0
- data/data/locale/en/LC_MESSAGES/active-ldap.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/active-ldap.mo +0 -0
- data/examples/al-admin/po/en/al-admin.po +3 -3
- data/examples/al-admin/po/ja/al-admin.po +3 -3
- data/examples/al-admin/po/nl/al-admin.po +3 -3
- data/lib/active_ldap/adapter/base.rb +0 -2
- data/lib/active_ldap/base.rb +4 -2
- data/lib/active_ldap/get_text_support.rb +3 -11
- data/lib/active_ldap/operations.rb +1 -0
- data/lib/active_ldap/schema/syntaxes.rb +5 -3
- data/lib/active_ldap/validations.rb +25 -15
- data/lib/active_ldap.rb +1 -1
- data/po/en/active-ldap.po +1 -1
- data/po/ja/active-ldap.po +1 -1
- data/rails/plugin/active_ldap/init.rb +1 -1
- data/test/run-test.rb +2 -0
- data/test/test_base.rb +63 -1
- data/test/test_syntax.rb +3 -2
- data/test-unit-ext/NEWS.en +28 -0
- data/test-unit-ext/NEWS.ja +28 -0
- data/test-unit-ext/README.en +247 -0
- data/test-unit-ext/README.ja +246 -0
- data/test-unit-ext/Rakefile +111 -0
- data/{test → test-unit-ext/lib}/test-unit-ext/always-show-result.rb +0 -0
- data/test-unit-ext/lib/test-unit-ext/assertions.rb +40 -0
- data/test-unit-ext/lib/test-unit-ext/attributes.rb +129 -0
- data/{test → test-unit-ext/lib}/test-unit-ext/backtrace-filter.rb +0 -0
- data/test-unit-ext/lib/test-unit-ext/color.rb +59 -0
- data/test-unit-ext/lib/test-unit-ext/colorized-runner.rb +111 -0
- data/test-unit-ext/lib/test-unit-ext/diff.rb +516 -0
- data/{test → test-unit-ext/lib}/test-unit-ext/long-display-for-emacs.rb +0 -0
- data/test-unit-ext/lib/test-unit-ext/notification.rb +79 -0
- data/test-unit-ext/lib/test-unit-ext/omission.rb +96 -0
- data/test-unit-ext/lib/test-unit-ext/pending.rb +97 -0
- data/{test → test-unit-ext/lib}/test-unit-ext/priority.rb +25 -53
- data/test-unit-ext/lib/test-unit-ext/version.rb +3 -0
- data/test-unit-ext/lib/test-unit-ext/xml-report.rb +224 -0
- data/test-unit-ext/lib/test-unit-ext.rb +16 -0
- data/test-unit-ext/misc/rd2html.rb +42 -0
- data/test-unit-ext/test/run-test.rb +14 -0
- data/test-unit-ext/test/test_attributes.rb +139 -0
- data/test-unit-ext/test/test_color.rb +39 -0
- data/test-unit-ext/test/test_diff.rb +475 -0
- data/test-unit-ext/test/test_notification.rb +32 -0
- data/test-unit-ext/test/test_omission.rb +64 -0
- data/test-unit-ext/test/test_pending.rb +64 -0
- data/test-unit-ext/test/test_priority.rb +88 -0
- data/test-unit-ext/test/test_xml_report.rb +161 -0
- metadata +34 -7
- data/test/test-unit-ext.rb +0 -4
@@ -0,0 +1,247 @@
|
|
1
|
+
# -*- rd -*-
|
2
|
+
|
3
|
+
= README
|
4
|
+
|
5
|
+
== Name
|
6
|
+
|
7
|
+
TestUnitExt
|
8
|
+
|
9
|
+
== What's this?
|
10
|
+
|
11
|
+
TestUnitExt extends the standard Test::Unit.
|
12
|
+
|
13
|
+
TestUnitExt provides some useful features:
|
14
|
+
|
15
|
+
* Emacs friendly backtrace format.
|
16
|
+
* runs tests depending on priority.
|
17
|
+
* supports attributes for each test.
|
18
|
+
* always shows tests result even if tests are interrupted.
|
19
|
+
* colorized output.
|
20
|
+
* outputs diff between expected and actual value.
|
21
|
+
* reports test result as XML format.
|
22
|
+
* adds pending/omission/notification methods.
|
23
|
+
|
24
|
+
== Author
|
25
|
+
|
26
|
+
Kouhei Sutou <kou@cozmixng.org>
|
27
|
+
|
28
|
+
== Licence
|
29
|
+
|
30
|
+
Ruby's.
|
31
|
+
|
32
|
+
# == Mailing list
|
33
|
+
#
|
34
|
+
# None. needed?
|
35
|
+
|
36
|
+
== Reference manual
|
37
|
+
|
38
|
+
((<URL:http://test-unit-ext.rubyforge.org/doc/>))
|
39
|
+
|
40
|
+
== Dependency libraries
|
41
|
+
|
42
|
+
None
|
43
|
+
|
44
|
+
== Usage
|
45
|
+
|
46
|
+
require 'test-unit-ext'
|
47
|
+
|
48
|
+
== Reference
|
49
|
+
|
50
|
+
=== Attributes
|
51
|
+
|
52
|
+
You can add attributes to your test to get more useful
|
53
|
+
information on failure. For example, you can add Bug ID like
|
54
|
+
the following
|
55
|
+
|
56
|
+
class MyTest < Test::Unit::TestCase
|
57
|
+
bug 123
|
58
|
+
def test_invalid_input
|
59
|
+
assert_equal("OK", input)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
In the above example, test_invalid_input test has an
|
64
|
+
attribute that the test is for Bug #123.
|
65
|
+
|
66
|
+
You can also write like the following:
|
67
|
+
|
68
|
+
class MyTest < Test::Unit::TestCase
|
69
|
+
attribute :bug, 123
|
70
|
+
def test_invalid_input
|
71
|
+
assert_equal("OK", input)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
That is, bug method is a convenience method. You can add any
|
76
|
+
attributes to your test if you use attribute method.
|
77
|
+
|
78
|
+
=== Priority
|
79
|
+
|
80
|
+
It will be difficult that you drop into test and develop
|
81
|
+
cycle when you have many tests and the tests take much
|
82
|
+
time. To reduce the problem, you can select some tests from
|
83
|
+
all tests and reduce elapsed time each test. It's a problem
|
84
|
+
that which tests are selected in each test.
|
85
|
+
|
86
|
+
In TestUnitExt, each test has its priority and runs tests
|
87
|
+
are selected by probabilistic method. --priority command
|
88
|
+
line option enables this feature.
|
89
|
+
|
90
|
+
A test that has higher priority will be ran in higher
|
91
|
+
ratio. Each test doesn't run all tests but tests that are
|
92
|
+
ran each test are changed in each test. All tests will be
|
93
|
+
ran after some test and develop cycles.
|
94
|
+
|
95
|
+
Tests that aren't succeeded in the previous test are ran in
|
96
|
+
the current test in spite of its priority. This means that
|
97
|
+
important tests are ran without you do something. You will
|
98
|
+
keep your lightweight test and develop cycles without
|
99
|
+
additional works.
|
100
|
+
|
101
|
+
Here are a sample priority specification. Priority
|
102
|
+
specification effects followed tests like public and
|
103
|
+
private.
|
104
|
+
|
105
|
+
class MyTest < Test::Unit::TestCase
|
106
|
+
priority :must
|
107
|
+
def test_must
|
108
|
+
# will be always ran
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_must2
|
112
|
+
# will be always ran too
|
113
|
+
end
|
114
|
+
|
115
|
+
priority :import
|
116
|
+
def test_import
|
117
|
+
# will be almost ran
|
118
|
+
end
|
119
|
+
|
120
|
+
priority :high
|
121
|
+
def test_high
|
122
|
+
# will be ran in high probability
|
123
|
+
end
|
124
|
+
|
125
|
+
priority :normal
|
126
|
+
def test_normal
|
127
|
+
# will be ran in fifty-fifty probability
|
128
|
+
# tests without priority specification has normal priority
|
129
|
+
end
|
130
|
+
|
131
|
+
priority :low
|
132
|
+
def test_low
|
133
|
+
# will be sometimes ran
|
134
|
+
end
|
135
|
+
|
136
|
+
priority :never
|
137
|
+
def test_never
|
138
|
+
# never be ran
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
=== Pending
|
143
|
+
|
144
|
+
You may write a test for a function that is not
|
145
|
+
implemented. In the case, the test will be failed. It's
|
146
|
+
correct that the test is failed but the test means 'the
|
147
|
+
function is not implemented'. To state your intent, pend
|
148
|
+
method is provided.
|
149
|
+
|
150
|
+
Please state your intent by your test code by using the
|
151
|
+
method.
|
152
|
+
|
153
|
+
class MyTest < Test::Unit::TestCase
|
154
|
+
def test_minor_function
|
155
|
+
pend("Should implement")
|
156
|
+
assert_equal("Good!", MyModule.minor_function)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
=== Omission
|
161
|
+
|
162
|
+
You may write a test only for a special environment. In the
|
163
|
+
case, the test will not work on a standard environment and you
|
164
|
+
know that before you run the test. You will omit the test on
|
165
|
+
a standard environment. To state your intent, omit method is
|
166
|
+
provided.
|
167
|
+
|
168
|
+
Please state your intent by your test code by using the method.
|
169
|
+
|
170
|
+
class MyTest < Test::Unit::TestCase
|
171
|
+
def test_special_function
|
172
|
+
omit("Only for special environment") unless MyModule.special_environment?
|
173
|
+
assert_equal("Good!", MyModule.special_function)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
|
178
|
+
=== Notification
|
179
|
+
|
180
|
+
You may put some messages in test. For example, "this test
|
181
|
+
is omitted because XXX module is not found on the
|
182
|
+
environment."
|
183
|
+
|
184
|
+
Those messages can be displayed by puts but it causes test
|
185
|
+
result output. To prevent this, notify method is
|
186
|
+
provided. notify method doesn't display those messages in
|
187
|
+
the place but display those messages in test result summary
|
188
|
+
like "failure", "error" and so on. You can leave those
|
189
|
+
messages without breaking test result output by using notify
|
190
|
+
method.
|
191
|
+
|
192
|
+
class MyTest < Test::Unit::TestCase
|
193
|
+
def test_with_other_module
|
194
|
+
unless MyModule.have_XXX?
|
195
|
+
notify("XXX module isn't found. skip this test.")
|
196
|
+
return
|
197
|
+
end
|
198
|
+
assert_equal("XXX Module!!!", MyModule.use_XXX)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
=== XML report
|
203
|
+
|
204
|
+
Test result can be reported as XML format if --xml-report
|
205
|
+
option is specified. A reported XML has the following
|
206
|
+
structure:
|
207
|
+
|
208
|
+
<report>
|
209
|
+
<result>
|
210
|
+
<test-case>
|
211
|
+
<name>TEST CASE NAME</name>
|
212
|
+
<description>DESCRIPTION OF TEST CASE (if exists)</description>
|
213
|
+
</test-case>
|
214
|
+
<test>
|
215
|
+
<name>TEST NAME</name>
|
216
|
+
<description>DESCRIPTION OF TEST CASE (if exists)</description>
|
217
|
+
<option><!-- ATTRIBUTE INFORMATION (if exists) -->
|
218
|
+
<name>ATTRIBUTE NAME (e.g.: bug)</name>
|
219
|
+
<value>ATTRIBUTE VALUE (e.g.: 1234)</value>
|
220
|
+
</option>
|
221
|
+
<option>
|
222
|
+
...
|
223
|
+
</option>
|
224
|
+
</test>
|
225
|
+
<status>TEST RESULT ([success|failure|error|pending|notification])</status>
|
226
|
+
<detail>DETAIL OF TEST RESULT (if exists)</detail>
|
227
|
+
<backtrace><!-- BACKTRACE (if exists) -->
|
228
|
+
<entry>
|
229
|
+
<file>FILE NAME</file>
|
230
|
+
<line>LINE</line>
|
231
|
+
<info>ADDITIONAL INFORMATION</info>
|
232
|
+
</entry>
|
233
|
+
<entry>
|
234
|
+
...
|
235
|
+
</entry>
|
236
|
+
</backtrace>
|
237
|
+
<elapsed>ELAPSED TIME (e.g.: 0.000010)</elapsed>
|
238
|
+
</result>
|
239
|
+
<result>
|
240
|
+
...
|
241
|
+
</result>
|
242
|
+
...
|
243
|
+
</report>
|
244
|
+
|
245
|
+
== Thanks
|
246
|
+
|
247
|
+
* ...
|
@@ -0,0 +1,246 @@
|
|
1
|
+
# -*- rd -*-
|
2
|
+
|
3
|
+
= README.ja
|
4
|
+
|
5
|
+
== 名前
|
6
|
+
|
7
|
+
TestUnitExt
|
8
|
+
|
9
|
+
== なにこれ?
|
10
|
+
|
11
|
+
TestUnitExtはRuby標準のTest::Unitを拡張します。
|
12
|
+
|
13
|
+
TestUnitExtはいくつかの有用な機能を提供します。
|
14
|
+
|
15
|
+
* Emacsにやさしいバックトレースフォーマット
|
16
|
+
* 優先度に応じたテストの実行
|
17
|
+
* 各テストへの属性の付加
|
18
|
+
* テストを途中終了(Ctrl+C)しても結果を表示
|
19
|
+
* 色付き出力
|
20
|
+
* テスト結果のdiff出力
|
21
|
+
* テスト結果のXMLでの出力
|
22
|
+
* 保留(pending)・省略(omission)・通知(notification)用メソッドの追加
|
23
|
+
|
24
|
+
== 作者
|
25
|
+
|
26
|
+
Kouhei Sutou <kou@cozmixng.org>
|
27
|
+
|
28
|
+
== ライセンス
|
29
|
+
|
30
|
+
Ruby's.
|
31
|
+
|
32
|
+
# == メーリングリスト
|
33
|
+
#
|
34
|
+
# なし。必要?
|
35
|
+
|
36
|
+
== リファレンスマニュアル
|
37
|
+
|
38
|
+
((<URL:http://test-unit-ext.rubyforge.org/doc/>))
|
39
|
+
|
40
|
+
== 依存ライブラリ
|
41
|
+
|
42
|
+
なし
|
43
|
+
|
44
|
+
== 使用法
|
45
|
+
|
46
|
+
require 'test-unit-ext'
|
47
|
+
|
48
|
+
== リファレンス
|
49
|
+
|
50
|
+
=== 属性
|
51
|
+
|
52
|
+
テストに属性を加えて、テスト失敗時により有益な情報を利用する
|
53
|
+
ことができます。例えば、以下のようにテストにBug IDの情報を付
|
54
|
+
加することができます。
|
55
|
+
|
56
|
+
class MyTest < Test::Unit::TestCase
|
57
|
+
bug 123
|
58
|
+
def test_invalid_input
|
59
|
+
assert_equal("OK", input)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
この例では、test_invalid_inputテストがBug #123のテストである
|
64
|
+
という情報を付加しています。
|
65
|
+
|
66
|
+
これは以下のように書くこともできます。
|
67
|
+
|
68
|
+
class MyTest < Test::Unit::TestCase
|
69
|
+
attribute :bug, 123
|
70
|
+
def test_invalid_input
|
71
|
+
assert_equal("OK", input)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
つまり、bugメソッドは便利のために用意されたメソッドです。
|
76
|
+
attributeメソッドを使うことで任意の属性を付加することができ
|
77
|
+
ます。
|
78
|
+
|
79
|
+
=== 優先度
|
80
|
+
|
81
|
+
テストが多くなるとテスト時間が長くなり、テストと開発をリズム
|
82
|
+
良く繰り返すことが難しくなります。それを軽減するために、開発
|
83
|
+
時のテストでは毎回全てのテストを実行するのではなく、一部のテ
|
84
|
+
ストのみ実行して1回のテスト時間を短くすることができます。問題
|
85
|
+
は各テストでどのテストを実行するかです。
|
86
|
+
|
87
|
+
TestUnitExtでは属性としてテストに優先度を付け、それに従って毎
|
88
|
+
回実行するテストを確率的に選択します。コマンドラインオプショ
|
89
|
+
ンで--priorityを指定するとこの機能が有効になります。
|
90
|
+
|
91
|
+
優先度が高いテスト程高い確率で実行され、そうではないテストは
|
92
|
+
低い頻度で実行されます。各テストでは全てのテストは実行しない
|
93
|
+
が、各テストで実行するテストがその都度変わるため、何度も走ら
|
94
|
+
せることにより結果的にテスト全体を実行することになります。
|
95
|
+
|
96
|
+
また、前回成功しなかったテストは確実に実行するため、明示的に
|
97
|
+
優先度を上げなくても失敗している(現在注目すべき重要な)テス
|
98
|
+
トは毎回必ず実行します。これにより、プログラマの負荷をあげる
|
99
|
+
ことなくテストのメリットを受けたまま、テストと開発のリズムを
|
100
|
+
保つことができます。
|
101
|
+
|
102
|
+
優先度は以下のように指定します。優先度指定はpublicやprivateの
|
103
|
+
ように、以降のメソッド定義に影響します。
|
104
|
+
|
105
|
+
class MyTest < Test::Unit::TestCase
|
106
|
+
priority :must
|
107
|
+
def test_must
|
108
|
+
# 必ず実行
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_must2
|
112
|
+
# これも必ず実行
|
113
|
+
end
|
114
|
+
|
115
|
+
priority :import
|
116
|
+
def test_import
|
117
|
+
# 高い確率で実行
|
118
|
+
end
|
119
|
+
|
120
|
+
priority :high
|
121
|
+
def test_high
|
122
|
+
# やや高い確率で実行
|
123
|
+
end
|
124
|
+
|
125
|
+
priority :normal
|
126
|
+
def test_normal
|
127
|
+
# 半々の確率で実行
|
128
|
+
# 優先度を指定していないときはnormal
|
129
|
+
end
|
130
|
+
|
131
|
+
priority :low
|
132
|
+
def test_low
|
133
|
+
# たまに実行
|
134
|
+
end
|
135
|
+
|
136
|
+
priority :never
|
137
|
+
def test_never
|
138
|
+
# 実行しない
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
=== 保留
|
143
|
+
|
144
|
+
現在はまだ実装していない機能をテストとして書く場合もあります。
|
145
|
+
その場合、まだ実装していない機能のテストは失敗します。たしか
|
146
|
+
にテストは失敗なのですが、そのテストは「実装が間違っている」
|
147
|
+
ではなく、「まだ実装していない」を意図しています。これを明示
|
148
|
+
的に表現するために新しくpendというメソッドを用意しています。
|
149
|
+
|
150
|
+
「現在はまだ実装していない」という場合はこのメソッドを使って、
|
151
|
+
その意図をコードで表現してください。
|
152
|
+
|
153
|
+
class MyTest < Test::Unit::TestCase
|
154
|
+
def test_minor_function
|
155
|
+
pend("Should implement")
|
156
|
+
assert_equal("Good!", MyModule.minor_function)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
=== 省略
|
161
|
+
|
162
|
+
特定の環境でしか動作しないテストを書く場合もあります。その場
|
163
|
+
合、特定の環境以外ではそのテストは失敗します。この場合はその
|
164
|
+
テストは特定の環境以外では失敗することがわかっています。その
|
165
|
+
ため、特定の環境以外ではそのテストは省略します。これを明示的
|
166
|
+
に表現するために新しくomitというメソッドを用意しています。
|
167
|
+
|
168
|
+
「このテストは省略する」という場合はこのメソッドを使って、そ
|
169
|
+
の意図をコードで表現してください。
|
170
|
+
|
171
|
+
class MyTest < Test::Unit::TestCase
|
172
|
+
def test_special_function
|
173
|
+
omit("Only for special environment") unless MyModule.special_environment?
|
174
|
+
assert_equal("Good!", MyModule.special_function)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
=== 通知
|
179
|
+
|
180
|
+
テスト中で何らかのメッセージを残したいことがあります。例えば、
|
181
|
+
「この環境では○○モジュールがないからこのテストは省略しま
|
182
|
+
す」、という場合です。
|
183
|
+
|
184
|
+
それらのメッセージをputsで表示することもできますが、テスト結
|
185
|
+
果の表示が乱れてしまいます。これを防ぐために、新しくnotifyメ
|
186
|
+
ソッドを用意しています。notifyを使うとメッセージはその場では
|
187
|
+
表示されず、テスト終了後に他の「失敗」や「エラー」などと同じ
|
188
|
+
ように表示されます。これにより、テスト結果の表示を乱さずにメッ
|
189
|
+
セージを残すことができます。
|
190
|
+
|
191
|
+
class MyTest < Test::Unit::TestCase
|
192
|
+
def test_with_other_module
|
193
|
+
unless MyModule.have_XXX?
|
194
|
+
notify("XXX module isn't found. skip this test.")
|
195
|
+
return
|
196
|
+
end
|
197
|
+
assert_equal("XXX Module!!!", MyModule.use_XXX)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
=== XML出力
|
202
|
+
|
203
|
+
--xml-reportオプションを指定することでテスト結果をXML形式で出
|
204
|
+
力することができます。出力されるXMLは以下のような構造になって
|
205
|
+
います。
|
206
|
+
|
207
|
+
<report>
|
208
|
+
<result>
|
209
|
+
<test-case>
|
210
|
+
<name>テストケース名</name>
|
211
|
+
<description>テストケースの説明(もしあれば)</description>
|
212
|
+
</test-case>
|
213
|
+
<test>
|
214
|
+
<name>テスト名</name>
|
215
|
+
<description>テストの説明(もしあれば)</description>
|
216
|
+
<option><!-- 属性情報(もしあれば) -->
|
217
|
+
<name>属性名(例: bug)</name>
|
218
|
+
<value>属性値(例: 1234)</value>
|
219
|
+
</option>
|
220
|
+
<option>
|
221
|
+
...
|
222
|
+
</option>
|
223
|
+
</test>
|
224
|
+
<status>テスト結果([success|failure|error|pending|notification])</status>
|
225
|
+
<detail>テスト結果の詳細(もしあれば)</detail>
|
226
|
+
<backtrace><!-- バックトレース(もしあれば) -->
|
227
|
+
<entry>
|
228
|
+
<file>ファイル名</file>
|
229
|
+
<line>行</line>
|
230
|
+
<info>付加情報</info>
|
231
|
+
</entry>
|
232
|
+
<entry>
|
233
|
+
...
|
234
|
+
</entry>
|
235
|
+
</backtrace>
|
236
|
+
<elapsed>実行時間(例: 0.000010)</elapsed>
|
237
|
+
</result>
|
238
|
+
<result>
|
239
|
+
...
|
240
|
+
</result>
|
241
|
+
...
|
242
|
+
</report>
|
243
|
+
|
244
|
+
== 感謝
|
245
|
+
|
246
|
+
* ...
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# -*- mode: ruby; coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'English'
|
4
|
+
|
5
|
+
require 'find'
|
6
|
+
require 'fileutils'
|
7
|
+
require 'rubygems'
|
8
|
+
require 'hoe'
|
9
|
+
|
10
|
+
base_dir = File.join(File.dirname(__FILE__))
|
11
|
+
truncate_base_dir = Proc.new do |x|
|
12
|
+
x.gsub(/^#{Regexp.escape(base_dir + File::SEPARATOR)}/, '')
|
13
|
+
end
|
14
|
+
|
15
|
+
lib_dir = File.join(base_dir, 'lib')
|
16
|
+
$LOAD_PATH.unshift(lib_dir)
|
17
|
+
|
18
|
+
require 'test-unit-ext'
|
19
|
+
|
20
|
+
Test::Unit.run = true
|
21
|
+
|
22
|
+
manifest = File.join(base_dir, "Manifest.txt")
|
23
|
+
manifest_contents = []
|
24
|
+
base_dir_included_components = %w(NEWS.en NEWS.ja README.en README.ja Rakefile)
|
25
|
+
excluded_components = %w(.svn .test-result pkg)
|
26
|
+
excluded_suffixes = %w(.png .ps .pdf .o .so .txt)
|
27
|
+
Find.find(base_dir) do |target|
|
28
|
+
target = truncate_base_dir[target]
|
29
|
+
components = target.split(File::SEPARATOR)
|
30
|
+
if components.size == 1 and !File.directory?(target)
|
31
|
+
next unless base_dir_included_components.include?(components[0])
|
32
|
+
end
|
33
|
+
Find.prune if (excluded_components - components) != excluded_components
|
34
|
+
next if excluded_suffixes.include?(File.extname(target))
|
35
|
+
manifest_contents << target if File.file?(target)
|
36
|
+
end
|
37
|
+
|
38
|
+
dummy_files = %w(History.txt README.txt)
|
39
|
+
FileUtils.touch("History.txt")
|
40
|
+
FileUtils.cp("README.en", "README.txt")
|
41
|
+
|
42
|
+
File.open(manifest, "w") do |f|
|
43
|
+
f.puts manifest_contents.sort.join("\n")
|
44
|
+
end
|
45
|
+
at_exit do
|
46
|
+
FileUtils.rm_f(manifest)
|
47
|
+
FileUtils.rm_f(dummy_files)
|
48
|
+
end
|
49
|
+
|
50
|
+
def cleanup_white_space(entry)
|
51
|
+
entry.gsub(/(\A\n+|\n+\z)/, '') + "\n"
|
52
|
+
end
|
53
|
+
|
54
|
+
version = TestUnitExt::VERSION
|
55
|
+
ENV["VERSION"] = version
|
56
|
+
project = Hoe.new('test-unit-ext', version) do |project|
|
57
|
+
project.rubyforge_name = 'test-unit-ext'
|
58
|
+
project.remote_rdoc_dir = "doc"
|
59
|
+
project.author = ["Kouhei Sutou"]
|
60
|
+
project.email = ['kou@cozmixng.org']
|
61
|
+
project.summary = 'Ruby bindings for cairo'
|
62
|
+
project.url = 'http://test-unit-ext.rubyforge.org/'
|
63
|
+
|
64
|
+
news_of_current_release = File.read("NEWS.en").split(/^==\s.*$/)[1]
|
65
|
+
project.changes = cleanup_white_space(news_of_current_release)
|
66
|
+
|
67
|
+
entries = File.read("README.en").split(/^==\s(.*)$/)
|
68
|
+
whats_this = cleanup_white_space(entries[entries.index("What\'s this?") + 1])
|
69
|
+
project.summary, project.description, = whats_this.split(/\n\n+/, 3)
|
70
|
+
end
|
71
|
+
|
72
|
+
spec = project.spec
|
73
|
+
spec.rdoc_options = spec.rdoc_options.collect do |option|
|
74
|
+
option == "README.txt" ? "README.en" : option
|
75
|
+
end
|
76
|
+
spec.extra_rdoc_files += spec.files.grep(/(:?README|NEWS)\.(:?ja|en)\z/)
|
77
|
+
spec.dependencies.delete_if {|dependency| dependency.name == "hoe"}
|
78
|
+
|
79
|
+
rdoc_task = nil
|
80
|
+
if ObjectSpace.each_object(Rake::RDocTask) {|rdoc_task|} != 1
|
81
|
+
puts "hoe may be changed"
|
82
|
+
end
|
83
|
+
rdoc_task.main = "README.en"
|
84
|
+
rdoc_task.options.delete("-d")
|
85
|
+
rdoc_task.options << "--charset=UTF-8"
|
86
|
+
rdoc_task.template = "kilmer"
|
87
|
+
rdoc_task.rdoc_files += ["README.en", "NEWS.en"]
|
88
|
+
|
89
|
+
desc 'Tag the repository for release.'
|
90
|
+
task :tag do
|
91
|
+
message = "Released TestUnitExt #{version}!"
|
92
|
+
base = "svn+ssh://#{ENV['USER']}@rubyforge.org/var/svn/test-unit-ext/"
|
93
|
+
sh 'svn', 'copy', '-m', message, "#{base}trunk", "#{base}tags/#{version}"
|
94
|
+
end
|
95
|
+
|
96
|
+
desc "Publish static HTML files"
|
97
|
+
task :publish_html do
|
98
|
+
ruby "misc/rd2html.rb"
|
99
|
+
Dir.glob("html/*.html.en") do |html_en|
|
100
|
+
FileUtils.cp(html_en, html_en.sub(/\.en$/, ''))
|
101
|
+
end
|
102
|
+
config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
|
103
|
+
host = "#{config["username"]}@rubyforge.org"
|
104
|
+
remote_dir = "/var/www/gforge-projects/#{project.rubyforge_name}"
|
105
|
+
local_dir = "html"
|
106
|
+
sh "rsync #{project.rsync_args} #{local_dir}/*.html* #{host}:#{remote_dir}"
|
107
|
+
end
|
108
|
+
task :publish_docs => :publish_html
|
109
|
+
|
110
|
+
desc "Distribute new release."
|
111
|
+
task :dist => [:publish_docs, :release, :tag, :announce]
|
File without changes
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "test/unit/testcase"
|
2
|
+
|
3
|
+
module Test
|
4
|
+
module Unit
|
5
|
+
module AssertionsWithDiff
|
6
|
+
def assert_equal(expected, actual, message=nil)
|
7
|
+
super
|
8
|
+
rescue AssertionFailedError
|
9
|
+
expected = PP.pp(expected, "") unless expected.is_a?(String)
|
10
|
+
actual = PP.pp(actual, "") unless actual.is_a?(String)
|
11
|
+
diff = Diff.readable(expected, actual)
|
12
|
+
if /^[\?\-\+].{79}/ =~ diff
|
13
|
+
folded_diff = Diff.readable(fold(expected), fold(actual))
|
14
|
+
diff = "#{diff}\n\nfolded diff:\n#{folded_diff}"
|
15
|
+
end
|
16
|
+
raise $!, "#{$!.message}\n\ndiff:\n#{diff}", $@
|
17
|
+
end
|
18
|
+
|
19
|
+
def fold(string)
|
20
|
+
string.split(/\n/).collect do |line|
|
21
|
+
line.gsub(/(.{78})/, "\\1\n")
|
22
|
+
end.join("\n")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module AdditionalAssertions
|
27
|
+
def assert_boolean(expected)
|
28
|
+
assert([true, false].include?(expected),
|
29
|
+
build_message(nil,
|
30
|
+
"<true or false> expected but was\n<?>",
|
31
|
+
expected))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class TestCase
|
36
|
+
include AssertionsWithDiff
|
37
|
+
include AdditionalAssertions
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|