elliottcable-echoe 3.1.2 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. data/CHANGELOG +3 -1
  2. data/Manifest +1 -93
  3. data/Rakefile +1 -2
  4. data/echoe.gemspec +7 -7
  5. data/lib/echoe.rb +50 -22
  6. data/lib/echoe/net.rb +7 -0
  7. data/lib/echoe/platform.rb +27 -25
  8. data/vendor/rake/lib/rake/contrib/sshpublisher.rb +0 -4
  9. metadata +7 -96
  10. data/vendor/rake/CHANGES +0 -400
  11. data/vendor/rake/README +0 -285
  12. data/vendor/rake/Rakefile +0 -418
  13. data/vendor/rake/TODO +0 -20
  14. data/vendor/rake/bin/rake +0 -31
  15. data/vendor/rake/doc/example/Rakefile1 +0 -38
  16. data/vendor/rake/doc/example/Rakefile2 +0 -35
  17. data/vendor/rake/doc/example/a.c +0 -6
  18. data/vendor/rake/doc/example/b.c +0 -6
  19. data/vendor/rake/doc/example/main.c +0 -11
  20. data/vendor/rake/doc/glossary.rdoc +0 -51
  21. data/vendor/rake/doc/jamis.rb +0 -591
  22. data/vendor/rake/doc/proto_rake.rdoc +0 -127
  23. data/vendor/rake/doc/rake.1.gz +0 -0
  24. data/vendor/rake/doc/rakefile.rdoc +0 -534
  25. data/vendor/rake/doc/rational.rdoc +0 -151
  26. data/vendor/rake/doc/release_notes/rake-0.4.14.rdoc +0 -23
  27. data/vendor/rake/doc/release_notes/rake-0.4.15.rdoc +0 -35
  28. data/vendor/rake/doc/release_notes/rake-0.5.0.rdoc +0 -53
  29. data/vendor/rake/doc/release_notes/rake-0.5.3.rdoc +0 -78
  30. data/vendor/rake/doc/release_notes/rake-0.5.4.rdoc +0 -46
  31. data/vendor/rake/doc/release_notes/rake-0.6.0.rdoc +0 -141
  32. data/vendor/rake/doc/release_notes/rake-0.7.0.rdoc +0 -119
  33. data/vendor/rake/doc/release_notes/rake-0.7.1.rdoc +0 -59
  34. data/vendor/rake/doc/release_notes/rake-0.7.2.rdoc +0 -121
  35. data/vendor/rake/doc/release_notes/rake-0.7.3.rdoc +0 -47
  36. data/vendor/rake/doc/release_notes/rake-0.8.0.rdoc +0 -114
  37. data/vendor/rake/doc/release_notes/rake-0.8.2.rdoc +0 -165
  38. data/vendor/rake/doc/release_notes/rake-0.8.3.rdoc +0 -112
  39. data/vendor/rake/install.rb +0 -88
  40. data/vendor/rake/lib/rake.rb +0 -2468
  41. data/vendor/rake/lib/rake/classic_namespace.rb +0 -8
  42. data/vendor/rake/lib/rake/clean.rb +0 -33
  43. data/vendor/rake/lib/rake/gempackagetask.rb +0 -103
  44. data/vendor/rake/lib/rake/loaders/makefile.rb +0 -35
  45. data/vendor/rake/lib/rake/packagetask.rb +0 -185
  46. data/vendor/rake/lib/rake/rake_test_loader.rb +0 -5
  47. data/vendor/rake/lib/rake/rdoctask.rb +0 -147
  48. data/vendor/rake/lib/rake/ruby182_test_unit_fix.rb +0 -23
  49. data/vendor/rake/lib/rake/runtest.rb +0 -23
  50. data/vendor/rake/lib/rake/tasklib.rb +0 -23
  51. data/vendor/rake/lib/rake/testtask.rb +0 -161
  52. data/vendor/rake/lib/rake/win32.rb +0 -54
  53. data/vendor/rake/test/capture_stdout.rb +0 -26
  54. data/vendor/rake/test/check_expansion.rb +0 -5
  55. data/vendor/rake/test/contrib/test_sys.rb +0 -47
  56. data/vendor/rake/test/data/chains/Rakefile +0 -15
  57. data/vendor/rake/test/data/default/Rakefile +0 -19
  58. data/vendor/rake/test/data/dryrun/Rakefile +0 -22
  59. data/vendor/rake/test/data/file_creation_task/Rakefile +0 -33
  60. data/vendor/rake/test/data/imports/Rakefile +0 -19
  61. data/vendor/rake/test/data/imports/deps.mf +0 -1
  62. data/vendor/rake/test/data/multidesc/Rakefile +0 -17
  63. data/vendor/rake/test/data/namespace/Rakefile +0 -57
  64. data/vendor/rake/test/data/rakelib/test1.rb +0 -3
  65. data/vendor/rake/test/data/rbext/rakefile.rb +0 -3
  66. data/vendor/rake/test/data/sample.mf +0 -12
  67. data/vendor/rake/test/data/statusreturn/Rakefile +0 -8
  68. data/vendor/rake/test/data/unittest/Rakefile +0 -1
  69. data/vendor/rake/test/filecreation.rb +0 -32
  70. data/vendor/rake/test/functional.rb +0 -15
  71. data/vendor/rake/test/in_environment.rb +0 -30
  72. data/vendor/rake/test/rake_test_setup.rb +0 -10
  73. data/vendor/rake/test/reqfile.rb +0 -3
  74. data/vendor/rake/test/reqfile2.rb +0 -3
  75. data/vendor/rake/test/session_functional.rb +0 -337
  76. data/vendor/rake/test/shellcommand.rb +0 -3
  77. data/vendor/rake/test/test_application.rb +0 -694
  78. data/vendor/rake/test/test_clean.rb +0 -14
  79. data/vendor/rake/test/test_definitions.rb +0 -82
  80. data/vendor/rake/test/test_earlytime.rb +0 -35
  81. data/vendor/rake/test/test_extension.rb +0 -63
  82. data/vendor/rake/test/test_file_creation_task.rb +0 -62
  83. data/vendor/rake/test/test_file_task.rb +0 -139
  84. data/vendor/rake/test/test_filelist.rb +0 -618
  85. data/vendor/rake/test/test_fileutils.rb +0 -250
  86. data/vendor/rake/test/test_ftp.rb +0 -59
  87. data/vendor/rake/test/test_invocation_chain.rb +0 -75
  88. data/vendor/rake/test/test_makefile_loader.rb +0 -25
  89. data/vendor/rake/test/test_multitask.rb +0 -45
  90. data/vendor/rake/test/test_namespace.rb +0 -36
  91. data/vendor/rake/test/test_package_task.rb +0 -116
  92. data/vendor/rake/test/test_pathmap.rb +0 -209
  93. data/vendor/rake/test/test_rake.rb +0 -41
  94. data/vendor/rake/test/test_require.rb +0 -33
  95. data/vendor/rake/test/test_rules.rb +0 -347
  96. data/vendor/rake/test/test_task_arguments.rb +0 -89
  97. data/vendor/rake/test/test_task_manager.rb +0 -170
  98. data/vendor/rake/test/test_tasklib.rb +0 -12
  99. data/vendor/rake/test/test_tasks.rb +0 -371
  100. data/vendor/rake/test/test_test_task.rb +0 -75
  101. data/vendor/rake/test/test_top_level_functions.rb +0 -84
  102. data/vendor/rake/test/test_win32.rb +0 -57
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- exit((ARGV[0] || "0").to_i)
@@ -1,694 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- begin
4
- require 'rubygems'
5
- rescue LoadError
6
- # got no gems
7
- end
8
-
9
- require 'test/unit'
10
- require 'rake'
11
- require 'test/rake_test_setup'
12
- require 'test/capture_stdout'
13
- require 'test/in_environment'
14
-
15
- TESTING_REQUIRE = [ ]
16
-
17
- ######################################################################
18
- class TestApplication < Test::Unit::TestCase
19
- include CaptureStdout
20
- include InEnvironment
21
-
22
- def setup
23
- @app = Rake::Application.new
24
- @app.options.rakelib = []
25
- end
26
-
27
- def test_constant_warning
28
- err = capture_stderr do @app.instance_eval { const_warning("Task") } end
29
- assert_match(/warning/i, err)
30
- assert_match(/deprecated/i, err)
31
- assert_match(/Task/i, err)
32
- end
33
-
34
- def test_display_tasks
35
- @app.options.show_task_pattern = //
36
- @app.last_description = "COMMENT"
37
- @app.define_task(Rake::Task, "t")
38
- out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
39
- assert_match(/^rake t/, out)
40
- assert_match(/# COMMENT/, out)
41
- end
42
-
43
- def test_display_tasks_with_long_comments
44
- in_environment('RAKE_COLUMNS' => '80') do
45
- @app.options.show_task_pattern = //
46
- @app.last_description = "1234567890" * 8
47
- @app.define_task(Rake::Task, "t")
48
- out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
49
- assert_match(/^rake t/, out)
50
- assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
51
- end
52
- end
53
-
54
- def test_display_tasks_with_task_name_wider_than_tty_display
55
- in_environment('RAKE_COLUMNS' => '80') do
56
- @app.options.show_task_pattern = //
57
- description = "something short"
58
- task_name = "task name" * 80
59
- @app.last_description = "something short"
60
- @app.define_task(Rake::Task, task_name )
61
- out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
62
- # Ensure the entire task name is output and we end up showing no description
63
- assert_match(/rake #{task_name} # .../, out)
64
- end
65
- end
66
-
67
- def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comment
68
- @app.options.show_task_pattern = //
69
- @app.tty_output = false
70
- description = "something short"
71
- task_name = "task name" * 80
72
- @app.last_description = "something short"
73
- @app.define_task(Rake::Task, task_name )
74
- out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
75
- # Ensure the entire task name is output and we end up showing no description
76
- assert_match(/rake #{task_name} # #{description}/, out)
77
- end
78
-
79
- def test_display_tasks_with_long_comments_to_a_non_tty_shows_entire_comment
80
- @app.options.show_task_pattern = //
81
- @app.tty_output = false
82
- @app.last_description = "1234567890" * 8
83
- @app.define_task(Rake::Task, "t")
84
- out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
85
- assert_match(/^rake t/, out)
86
- assert_match(/# #{@app.last_description}/, out)
87
- end
88
-
89
- def test_display_tasks_with_long_comments_to_a_non_tty_with_columns_set_truncates_comments
90
- in_environment("RAKE_COLUMNS" => '80') do
91
- @app.options.show_task_pattern = //
92
- @app.tty_output = false
93
- @app.last_description = "1234567890" * 8
94
- @app.define_task(Rake::Task, "t")
95
- out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
96
- assert_match(/^rake t/, out)
97
- assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
98
- end
99
- end
100
-
101
- def test_display_tasks_with_full_descriptions
102
- @app.options.show_task_pattern = //
103
- @app.options.full_description = true
104
- @app.last_description = "COMMENT"
105
- @app.define_task(Rake::Task, "t")
106
- out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
107
- assert_match(/^rake t$/, out)
108
- assert_match(/^ {4}COMMENT$/, out)
109
- end
110
-
111
- def test_finding_rakefile
112
- assert_match(/[Rr]akefile/, @app.instance_eval { have_rakefile })
113
- end
114
-
115
- def test_not_finding_rakefile
116
- @app.instance_eval { @rakefiles = ['NEVER_FOUND'] }
117
- assert( ! @app.instance_eval do have_rakefile end )
118
- assert_nil @app.rakefile
119
- end
120
-
121
- def test_load_rakefile
122
- in_environment("PWD" => "test/data/unittest") do
123
- @app.instance_eval do
124
- handle_options
125
- options.silent = true
126
- load_rakefile
127
- end
128
- assert_equal "rakefile", @app.rakefile.downcase
129
- assert_match(%r(unittest$), Dir.pwd)
130
- end
131
- end
132
-
133
- def test_load_rakefile_from_subdir
134
- in_environment("PWD" => "test/data/unittest/subdir") do
135
- @app.instance_eval do
136
- handle_options
137
- options.silent = true
138
- load_rakefile
139
- end
140
- assert_equal "rakefile", @app.rakefile.downcase
141
- assert_match(%r(unittest$), Dir.pwd)
142
- end
143
- end
144
-
145
- def test_load_rakefile_not_found
146
- in_environment("PWD" => "/", "RAKE_SYSTEM" => 'not_exist') do
147
- @app.instance_eval do
148
- handle_options
149
- options.silent = true
150
- end
151
- ex = assert_raise(RuntimeError) do
152
- @app.instance_eval do raw_load_rakefile end
153
- end
154
- assert_match(/no rakefile found/i, ex.message)
155
- end
156
- end
157
-
158
- def test_load_from_system_rakefile
159
- in_environment('RAKE_SYSTEM' => 'test/data/sys') do
160
- @app.options.rakelib = []
161
- @app.instance_eval do
162
- handle_options
163
- options.silent = true
164
- options.load_system = true
165
- load_rakefile
166
- end
167
- assert_equal "test/data/sys", @app.system_dir
168
- assert_nil @app.rakefile
169
- end
170
- end
171
-
172
- def test_load_from_system_rakefile_on_unix
173
- flexmock(@app, :windows? => false,
174
- :win32_system_dir => nil,
175
- :load => nil)
176
- flexmock(File).should_receive(:expand_path).with("~").and_return("/HOME")
177
- flexmock(File).should_receive(:expand_path).and_return { |fn| fn }
178
-
179
- in_environment('RAKE_SYSTEM' => nil) do
180
- @app.options.rakelib = []
181
- @app.instance_eval do
182
- handle_options
183
- options.silent = true
184
- options.load_system = true
185
- load_rakefile
186
- end
187
- assert_equal "/HOME/.rake", @app.system_dir
188
- end
189
- end
190
-
191
- def test_windows
192
- assert ! (@app.windows? && @app.unix?)
193
- end
194
-
195
- def test_load_from_system_rakefile_on_windows
196
- flexmock(Rake::Win32, :windows? => true)
197
- flexmock(@app, :standard_system_dir => "XX")
198
- flexmock(@app).should_receive(:directory?).with("/AD/Rake").and_return(true)
199
- flexmock(@app).should_receive(:load).and_return(nil)
200
- in_environment('RAKE_SYSTEM' => nil, 'APPDATA' => '/AD') do
201
- @app.options.rakelib = []
202
- @app.instance_eval do
203
- handle_options
204
- options.silent = true
205
- options.load_system = true
206
- load_rakefile
207
- end
208
- assert_equal "/AD/Rake", @app.system_dir
209
- end
210
- end
211
-
212
- def test_loading_imports
213
- mock = flexmock("loader")
214
- mock.should_receive(:load).with("x.dummy").once
215
- @app.instance_eval do
216
- add_loader("dummy", mock)
217
- add_import("x.dummy")
218
- load_imports
219
- end
220
- end
221
-
222
- def test_building_imported_files_on_demand
223
- mock = flexmock("loader")
224
- mock.should_receive(:load).with("x.dummy").once
225
- mock.should_receive(:make_dummy).with_no_args.once
226
- @app.instance_eval do
227
- intern(Rake::Task, "x.dummy").enhance do mock.make_dummy end
228
- add_loader("dummy", mock)
229
- add_import("x.dummy")
230
- load_imports
231
- end
232
- end
233
-
234
- def test_good_run
235
- ran = false
236
- ARGV.clear
237
- ARGV << '--rakelib=""'
238
- @app.options.silent = true
239
- @app.instance_eval do
240
- intern(Rake::Task, "default").enhance { ran = true }
241
- end
242
- in_environment("PWD" => "test/data/default") do
243
- @app.run
244
- end
245
- assert ran
246
- end
247
-
248
- def test_display_task_run
249
- ran = false
250
- ARGV.clear
251
- ARGV << '-f' << '-s' << '--tasks' << '--rakelib=""'
252
- @app.last_description = "COMMENT"
253
- @app.define_task(Rake::Task, "default")
254
- out = capture_stdout { @app.run }
255
- assert @app.options.show_tasks
256
- assert ! ran
257
- assert_match(/rake default/, out)
258
- assert_match(/# COMMENT/, out)
259
- end
260
-
261
- def test_display_prereqs
262
- ran = false
263
- ARGV.clear
264
- ARGV << '-f' << '-s' << '--prereqs' << '--rakelib=""'
265
- @app.last_description = "COMMENT"
266
- t = @app.define_task(Rake::Task, "default")
267
- t.enhance([:a, :b])
268
- @app.define_task(Rake::Task, "a")
269
- @app.define_task(Rake::Task, "b")
270
- out = capture_stdout { @app.run }
271
- assert @app.options.show_prereqs
272
- assert ! ran
273
- assert_match(/rake a$/, out)
274
- assert_match(/rake b$/, out)
275
- assert_match(/rake default\n( *(a|b)\n){2}/m, out)
276
- end
277
-
278
- def test_bad_run
279
- @app.intern(Rake::Task, "default").enhance { fail }
280
- ARGV.clear
281
- ARGV << '-f' << '-s' << '--rakelib=""'
282
- assert_raise(SystemExit) {
283
- err = capture_stderr { @app.run }
284
- assert_match(/see full trace/, err)
285
- }
286
- ensure
287
- ARGV.clear
288
- end
289
-
290
- def test_bad_run_with_trace
291
- @app.intern(Rake::Task, "default").enhance { fail }
292
- ARGV.clear
293
- ARGV << '-f' << '-s' << '-t'
294
- assert_raise(SystemExit) {
295
- err = capture_stderr { capture_stdout { @app.run } }
296
- assert_no_match(/see full trace/, err)
297
- }
298
- ensure
299
- ARGV.clear
300
- end
301
-
302
- def test_run_with_bad_options
303
- @app.intern(Rake::Task, "default").enhance { fail }
304
- ARGV.clear
305
- ARGV << '-f' << '-s' << '--xyzzy'
306
- assert_raise(SystemExit) {
307
- err = capture_stderr { capture_stdout { @app.run } }
308
- }
309
- ensure
310
- ARGV.clear
311
- end
312
- end
313
-
314
-
315
- ######################################################################
316
- class TestApplicationOptions < Test::Unit::TestCase
317
- include CaptureStdout
318
-
319
- def setup
320
- clear_argv
321
- RakeFileUtils.verbose_flag = false
322
- RakeFileUtils.nowrite_flag = false
323
- TESTING_REQUIRE.clear
324
- end
325
-
326
- def teardown
327
- clear_argv
328
- RakeFileUtils.verbose_flag = false
329
- RakeFileUtils.nowrite_flag = false
330
- end
331
-
332
- def clear_argv
333
- while ! ARGV.empty?
334
- ARGV.pop
335
- end
336
- end
337
-
338
- def test_default_options
339
- opts = command_line
340
- assert_nil opts.classic_namespace
341
- assert_nil opts.dryrun
342
- assert_nil opts.full_description
343
- assert_nil opts.ignore_system
344
- assert_nil opts.load_system
345
- assert_nil opts.nosearch
346
- assert_equal ['rakelib'], opts.rakelib
347
- assert_nil opts.show_prereqs
348
- assert_nil opts.show_task_pattern
349
- assert_nil opts.show_tasks
350
- assert_nil opts.silent
351
- assert_nil opts.trace
352
- assert_equal ['rakelib'], opts.rakelib
353
- assert ! RakeFileUtils.verbose_flag
354
- assert ! RakeFileUtils.nowrite_flag
355
- end
356
-
357
- def test_dry_run
358
- flags('--dry-run', '-n') do |opts|
359
- assert opts.dryrun
360
- assert opts.trace
361
- assert RakeFileUtils.verbose_flag
362
- assert RakeFileUtils.nowrite_flag
363
- end
364
- end
365
-
366
- def test_describe
367
- flags('--describe') do |opts|
368
- assert opts.full_description
369
- assert opts.show_tasks
370
- assert_equal(//.to_s, opts.show_task_pattern.to_s)
371
- end
372
- end
373
-
374
- def test_describe_with_pattern
375
- flags('--describe=X') do |opts|
376
- assert opts.full_description
377
- assert opts.show_tasks
378
- assert_equal(/X/.to_s, opts.show_task_pattern.to_s)
379
- end
380
- end
381
-
382
- def test_execute
383
- $xyzzy = 0
384
- flags('--execute=$xyzzy=1', '-e $xyzzy=1') do |opts|
385
- assert_equal 1, $xyzzy
386
- assert_equal :exit, @exit
387
- $xyzzy = 0
388
- end
389
- end
390
-
391
- def test_execute_and_continue
392
- $xyzzy = 0
393
- flags('--execute-continue=$xyzzy=1', '-E $xyzzy=1') do |opts|
394
- assert_equal 1, $xyzzy
395
- assert_not_equal :exit, @exit
396
- $xyzzy = 0
397
- end
398
- end
399
-
400
- def test_execute_and_print
401
- $xyzzy = 0
402
- flags('--execute-print=$xyzzy="pugh"', '-p $xyzzy="pugh"') do |opts|
403
- assert_equal 'pugh', $xyzzy
404
- assert_equal :exit, @exit
405
- assert_match(/^pugh$/, @out)
406
- $xyzzy = 0
407
- end
408
- end
409
-
410
- def test_help
411
- flags('--help', '-H', '-h') do |opts|
412
- assert_match(/\Arake/, @out)
413
- assert_match(/\boptions\b/, @out)
414
- assert_match(/\btargets\b/, @out)
415
- assert_equal :exit, @exit
416
- assert_equal :exit, @exit
417
- end
418
- end
419
-
420
- def test_libdir
421
- flags(['--libdir', 'xx'], ['-I', 'xx'], ['-Ixx']) do |opts|
422
- $:.include?('xx')
423
- end
424
- ensure
425
- $:.delete('xx')
426
- end
427
-
428
- def test_rakefile
429
- flags(['--rakefile', 'RF'], ['--rakefile=RF'], ['-f', 'RF'], ['-fRF']) do |opts|
430
- assert_equal ['RF'], @app.instance_eval { @rakefiles }
431
- end
432
- end
433
-
434
- def test_rakelib
435
- flags(['--rakelibdir', 'A:B:C'], ['--rakelibdir=A:B:C'], ['-R', 'A:B:C'], ['-RA:B:C']) do |opts|
436
- assert_equal ['A', 'B', 'C'], opts.rakelib
437
- end
438
- end
439
-
440
- def test_require
441
- flags(['--require', 'test/reqfile'], '-rtest/reqfile2', '-rtest/reqfile3') do |opts|
442
- end
443
- assert TESTING_REQUIRE.include?(1)
444
- assert TESTING_REQUIRE.include?(2)
445
- assert TESTING_REQUIRE.include?(3)
446
- assert_equal 3, TESTING_REQUIRE.size
447
- end
448
-
449
- def test_missing_require
450
- ex = assert_raises(LoadError) do
451
- flags(['--require', 'test/missing']) do |opts|
452
- end
453
- end
454
- assert_match(/no such file/, ex.message)
455
- assert_match(/test\/missing/, ex.message)
456
- end
457
-
458
- def test_prereqs
459
- flags('--prereqs', '-P') do |opts|
460
- assert opts.show_prereqs
461
- end
462
- end
463
-
464
- def test_quiet
465
- flags('--quiet', '-q') do |opts|
466
- assert ! RakeFileUtils.verbose_flag
467
- assert ! opts.silent
468
- end
469
- end
470
-
471
- def test_no_search
472
- flags('--nosearch', '--no-search', '-N') do |opts|
473
- assert opts.nosearch
474
- end
475
- end
476
-
477
- def test_silent
478
- flags('--silent', '-s') do |opts|
479
- assert ! RakeFileUtils.verbose_flag
480
- assert opts.silent
481
- end
482
- end
483
-
484
- def test_system
485
- flags('--system', '-g') do |opts|
486
- assert opts.load_system
487
- end
488
- end
489
-
490
- def test_no_system
491
- flags('--no-system', '-G') do |opts|
492
- assert opts.ignore_system
493
- end
494
- end
495
-
496
- def test_trace
497
- flags('--trace', '-t') do |opts|
498
- assert opts.trace
499
- assert RakeFileUtils.verbose_flag
500
- assert ! RakeFileUtils.nowrite_flag
501
- end
502
- end
503
-
504
- def test_trace_rules
505
- flags('--rules') do |opts|
506
- assert opts.trace_rules
507
- end
508
- end
509
-
510
- def test_tasks
511
- flags('--tasks', '-T') do |opts|
512
- assert opts.show_tasks
513
- assert_equal(//.to_s, opts.show_task_pattern.to_s)
514
- end
515
- flags(['--tasks', 'xyz'], ['-Txyz']) do |opts|
516
- assert opts.show_tasks
517
- assert_equal(/xyz/, opts.show_task_pattern)
518
- end
519
- end
520
-
521
- def test_verbose
522
- flags('--verbose', '-V') do |opts|
523
- assert RakeFileUtils.verbose_flag
524
- assert ! opts.silent
525
- end
526
- end
527
-
528
- def test_version
529
- flags('--version', '-V') do |opts|
530
- assert_match(/\bversion\b/, @out)
531
- assert_match(/\b#{RAKEVERSION}\b/, @out)
532
- assert_equal :exit, @exit
533
- end
534
- end
535
-
536
- def test_classic_namespace
537
- flags(['--classic-namespace'], ['-C', '-T', '-P', '-n', '-s', '-t']) do |opts|
538
- assert opts.classic_namespace
539
- assert_equal opts.show_tasks, $show_tasks
540
- assert_equal opts.show_prereqs, $show_prereqs
541
- assert_equal opts.trace, $trace
542
- assert_equal opts.dryrun, $dryrun
543
- assert_equal opts.silent, $silent
544
- end
545
- end
546
-
547
- def test_bad_option
548
- capture_stderr do
549
- ex = assert_raise(OptionParser::InvalidOption) do
550
- flags('--bad-option')
551
- end
552
- if ex.message =~ /^While/ # Ruby 1.9 error message
553
- assert_match(/while parsing/i, ex.message)
554
- else # Ruby 1.8 error message
555
- assert_match(/(invalid|unrecognized) option/i, ex.message)
556
- assert_match(/--bad-option/, ex.message)
557
- end
558
- end
559
- end
560
-
561
- def test_task_collection
562
- command_line("a", "b")
563
- assert_equal ["a", "b"], @tasks.sort
564
- end
565
-
566
- def test_default_task_collection
567
- command_line()
568
- assert_equal ["default"], @tasks
569
- end
570
-
571
- def test_environment_definition
572
- ENV.delete('TESTKEY')
573
- command_line("a", "TESTKEY=12")
574
- assert_equal ["a"], @tasks.sort
575
- assert '12', ENV['TESTKEY']
576
- end
577
-
578
- private
579
-
580
- def flags(*sets)
581
- sets.each do |set|
582
- ARGV.clear
583
- @out = capture_stdout {
584
- @exit = catch(:system_exit) { opts = command_line(*set) }
585
- }
586
- yield(@app.options) if block_given?
587
- end
588
- end
589
-
590
- def command_line(*options)
591
- options.each do |opt| ARGV << opt end
592
- @app = Rake::Application.new
593
- def @app.exit(*args)
594
- throw :system_exit, :exit
595
- end
596
- @app.instance_eval do
597
- collect_tasks handle_options
598
- end
599
- @tasks = @app.top_level_tasks
600
- @app.options
601
- end
602
- end
603
-
604
- class TestTaskArgumentParsing < Test::Unit::TestCase
605
- def setup
606
- @app = Rake::Application.new
607
- end
608
-
609
- def test_name_only
610
- name, args = @app.parse_task_string("name")
611
- assert_equal "name", name
612
- assert_equal [], args
613
- end
614
-
615
- def test_empty_args
616
- name, args = @app.parse_task_string("name[]")
617
- assert_equal "name", name
618
- assert_equal [], args
619
- end
620
-
621
- def test_one_argument
622
- name, args = @app.parse_task_string("name[one]")
623
- assert_equal "name", name
624
- assert_equal ["one"], args
625
- end
626
-
627
- def test_two_arguments
628
- name, args = @app.parse_task_string("name[one,two]")
629
- assert_equal "name", name
630
- assert_equal ["one", "two"], args
631
- end
632
-
633
- def test_can_handle_spaces_between_args
634
- name, args = @app.parse_task_string("name[one, two,\tthree , \tfour]")
635
- assert_equal "name", name
636
- assert_equal ["one", "two", "three", "four"], args
637
- end
638
-
639
- def test_keeps_embedded_spaces
640
- name, args = @app.parse_task_string("name[a one ana, two]")
641
- assert_equal "name", name
642
- assert_equal ["a one ana", "two"], args
643
- end
644
-
645
- end
646
-
647
- class TestTaskArgumentParsing < Test::Unit::TestCase
648
- include InEnvironment
649
-
650
- def test_terminal_width_using_env
651
- app = Rake::Application.new
652
- in_environment('RAKE_COLUMNS' => '1234') do
653
- assert_equal 1234, app.terminal_width
654
- end
655
- end
656
-
657
- def test_terminal_width_using_stty
658
- app = Rake::Application.new
659
- flexmock(app,
660
- :unix? => true,
661
- :dynamic_width_stty => 1235,
662
- :dynamic_width_tput => 0)
663
- in_environment('RAKE_COLUMNS' => nil) do
664
- assert_equal 1235, app.terminal_width
665
- end
666
- end
667
-
668
- def test_terminal_width_using_tput
669
- app = Rake::Application.new
670
- flexmock(app,
671
- :unix? => true,
672
- :dynamic_width_stty => 0,
673
- :dynamic_width_tput => 1236)
674
- in_environment('RAKE_COLUMNS' => nil) do
675
- assert_equal 1236, app.terminal_width
676
- end
677
- end
678
-
679
- def test_terminal_width_using_hardcoded_80
680
- app = Rake::Application.new
681
- flexmock(app, :unix? => false)
682
- in_environment('RAKE_COLUMNS' => nil) do
683
- assert_equal 80, app.terminal_width
684
- end
685
- end
686
-
687
- def test_terminal_width_with_failure
688
- app = Rake::Application.new
689
- flexmock(app).should_receive(:unix?).and_throw(RuntimeError)
690
- in_environment('RAKE_COLUMNS' => nil) do
691
- assert_equal 80, app.terminal_width
692
- end
693
- end
694
- end