riel 1.1.10 → 1.1.11
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/riel/dir.rb +9 -7
- data/lib/riel/io.rb +1 -1
- data/lib/riel/optproc.rb +1 -1
- data/lib/riel/pathname.rb +1 -1
- data/lib/riel/text.rb +3 -0
- data/lib/riel.rb +1 -1
- data/test/riel/array_test.rb +2 -2
- data/test/riel/command_test.rb +5 -7
- data/test/riel/date_test.rb +3 -5
- data/test/riel/dir_test.rb +7 -8
- data/test/riel/enumerable_test.rb +10 -13
- data/test/riel/env_test.rb +14 -18
- data/test/riel/file_test.rb +23 -26
- data/test/riel/filetype_test.rb +15 -18
- data/test/riel/hash_test.rb +3 -5
- data/test/riel/integer_test.rb +2 -2
- data/test/riel/io_test.rb +3 -3
- data/test/riel/log_stack_test.rb +5 -31
- data/test/riel/log_test.rb +23 -41
- data/test/riel/matchdata_test.rb +3 -6
- data/test/riel/optproc_test.rb +27 -29
- data/test/riel/pathname_test.rb +7 -10
- data/test/riel/rcfile_test.rb +5 -8
- data/test/riel/regexp_test.rb +11 -13
- data/test/riel/setdiff_test.rb +13 -16
- data/test/riel/size_converter_test.rb +10 -12
- data/test/riel/string_test.rb +32 -34
- data/test/riel/tempfile_test.rb +4 -8
- data/test/riel/text_test.rb +62 -66
- data/test/riel/timer_test.rb +8 -10
- metadata +4 -4
data/lib/riel/dir.rb
CHANGED
@@ -6,14 +6,16 @@ require 'pathname'
|
|
6
6
|
class Dir
|
7
7
|
|
8
8
|
# Returns the home directory, for both Unix and Windows.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
unless RUBY_VERSION.index('1.9')
|
10
|
+
def self.home
|
11
|
+
ENV["HOME"] || begin
|
12
|
+
hd = ENV["HOMEDRIVE"]
|
13
|
+
hp = ENV["HOMEPATH"]
|
14
|
+
if hd || hp
|
15
|
+
(hd || "") + (hp || "\\")
|
16
|
+
end
|
15
17
|
end
|
16
|
-
|
18
|
+
end
|
17
19
|
end
|
18
20
|
|
19
21
|
# Removes directories containing no files or files matching only those in
|
data/lib/riel/io.rb
CHANGED
data/lib/riel/optproc.rb
CHANGED
@@ -302,7 +302,7 @@ module OptProc
|
|
302
302
|
@bestopts[0].set_value args
|
303
303
|
return @bestopts[0]
|
304
304
|
else
|
305
|
-
optstr = @bestopts.collect { |
|
305
|
+
optstr = @bestopts.collect { |y| '(' + y.tags.join(', ') + ')' }.join(', ')
|
306
306
|
$stderr.puts "ERROR: ambiguous match of '#{args[0]}'; matches options: #{optstr}"
|
307
307
|
exit 2
|
308
308
|
end
|
data/lib/riel/pathname.rb
CHANGED
data/lib/riel/text.rb
CHANGED
@@ -226,6 +226,7 @@ module Text
|
|
226
226
|
# Returns the escape sequence for the given names.
|
227
227
|
def names_to_code names
|
228
228
|
str = ""
|
229
|
+
names = [ names ] unless names.kind_of? Array
|
229
230
|
names.each do |name|
|
230
231
|
code = ATTRIBUTES[name]
|
231
232
|
if code
|
@@ -296,6 +297,8 @@ module Text
|
|
296
297
|
def names_to_code names
|
297
298
|
str = ""
|
298
299
|
|
300
|
+
names = [ names ] unless names.kind_of? Array
|
301
|
+
|
299
302
|
names.each do |name|
|
300
303
|
@stack << name
|
301
304
|
|
data/lib/riel.rb
CHANGED
data/test/riel/array_test.rb
CHANGED
data/test/riel/command_test.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
-
require '
|
4
|
+
require 'test/unit'
|
5
5
|
require 'riel/command'
|
6
6
|
|
7
|
-
class CommandTestCase <
|
8
|
-
|
7
|
+
class CommandTestCase < Test::Unit::TestCase
|
9
8
|
def test_all
|
10
9
|
assert_equal [ "/bin/ls\n" ], Command.run("ls", "/bin/ls")
|
11
10
|
assert_equal [ "/bin/grep\n", "/bin/ls\n" ], Command.run("ls", "/bin/ls", "/bin/grep" )
|
@@ -13,16 +12,15 @@ class CommandTestCase < RUNIT::TestCase
|
|
13
12
|
lnum = 0
|
14
13
|
expected = [ "/bin/grep\n", "/bin/ls\n" ]
|
15
14
|
lines = Command.run("ls", "/bin/ls", "/bin/grep" ) do |line|
|
16
|
-
|
15
|
+
assert_equal expected[lnum], line
|
17
16
|
lnum += 1
|
18
17
|
end
|
19
18
|
assert_equal expected, lines
|
20
19
|
|
21
20
|
expected = [ "/bin/grep\n", "/bin/ls\n" ]
|
22
|
-
lines = Command.run("ls", "/bin/ls", "/bin/grep" ) do |line,
|
23
|
-
|
21
|
+
lines = Command.run("ls", "/bin/ls", "/bin/grep" ) do |line, ln|
|
22
|
+
assert_equal expected[ln], line
|
24
23
|
end
|
25
24
|
assert_equal expected, lines
|
26
25
|
end
|
27
|
-
|
28
26
|
end
|
data/test/riel/date_test.rb
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
-
require '
|
4
|
+
require 'test/unit'
|
5
5
|
require 'riel/date'
|
6
6
|
|
7
|
-
class DateTestCase <
|
8
|
-
|
9
|
-
def test
|
7
|
+
class DateTestCase < Test::Unit::TestCase
|
8
|
+
def test_simple
|
10
9
|
assert_equal 28, Date.days_in_month(2010, 2)
|
11
10
|
assert_equal 31, Date.days_in_month(2010, 1)
|
12
11
|
assert_equal 29, Date.days_in_month(2008, 2)
|
13
12
|
assert_equal 30, Date.days_in_month(2007, 6)
|
14
13
|
assert_equal 31, Date.days_in_month(2010, 12)
|
15
14
|
end
|
16
|
-
|
17
15
|
end
|
data/test/riel/dir_test.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
-
require '
|
4
|
+
require 'test/unit'
|
5
5
|
require 'pathname'
|
6
6
|
require 'riel/dir'
|
7
7
|
require 'riel/file'
|
8
8
|
|
9
|
-
class DirTestCase <
|
10
|
-
|
9
|
+
class DirTestCase < Test::Unit::TestCase
|
11
10
|
def test_home
|
12
11
|
assert_equal ENV["HOME"], Dir.home
|
13
12
|
end
|
@@ -15,7 +14,7 @@ class DirTestCase < RUNIT::TestCase
|
|
15
14
|
def test_remove_if_empty
|
16
15
|
# set up a mess of files in /tmp ...
|
17
16
|
|
18
|
-
tmpdir = Pathname.new
|
17
|
+
tmpdir = Pathname.new '/tmp'
|
19
18
|
|
20
19
|
# maybe this isn't Linux (poor devils!):
|
21
20
|
return unless tmpdir.exist?
|
@@ -46,7 +45,7 @@ class DirTestCase < RUNIT::TestCase
|
|
46
45
|
adir.mkdir
|
47
46
|
end
|
48
47
|
|
49
|
-
Dir.remove_if_empty
|
48
|
+
Dir.remove_if_empty a, :verbose => false
|
50
49
|
|
51
50
|
assert !a.exist?
|
52
51
|
|
@@ -65,7 +64,7 @@ class DirTestCase < RUNIT::TestCase
|
|
65
64
|
end
|
66
65
|
end
|
67
66
|
|
68
|
-
Dir.remove_if_empty
|
67
|
+
Dir.remove_if_empty a
|
69
68
|
assert a.exist?
|
70
69
|
|
71
70
|
Dir.remove_if_empty(a, :deletable => [ %r{aa\d+} ])
|
@@ -87,10 +86,10 @@ class DirTestCase < RUNIT::TestCase
|
|
87
86
|
end
|
88
87
|
end
|
89
88
|
|
90
|
-
Dir.remove_if_empty
|
89
|
+
Dir.remove_if_empty a
|
91
90
|
assert a.exist?
|
92
91
|
|
93
|
-
Dir.remove_if_empty
|
92
|
+
Dir.remove_if_empty a, :deletable => %w{ foo.bar }
|
94
93
|
assert !a.exist?
|
95
94
|
|
96
95
|
testdir.delete
|
@@ -1,27 +1,24 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
-
require '
|
5
|
-
require 'rubyunit'
|
4
|
+
require 'test/unit'
|
6
5
|
require 'riel/enumerable'
|
7
6
|
|
8
|
-
class EnumerableTestCase <
|
9
|
-
|
7
|
+
class EnumerableTestCase < Test::Unit::TestCase
|
10
8
|
def test_collect_with_index
|
11
|
-
|
12
|
-
|
9
|
+
assert_equal [ 0, 5, 12, 21, 32 ], (4 .. 8).collect_with_index { |val, idx| val * idx }
|
10
|
+
assert_equal [ "", "b", "cc", "ddd" ], ('a' .. 'd').collect_with_index { |str, idx| str * idx }
|
13
11
|
end
|
14
12
|
|
15
13
|
def test_select_with_index
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
assert_equal [ 5, 6, 7, 8 ], (4 .. 8).select_with_index { |val, idx| val >= 5 }
|
15
|
+
assert_equal [ 6 ], (4 .. 8).select_with_index { |val, idx| val * idx == 12 }
|
16
|
+
assert_equal [], (4 .. 8).select_with_index { |val, idx| idx - val > 0 }
|
19
17
|
end
|
20
18
|
|
21
19
|
def test_detect_with_index
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
assert_equal 5, (4 .. 8).detect_with_index { |val, idx| val >= 5 }
|
21
|
+
assert_equal 6, (4 .. 8).detect_with_index { |val, idx| val * idx == 12 }
|
22
|
+
assert_equal nil, (4 .. 8).detect_with_index { |val, idx| idx - val > 0 }
|
25
23
|
end
|
26
|
-
|
27
24
|
end
|
data/test/riel/env_test.rb
CHANGED
@@ -1,52 +1,48 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
-
require '
|
4
|
+
require 'test/unit'
|
5
5
|
require 'riel/env'
|
6
6
|
|
7
|
-
class EnvTestCase <
|
8
|
-
|
7
|
+
class EnvTestCase < Test::Unit::TestCase
|
9
8
|
def test_home_directory
|
10
9
|
# Unix
|
11
10
|
|
12
11
|
ENV["HOME"] = "/home/me"
|
13
12
|
|
14
|
-
|
13
|
+
assert_equal "/home/me", Env.home_directory
|
15
14
|
|
16
15
|
# Windows
|
17
16
|
|
18
17
|
ENV["HOME"] = nil
|
19
18
|
ENV["HOMEDRIVE"] = "c:"
|
20
19
|
|
21
|
-
|
20
|
+
assert_equal "c:\\", Env.home_directory
|
22
21
|
|
23
22
|
ENV["HOME"] = nil
|
24
23
|
ENV["HOMEDRIVE"] = nil
|
25
24
|
ENV["HOMEPATH"] = "\\Program Files\\User"
|
26
25
|
|
27
|
-
|
26
|
+
assert_equal "\\Program Files\\User", Env.home_directory
|
28
27
|
|
29
28
|
ENV["HOME"] = nil
|
30
29
|
ENV["HOMEDRIVE"] = "c:"
|
31
30
|
ENV["HOMEPATH"] = "\\Program Files\\User"
|
32
31
|
|
33
|
-
#
|
32
|
+
# assert_equal "c:\\Program Files\\User", Env.home_directory
|
34
33
|
end
|
35
34
|
|
36
|
-
def
|
35
|
+
def run_split_test expected, input
|
37
36
|
ENV["FOO"] = input
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
assert_equals expected, result
|
37
|
+
result = Env.split "FOO"
|
38
|
+
assert_equal expected, result
|
42
39
|
end
|
43
40
|
|
44
41
|
def test_split
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
42
|
+
run_split_test %w{ testing }, "testing"
|
43
|
+
run_split_test %w{ this is }, "this is"
|
44
|
+
run_split_test %w{ this is }, '"this" "is"'
|
45
|
+
run_split_test %w{ this is a test }, '"this" "is" \'a\' "test"'
|
46
|
+
run_split_test %w{ this is a tes't }, '"this" "is" \'a\' "tes\'t"'
|
50
47
|
end
|
51
|
-
|
52
48
|
end
|
data/test/riel/file_test.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
-
require '
|
4
|
+
require 'test/unit'
|
5
5
|
require 'riel/file'
|
6
6
|
require 'riel/tempfile'
|
7
7
|
require 'pathname'
|
8
8
|
|
9
|
-
|
10
|
-
class FileTestCase < RUNIT::TestCase
|
9
|
+
class FileTestCase < Test::Unit::TestCase
|
11
10
|
|
12
11
|
def get_file_rootname
|
13
12
|
Pathname.new(__FILE__).rootname
|
@@ -28,7 +27,7 @@ class FileTestCase < RUNIT::TestCase
|
|
28
27
|
|
29
28
|
tempname = nil
|
30
29
|
|
31
|
-
if File.exist?
|
30
|
+
if File.exist? stringio_so
|
32
31
|
rootname = Pathname.new(__FILE__).rootname
|
33
32
|
tempname = Tempfile.open(rootname) do |tf|
|
34
33
|
tf.write IO.read(stringio_so)
|
@@ -42,12 +41,12 @@ class FileTestCase < RUNIT::TestCase
|
|
42
41
|
|
43
42
|
def test_file_types
|
44
43
|
text_file = create_text_file
|
45
|
-
assert
|
46
|
-
assert
|
44
|
+
assert File.text?(text_file)
|
45
|
+
assert !File.binary?(text_file)
|
47
46
|
|
48
47
|
if binary_file = create_binary_file
|
49
|
-
assert
|
50
|
-
assert
|
48
|
+
assert !File.text?(binary_file)
|
49
|
+
assert File.binary?(binary_file)
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
@@ -56,18 +55,17 @@ class FileTestCase < RUNIT::TestCase
|
|
56
55
|
|
57
56
|
dir = Pathname.new(file).dirname
|
58
57
|
|
59
|
-
assert
|
60
|
-
assert
|
58
|
+
assert File.is_file?(file)
|
59
|
+
assert !File.is_file?(dir)
|
61
60
|
|
62
|
-
assert
|
63
|
-
assert
|
61
|
+
assert !File.is_directory?(file)
|
62
|
+
assert File.is_directory?(dir)
|
64
63
|
|
65
64
|
# this should have access only by root:
|
66
65
|
|
67
66
|
file = "/var/log/httpd/error_log"
|
68
|
-
assert
|
69
|
-
assert
|
70
|
-
|
67
|
+
assert !File.is_file?(file)
|
68
|
+
assert !File.is_directory?(file)
|
71
69
|
end
|
72
70
|
|
73
71
|
def test_read_write_file
|
@@ -82,7 +80,7 @@ class FileTestCase < RUNIT::TestCase
|
|
82
80
|
line = ln
|
83
81
|
end
|
84
82
|
|
85
|
-
assert_equal
|
83
|
+
assert_equal "hello, world", line
|
86
84
|
end
|
87
85
|
|
88
86
|
def test_read_put_file
|
@@ -97,7 +95,7 @@ class FileTestCase < RUNIT::TestCase
|
|
97
95
|
line = ln
|
98
96
|
end
|
99
97
|
|
100
|
-
assert_equal
|
98
|
+
assert_equal "hello, world\n", line
|
101
99
|
|
102
100
|
File.put_file(filename) do
|
103
101
|
[
|
@@ -111,13 +109,13 @@ class FileTestCase < RUNIT::TestCase
|
|
111
109
|
lines << ln
|
112
110
|
end
|
113
111
|
|
114
|
-
assert_equal
|
112
|
+
assert_equal [ "hello, world\n", "this is a test\n" ] , lines
|
115
113
|
end
|
116
114
|
|
117
115
|
def test_open_via_temp_file
|
118
116
|
fname = "/tmp/test_open_via_temp_file.#{$$}"
|
119
117
|
|
120
|
-
pn = Pathname.new
|
118
|
+
pn = Pathname.new fname
|
121
119
|
|
122
120
|
assert !pn.exist?
|
123
121
|
|
@@ -166,13 +164,13 @@ class FileTestCase < RUNIT::TestCase
|
|
166
164
|
assert file.exist?
|
167
165
|
end
|
168
166
|
|
169
|
-
File.move_files
|
167
|
+
File.move_files tgt, srcfiles
|
170
168
|
|
171
|
-
assert_files_existence
|
169
|
+
assert_files_existence false, srcfiles
|
172
170
|
|
173
171
|
tgtfiles = fnums.collect { |num| tgt + "movefile#{num}" }
|
174
172
|
|
175
|
-
assert_files_existence
|
173
|
+
assert_files_existence true, tgtfiles
|
176
174
|
ensure
|
177
175
|
if tgt && tgt.exist?
|
178
176
|
tgt.children.each do |child|
|
@@ -217,13 +215,13 @@ class FileTestCase < RUNIT::TestCase
|
|
217
215
|
assert file.exist?
|
218
216
|
end
|
219
217
|
|
220
|
-
File.copy_files
|
218
|
+
File.copy_files tgt, srcfiles
|
221
219
|
|
222
|
-
assert_files_existence
|
220
|
+
assert_files_existence true, srcfiles
|
223
221
|
|
224
222
|
tgtfiles = fnums.collect { |num| tgt + "copyfile#{num}" }
|
225
223
|
|
226
|
-
assert_files_existence
|
224
|
+
assert_files_existence true, tgtfiles
|
227
225
|
ensure
|
228
226
|
if tgt && tgt.exist?
|
229
227
|
tgt.children.each do |child|
|
@@ -238,5 +236,4 @@ class FileTestCase < RUNIT::TestCase
|
|
238
236
|
end
|
239
237
|
end
|
240
238
|
end
|
241
|
-
|
242
239
|
end
|
data/test/riel/filetype_test.rb
CHANGED
@@ -1,32 +1,29 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
-
require '
|
4
|
+
require 'test/unit'
|
5
5
|
require 'riel/filetype'
|
6
6
|
|
7
|
-
|
8
|
-
class FileTypeTestCase < RUNIT::TestCase
|
9
|
-
|
7
|
+
class FileTypeTestCase < Test::Unit::TestCase
|
10
8
|
def test_default_extensions
|
11
9
|
ft = FileType.instance
|
12
10
|
|
13
|
-
assert
|
11
|
+
assert ft.text_extensions.include?("rb")
|
14
12
|
|
15
|
-
assert
|
16
|
-
assert
|
17
|
-
assert
|
18
|
-
assert
|
13
|
+
assert !ft.text_extensions.include?("rbx")
|
14
|
+
assert !ft.text_extensions.include?("tar")
|
15
|
+
assert !ft.text_extensions.include?("jar")
|
16
|
+
assert !ft.text_extensions.include?("gz")
|
19
17
|
|
20
|
-
assert
|
21
|
-
assert
|
22
|
-
assert
|
18
|
+
assert ft.nontext_extensions.include?("tar")
|
19
|
+
assert ft.nontext_extensions.include?("jar")
|
20
|
+
assert ft.nontext_extensions.include?("gz")
|
23
21
|
|
24
|
-
ft.set_extensions
|
25
|
-
assert
|
22
|
+
ft.set_extensions true, "rbx"
|
23
|
+
assert ft.text_extensions.include?("rbx")
|
26
24
|
|
27
|
-
ft.set_extensions
|
28
|
-
assert
|
29
|
-
assert
|
25
|
+
ft.set_extensions true, "foo", "bar"
|
26
|
+
assert ft.text_extensions.include?("foo")
|
27
|
+
assert ft.text_extensions.include?("bar")
|
30
28
|
end
|
31
|
-
|
32
29
|
end
|
data/test/riel/hash_test.rb
CHANGED
data/test/riel/integer_test.rb
CHANGED
@@ -8,11 +8,11 @@ module PVN
|
|
8
8
|
def setup
|
9
9
|
end
|
10
10
|
|
11
|
-
def assert_true boolean, message =
|
11
|
+
def assert_true boolean, message = ""
|
12
12
|
assert boolean, message
|
13
13
|
end
|
14
14
|
|
15
|
-
def assert_false boolean, message =
|
15
|
+
def assert_false boolean, message = ""
|
16
16
|
assert !boolean, message
|
17
17
|
end
|
18
18
|
|
data/test/riel/io_test.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
#!/usr/bin/ruby -w
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
-
require '
|
4
|
+
require 'test/unit'
|
5
5
|
require 'riel/io'
|
6
6
|
|
7
|
-
class IOTestCase <
|
7
|
+
class IOTestCase < Test::Unit::TestCase
|
8
8
|
def xtest_readlines
|
9
9
|
orig = $/
|
10
10
|
|
11
11
|
$/ = nil
|
12
12
|
|
13
|
-
contents = IO.readlines
|
13
|
+
contents = IO.readlines __FILE__
|
14
14
|
|
15
15
|
assert_not_nil contents
|
16
16
|
assert contents.size > 0
|
data/test/riel/log_stack_test.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
4
|
require 'pathname'
|
5
|
-
require '
|
5
|
+
require 'test/unit'
|
6
6
|
require 'stringio'
|
7
7
|
require 'riel/log'
|
8
8
|
|
@@ -35,7 +35,7 @@ class LogInner
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
class LogStackTestCase <
|
38
|
+
class LogStackTestCase < Test::Unit::TestCase
|
39
39
|
include Loggable
|
40
40
|
|
41
41
|
def test_stack
|
@@ -53,37 +53,13 @@ class LogStackTestCase < RUNIT::TestCase
|
|
53
53
|
"[ ...: 14] {LogAbyss#squeal } turtles all the way down",
|
54
54
|
"[ ...: 24] {speak } ",
|
55
55
|
"[ ...: 34] {screech } ",
|
56
|
-
"[ ...: 46] {test_stack } ",
|
57
|
-
"[ ...: 104] {call } ",
|
58
|
-
"[ ...: 104] {run_test } ",
|
59
|
-
"[ ...: 82] {test_stack } ",
|
60
|
-
"[ ...testcase.rb: 78] {__send__ } ",
|
61
|
-
"[ ...testcase.rb: 78] {run } ",
|
62
|
-
"[ ...testcase.rb: 42] {run } ",
|
63
|
-
"[...testsuite.rb: 34] {run } ",
|
64
|
-
"[...testsuite.rb: 33] {each } ",
|
65
|
-
"[...testsuite.rb: 33] {run } ",
|
66
|
-
"[...testsuite.rb: 23] {run } ",
|
67
|
-
"[...testsuite.rb: 34] {run } ",
|
68
|
-
"[...testsuite.rb: 33] {each } ",
|
69
|
-
"[...testsuite.rb: 33] {run } ",
|
70
|
-
"[ ...: 46] {run_suite } ",
|
71
|
-
"[ ...: 67] {start_mediator } ",
|
72
|
-
"[ ...: 41] {start } ",
|
73
|
-
"[ ...: 29] {run } ",
|
74
|
-
"[ ...: 216] {run } ",
|
75
|
-
"[ ...: 12] {run } ",
|
76
|
-
# nil means to ignore these lines, which in this case is
|
77
|
-
# because this is deep in the unit test code:
|
78
|
-
nil,
|
79
|
-
nil,
|
80
56
|
]
|
81
57
|
|
82
58
|
run_test @verbose_setup, log, *expected_output
|
83
59
|
end
|
84
60
|
|
85
61
|
# the ctor is down here so the lines above are less likely to change.
|
86
|
-
def initialize test, name
|
62
|
+
def initialize test, name = nil
|
87
63
|
@nonverbose_setup = Proc.new {
|
88
64
|
Log.verbose = false
|
89
65
|
Log.output = StringIO.new
|
@@ -94,7 +70,7 @@ class LogStackTestCase < RUNIT::TestCase
|
|
94
70
|
Log.output = StringIO.new
|
95
71
|
}
|
96
72
|
|
97
|
-
super
|
73
|
+
super test
|
98
74
|
end
|
99
75
|
|
100
76
|
def run_test setup, log, *expected
|
@@ -111,11 +87,9 @@ class LogStackTestCase < RUNIT::TestCase
|
|
111
87
|
|
112
88
|
puts lines
|
113
89
|
|
114
|
-
assert_equals expected.size, lines.size, "number of lines of output"
|
115
|
-
|
116
90
|
(0 ... expected.size).each do |idx|
|
117
91
|
if expected[idx]
|
118
|
-
|
92
|
+
assert_equal expected[idx], lines[idx], "index: #{idx}"
|
119
93
|
end
|
120
94
|
end
|
121
95
|
|