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,89 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require 'rake'
5
-
6
- ######################################################################
7
- class TestTaskArguments < Test::Unit::TestCase
8
- def teardown
9
- ENV.delete('rev')
10
- ENV.delete('VER')
11
- end
12
-
13
- def test_empty_arg_list_is_empty
14
- ta = Rake::TaskArguments.new([], [])
15
- assert_equal({}, ta.to_hash)
16
- end
17
-
18
- def test_multiple_values_in_args
19
- ta = Rake::TaskArguments.new([:a, :b, :c], [:one, :two, :three])
20
- assert_equal({:a => :one, :b => :two, :c => :three}, ta.to_hash)
21
- end
22
-
23
- def test_to_s
24
- ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2, 3])
25
- assert_equal ta.to_hash.inspect, ta.to_s
26
- assert_equal ta.to_hash.inspect, ta.inspect
27
- end
28
-
29
- def test_enumerable_behavior
30
- ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2 ,3])
31
- assert_equal [10, 20, 30], ta.collect { |k,v| v * 10 }.sort
32
- end
33
-
34
- def test_named_args
35
- ta = Rake::TaskArguments.new(["aa", "bb"], [1, 2])
36
- assert_equal 1, ta.aa
37
- assert_equal 1, ta[:aa]
38
- assert_equal 1, ta["aa"]
39
- assert_equal 2, ta.bb
40
- assert_nil ta.cc
41
- end
42
-
43
- def test_args_knows_its_names
44
- ta = Rake::TaskArguments.new(["aa", "bb"], [1, 2])
45
- assert_equal ["aa", "bb"], ta.names
46
- end
47
-
48
- def test_extra_names_are_nil
49
- ta = Rake::TaskArguments.new(["aa", "bb", "cc"], [1, 2])
50
- assert_nil ta.cc
51
- end
52
-
53
- def test_args_can_reference_env_values
54
- ta = Rake::TaskArguments.new(["aa"], [1])
55
- ENV['rev'] = "1.2"
56
- ENV['VER'] = "2.3"
57
- assert_equal "1.2", ta.rev
58
- assert_equal "2.3", ta.ver
59
- end
60
-
61
- def test_creating_new_argument_scopes
62
- parent = Rake::TaskArguments.new(['p'], [1])
63
- child = parent.new_scope(['c', 'p'])
64
- assert_equal({:p=>1}, child.to_hash)
65
- assert_equal 1, child.p
66
- assert_equal 1, child["p"]
67
- assert_equal 1, child[:p]
68
- assert_nil child.c
69
- end
70
-
71
- def test_child_hides_parent_arg_names
72
- parent = Rake::TaskArguments.new(['aa'], [1])
73
- child = Rake::TaskArguments.new(['aa'], [2], parent)
74
- assert_equal 2, child.aa
75
- end
76
-
77
- def test_default_arguments_values_can_be_merged
78
- ta = Rake::TaskArguments.new(["aa", "bb"], [nil, "original_val"])
79
- ta.with_defaults({ :aa => 'default_val' })
80
- assert_equal 'default_val', ta[:aa]
81
- assert_equal 'original_val', ta[:bb]
82
- end
83
-
84
- def test_default_arguements_that_dont_match_names_are_ignored
85
- ta = Rake::TaskArguments.new(["aa", "bb"], [nil, "original_val"])
86
- ta.with_defaults({ "cc" => "default_val" })
87
- assert_nil ta[:cc]
88
- end
89
- end
@@ -1,170 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require 'rake'
5
-
6
- class TaskManager
7
- include Rake::TaskManager
8
- end
9
-
10
- class TestTaskManager < Test::Unit::TestCase
11
- def setup
12
- @tm = TaskManager.new
13
- end
14
-
15
- def test_create_task_manager
16
- assert_not_nil @tm
17
- assert_equal [], @tm.tasks
18
- end
19
-
20
- def test_define_task
21
- t = @tm.define_task(Rake::Task, :t)
22
- assert_equal "t", t.name
23
- assert_equal @tm, t.application
24
- end
25
-
26
- def test_name_lookup
27
- t = @tm.define_task(Rake::Task, :t)
28
- assert_equal t, @tm[:t]
29
- end
30
-
31
- def test_namespace_task_create
32
- @tm.in_namespace("x") do
33
- t = @tm.define_task(Rake::Task, :t)
34
- assert_equal "x:t", t.name
35
- end
36
- assert_equal ["x:t"], @tm.tasks.collect { |t| t.name }
37
- end
38
-
39
- def test_anonymous_namespace
40
- anon_ns = @tm.in_namespace(nil) do
41
- t = @tm.define_task(Rake::Task, :t)
42
- assert_equal "_anon_1:t", t.name
43
- end
44
- task = anon_ns[:t]
45
- assert_equal "_anon_1:t", task.name
46
- end
47
-
48
- def test_create_filetask_in_namespace
49
- @tm.in_namespace("x") do
50
- t = @tm.define_task(Rake::FileTask, "fn")
51
- assert_equal "fn", t.name
52
- end
53
- assert_equal ["fn"], @tm.tasks.collect { |t| t.name }
54
- end
55
-
56
- def test_namespace_yields_same_namespace_as_returned
57
- yielded_namespace = nil
58
- returned_namespace = @tm.in_namespace("x") do |ns|
59
- yielded_namespace = ns
60
- end
61
- assert_equal returned_namespace, yielded_namespace
62
- end
63
-
64
- def test_name_lookup_with_implicit_file_tasks
65
- t = @tm["README"]
66
- assert_equal "README", t.name
67
- assert Rake::FileTask === t
68
- end
69
-
70
- def test_name_lookup_with_nonexistent_task
71
- assert_raise(RuntimeError) {
72
- t = @tm["DOES NOT EXIST"]
73
- }
74
- end
75
-
76
- def test_name_lookup_in_multiple_scopes
77
- aa = nil
78
- bb = nil
79
- xx = @tm.define_task(Rake::Task, :xx)
80
- top_z = @tm.define_task(Rake::Task, :z)
81
- @tm.in_namespace("a") do
82
- aa = @tm.define_task(Rake::Task, :aa)
83
- mid_z = @tm.define_task(Rake::Task, :z)
84
- @tm.in_namespace("b") do
85
- bb = @tm.define_task(Rake::Task, :bb)
86
- bot_z = @tm.define_task(Rake::Task, :z)
87
-
88
- assert_equal ["a", "b"], @tm.current_scope
89
-
90
- assert_equal bb, @tm["a:b:bb"]
91
- assert_equal aa, @tm["a:aa"]
92
- assert_equal xx, @tm["xx"]
93
- assert_equal bot_z, @tm["z"]
94
- assert_equal mid_z, @tm["^z"]
95
- assert_equal top_z, @tm["^^z"]
96
- assert_equal top_z, @tm["rake:z"]
97
- end
98
-
99
- assert_equal ["a"], @tm.current_scope
100
-
101
- assert_equal bb, @tm["a:b:bb"]
102
- assert_equal aa, @tm["a:aa"]
103
- assert_equal xx, @tm["xx"]
104
- assert_equal bb, @tm["b:bb"]
105
- assert_equal aa, @tm["aa"]
106
- assert_equal mid_z, @tm["z"]
107
- assert_equal top_z, @tm["^z"]
108
- assert_equal top_z, @tm["rake:z"]
109
- end
110
-
111
- assert_equal [], @tm.current_scope
112
-
113
- assert_equal [], xx.scope
114
- assert_equal ['a'], aa.scope
115
- assert_equal ['a', 'b'], bb.scope
116
- end
117
-
118
- def test_lookup_with_explicit_scopes
119
- t1, t2, t3, s = (0...4).collect { nil }
120
- t1 = @tm.define_task(Rake::Task, :t)
121
- @tm.in_namespace("a") do
122
- t2 = @tm.define_task(Rake::Task, :t)
123
- s = @tm.define_task(Rake::Task, :s)
124
- @tm.in_namespace("b") do
125
- t3 = @tm.define_task(Rake::Task, :t)
126
- end
127
- end
128
- assert_equal t1, @tm[:t, []]
129
- assert_equal t2, @tm[:t, ["a"]]
130
- assert_equal t3, @tm[:t, ["a", "b"]]
131
- assert_equal s, @tm[:s, ["a", "b"]]
132
- assert_equal s, @tm[:s, ["a"]]
133
- end
134
-
135
- def test_correctly_scoped_prerequisites_are_invoked
136
- values = []
137
- @tm = Rake::Application.new
138
- @tm.define_task(Rake::Task, :z) do values << "top z" end
139
- @tm.in_namespace("a") do
140
- @tm.define_task(Rake::Task, :z) do values << "next z" end
141
- @tm.define_task(Rake::Task, :x => :z)
142
- end
143
-
144
- @tm["a:x"].invoke
145
- assert_equal ["next z"], values
146
- end
147
-
148
- end
149
-
150
- class TestTaskManagerArgumentResolution < Test::Unit::TestCase
151
- def test_good_arg_patterns
152
- assert_equal [:t, [], []], task(:t)
153
- assert_equal [:t, [], [:x]], task(:t => :x)
154
- assert_equal [:t, [], [:x, :y]], task(:t => [:x, :y])
155
-
156
- assert_equal [:t, [:a, :b], []], task(:t, :a, :b)
157
- assert_equal [:t, [], [:x]], task(:t, :needs => :x)
158
- assert_equal [:t, [:a, :b], [:x]], task(:t, :a, :b, :needs => :x)
159
- assert_equal [:t, [:a, :b], [:x, :y]], task(:t, :a, :b, :needs => [:x, :y])
160
-
161
- assert_equal [:t, [:a, :b], []], task(:t, [:a, :b])
162
- assert_equal [:t, [:a, :b], [:x]], task(:t, [:a, :b] => :x)
163
- assert_equal [:t, [:a, :b], [:x, :y]], task(:t, [:a, :b] => [:x, :y])
164
- end
165
-
166
- def task(*args)
167
- tm = TaskManager.new
168
- tm.resolve_args(args)
169
- end
170
- end
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require 'rake/tasklib'
5
-
6
-
7
- class TestTaskLib < Test::Unit::TestCase
8
- def test_paste
9
- tl = Rake::TaskLib.new
10
- assert_equal :ab, tl.paste(:a, :b)
11
- end
12
- end
@@ -1,371 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require 'fileutils'
5
- require 'rake'
6
- require 'test/filecreation'
7
- require 'test/capture_stdout'
8
-
9
- ######################################################################
10
- class TestTask < Test::Unit::TestCase
11
- include CaptureStdout
12
- include Rake
13
-
14
- def setup
15
- Task.clear
16
- end
17
-
18
- def test_create
19
- arg = nil
20
- t = task(:name) { |task| arg = task; 1234 }
21
- assert_equal "name", t.name
22
- assert_equal [], t.prerequisites
23
- assert t.needed?
24
- t.execute(0)
25
- assert_equal t, arg
26
- assert_nil t.source
27
- assert_equal [], t.sources
28
- end
29
-
30
- def test_inspect
31
- t = task(:foo, :needs => [:bar, :baz])
32
- assert_equal "<Rake::Task foo => [bar, baz]>", t.inspect
33
- end
34
-
35
- def test_invoke
36
- runlist = []
37
- t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
38
- t2 = task(:t2) { |t| runlist << t.name }
39
- t3 = task(:t3) { |t| runlist << t.name }
40
- assert_equal ["t2", "t3"], t1.prerequisites
41
- t1.invoke
42
- assert_equal ["t2", "t3", "t1"], runlist
43
- end
44
-
45
- def test_invoke_with_circular_dependencies
46
- runlist = []
47
- t1 = task(:t1 => [:t2]) { |t| runlist << t.name; 3321 }
48
- t2 = task(:t2 => [:t1]) { |t| runlist << t.name }
49
- assert_equal ["t2"], t1.prerequisites
50
- assert_equal ["t1"], t2.prerequisites
51
- ex = assert_raise RuntimeError do
52
- t1.invoke
53
- end
54
- assert_match(/circular dependency/i, ex.message)
55
- assert_match(/t1 => t2 => t1/, ex.message)
56
- end
57
-
58
- def test_dry_run_prevents_actions
59
- Rake.application.options.dryrun = true
60
- runlist = []
61
- t1 = task(:t1) { |t| runlist << t.name; 3321 }
62
- out = capture_stdout { t1.invoke }
63
- assert_match(/execute .*t1/i, out)
64
- assert_match(/dry run/i, out)
65
- assert_no_match(/invoke/i, out)
66
- assert_equal [], runlist
67
- ensure
68
- Rake.application.options.dryrun = false
69
- end
70
-
71
- def test_tasks_can_be_traced
72
- Rake.application.options.trace = true
73
- t1 = task(:t1)
74
- out = capture_stdout {
75
- t1.invoke
76
- }
77
- assert_match(/invoke t1/i, out)
78
- assert_match(/execute t1/i, out)
79
- ensure
80
- Rake.application.options.trace = false
81
- end
82
-
83
- def test_no_double_invoke
84
- runlist = []
85
- t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
86
- t2 = task(:t2 => [:t3]) { |t| runlist << t.name }
87
- t3 = task(:t3) { |t| runlist << t.name }
88
- t1.invoke
89
- assert_equal ["t3", "t2", "t1"], runlist
90
- end
91
-
92
- def test_can_double_invoke_with_reenable
93
- runlist = []
94
- t1 = task(:t1) { |t| runlist << t.name }
95
- t1.invoke
96
- t1.reenable
97
- t1.invoke
98
- assert_equal ["t1", "t1"], runlist
99
- end
100
-
101
- def test_clear
102
- t = task("t" => "a") { }
103
- t.clear
104
- assert t.prerequisites.empty?, "prerequisites should be empty"
105
- assert t.actions.empty?, "actions should be empty"
106
- end
107
-
108
- def test_clear_prerequisites
109
- t = task("t" => ["a", "b"])
110
- assert_equal ['a', 'b'], t.prerequisites
111
- t.clear_prerequisites
112
- assert_equal [], t.prerequisites
113
- end
114
-
115
- def test_clear_actions
116
- t = task("t") { }
117
- t.clear_actions
118
- assert t.actions.empty?, "actions should be empty"
119
- end
120
-
121
- def test_find
122
- task :tfind
123
- assert_equal "tfind", Task[:tfind].name
124
- ex = assert_raises(RuntimeError) { Task[:leaves] }
125
- assert_equal "Don't know how to build task 'leaves'", ex.message
126
- end
127
-
128
- def test_defined
129
- assert ! Task.task_defined?(:a)
130
- task :a
131
- assert Task.task_defined?(:a)
132
- end
133
-
134
- def test_multi_invocations
135
- runs = []
136
- p = proc do |t| runs << t.name end
137
- task({:t1=>[:t2,:t3]}, &p)
138
- task({:t2=>[:t3]}, &p)
139
- task(:t3, &p)
140
- Task[:t1].invoke
141
- assert_equal ["t1", "t2", "t3"], runs.sort
142
- end
143
-
144
- def test_task_list
145
- task :t2
146
- task :t1 => [:t2]
147
- assert_equal ["t1", "t2"], Task.tasks.collect {|t| t.name}
148
- end
149
-
150
- def test_task_gives_name_on_to_s
151
- task :abc
152
- assert_equal "abc", Task[:abc].to_s
153
- end
154
-
155
- def test_symbols_can_be_prerequisites
156
- task :a => :b
157
- assert_equal ["b"], Task[:a].prerequisites
158
- end
159
-
160
- def test_strings_can_be_prerequisites
161
- task :a => "b"
162
- assert_equal ["b"], Task[:a].prerequisites
163
- end
164
-
165
- def test_arrays_can_be_prerequisites
166
- task :a => ["b", "c"]
167
- assert_equal ["b", "c"], Task[:a].prerequisites
168
- end
169
-
170
- def test_filelists_can_be_prerequisites
171
- task :a => FileList.new.include("b", "c")
172
- assert_equal ["b", "c"], Task[:a].prerequisites
173
- end
174
-
175
- def test_investigation_output
176
- t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
177
- task(:t2)
178
- task(:t3)
179
- out = t1.investigation
180
- assert_match(/class:\s*Rake::Task/, out)
181
- assert_match(/needed:\s*true/, out)
182
- assert_match(/pre-requisites:\s*--t2/, out)
183
- end
184
-
185
-
186
- def test_extended_comments
187
- desc %{
188
- This is a comment.
189
-
190
- And this is the extended comment.
191
- name -- Name of task to execute.
192
- rev -- Software revision to use.
193
- }
194
- t = task(:t, :name, :rev)
195
- assert_equal "[name,rev]", t.arg_description
196
- assert_equal "This is a comment.", t.comment
197
- assert_match(/^\s*name -- Name/, t.full_comment)
198
- assert_match(/^\s*rev -- Software/, t.full_comment)
199
- assert_match(/\A\s*This is a comment\.$/, t.full_comment)
200
- end
201
-
202
- def test_multiple_comments
203
- desc "line one"
204
- t = task(:t)
205
- desc "line two"
206
- task(:t)
207
- assert_equal "line one / line two", t.comment
208
- end
209
-
210
- def test_settable_comments
211
- t = task(:t)
212
- t.comment = "HI"
213
- assert_equal "HI", t.comment
214
- end
215
- end
216
-
217
- ######################################################################
218
- class TestTaskWithArguments < Test::Unit::TestCase
219
- include CaptureStdout
220
- include Rake
221
-
222
- def setup
223
- Task.clear
224
- end
225
-
226
- def test_no_args_given
227
- t = task :t
228
- assert_equal [], t.arg_names
229
- end
230
-
231
- def test_args_given
232
- t = task :t, :a, :b
233
- assert_equal [:a, :b], t.arg_names
234
- end
235
-
236
- def test_name_and_needs
237
- t = task(:t => [:pre])
238
- assert_equal "t", t.name
239
- assert_equal [], t.arg_names
240
- assert_equal ["pre"], t.prerequisites
241
- end
242
-
243
- def test_name_and_explicit_needs
244
- t = task(:t, :needs => [:pre])
245
- assert_equal "t", t.name
246
- assert_equal [], t.arg_names
247
- assert_equal ["pre"], t.prerequisites
248
- end
249
-
250
- def test_name_args_and_explicit_needs
251
- t = task(:t, :x, :y, :needs => [:pre])
252
- assert_equal "t", t.name
253
- assert_equal [:x, :y], t.arg_names
254
- assert_equal ["pre"], t.prerequisites
255
- end
256
-
257
- def test_illegal_keys_in_task_name_hash
258
- assert_raise RuntimeError do
259
- t = task(:t, :x, :y => 1, :needs => [:pre])
260
- end
261
- end
262
-
263
- def test_arg_list_is_empty_if_no_args_given
264
- t = task(:t) { |tt, args| assert_equal({}, args.to_hash) }
265
- t.invoke(1, 2, 3)
266
- end
267
-
268
- def test_tasks_can_access_arguments_as_hash
269
- t = task :t, :a, :b, :c do |tt, args|
270
- assert_equal({:a => 1, :b => 2, :c => 3}, args.to_hash)
271
- assert_equal 1, args[:a]
272
- assert_equal 2, args[:b]
273
- assert_equal 3, args[:c]
274
- assert_equal 1, args.a
275
- assert_equal 2, args.b
276
- assert_equal 3, args.c
277
- end
278
- t.invoke(1, 2, 3)
279
- end
280
-
281
- def test_actions_of_various_arity_are_ok_with_args
282
- notes = []
283
- t = task(:t, :x) do
284
- notes << :a
285
- end
286
- t.enhance do | |
287
- notes << :b
288
- end
289
- t.enhance do |task|
290
- notes << :c
291
- assert_kind_of Task, task
292
- end
293
- t.enhance do |t2, args|
294
- notes << :d
295
- assert_equal t, t2
296
- assert_equal({:x => 1}, args.to_hash)
297
- end
298
- assert_nothing_raised do t.invoke(1) end
299
- assert_equal [:a, :b, :c, :d], notes
300
- end
301
-
302
- def test_arguments_are_passed_to_block
303
- t = task(:t, :a, :b) { |tt, args|
304
- assert_equal( { :a => 1, :b => 2 }, args.to_hash )
305
- }
306
- t.invoke(1, 2)
307
- end
308
-
309
- def test_extra_parameters_are_ignored
310
- t = task(:t, :a) { |tt, args|
311
- assert_equal 1, args.a
312
- assert_nil args.b
313
- }
314
- t.invoke(1, 2)
315
- end
316
-
317
- def test_arguments_are_passed_to_all_blocks
318
- counter = 0
319
- t = task :t, :a
320
- task :t do |tt, args|
321
- assert_equal 1, args.a
322
- counter += 1
323
- end
324
- task :t do |tt, args|
325
- assert_equal 1, args.a
326
- counter += 1
327
- end
328
- t.invoke(1)
329
- assert_equal 2, counter
330
- end
331
-
332
- def test_block_with_no_parameters_is_ok
333
- t = task(:t) { }
334
- t.invoke(1, 2)
335
- end
336
-
337
- def test_name_with_args
338
- desc "T"
339
- t = task(:tt, :a, :b)
340
- assert_equal "tt", t.name
341
- assert_equal "T", t.comment
342
- assert_equal "[a,b]", t.arg_description
343
- assert_equal "tt[a,b]", t.name_with_args
344
- assert_equal [:a, :b],t.arg_names
345
- end
346
-
347
- def test_named_args_are_passed_to_prereqs
348
- value = nil
349
- pre = task(:pre, :rev) { |t, args| value = args.rev }
350
- t = task(:t, :name, :rev, :needs => [:pre])
351
- t.invoke("bill", "1.2")
352
- assert_equal "1.2", value
353
- end
354
-
355
- def test_args_not_passed_if_no_prereq_names
356
- pre = task(:pre) { |t, args|
357
- assert_equal({}, args.to_hash)
358
- assert_equal "bill", args.name
359
- }
360
- t = task(:t, :name, :rev, :needs => [:pre])
361
- t.invoke("bill", "1.2")
362
- end
363
-
364
- def test_args_not_passed_if_no_arg_names
365
- pre = task(:pre, :rev) { |t, args|
366
- assert_equal({}, args.to_hash)
367
- }
368
- t = task(:t, :needs => [:pre])
369
- t.invoke("bill", "1.2")
370
- end
371
- end