drake 0.9.0.0.3.0 → 0.9.1.0.3.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.
Files changed (71) hide show
  1. data/CHANGES +9 -8
  2. data/CHANGES-drake +4 -0
  3. data/Rakefile +14 -49
  4. data/Rakefile-drake +2 -1
  5. data/bin/drake +4 -3
  6. data/doc/release_notes/rake-0.9.1.rdoc +52 -0
  7. data/lib/rake/dsl_definition.rb +19 -0
  8. data/lib/rake/version.rb +1 -1
  9. data/test/data/access/Rakefile +3 -1
  10. data/test/data/default/Rakefile +0 -2
  11. data/test/data/file_creation_task/Rakefile +0 -2
  12. data/test/data/multidesc/Rakefile +0 -2
  13. data/test/data/namespace/Rakefile +0 -2
  14. data/test/data/statusreturn/Rakefile +0 -2
  15. data/test/file_creation.rb +0 -2
  16. data/test/helper.rb +63 -0
  17. data/test/in_environment.rb +4 -1
  18. data/test/{parallel_setup.rb → setup_parallel.rb} +0 -0
  19. data/test/{serial_setup.rb → setup_serial.rb} +0 -0
  20. data/test/{lib/parallel_test.rb → test_parallel.rb} +3 -1
  21. data/test/{lib/rake_test.rb → test_rake.rb} +2 -5
  22. data/test/test_rake_application.rb +365 -0
  23. data/test/test_rake_application_options.rb +383 -0
  24. data/test/test_rake_clean.rb +14 -0
  25. data/test/{lib/definitions_test.rb → test_rake_definitions.rb} +5 -10
  26. data/test/test_rake_directory_task.rb +55 -0
  27. data/test/test_rake_dsl.rb +53 -0
  28. data/test/{lib/earlytime_test.rb → test_rake_early_time.rb} +2 -5
  29. data/test/{lib/extension_test.rb → test_rake_extension.rb} +2 -6
  30. data/test/{lib/file_creation_task_test.rb → test_rake_file_creation_task.rb} +7 -7
  31. data/test/{lib/filelist_test.rb → test_rake_file_list.rb} +18 -22
  32. data/test/test_rake_file_list_path_map.rb +8 -0
  33. data/test/{lib/file_task_test.rb → test_rake_file_task.rb} +22 -61
  34. data/test/{lib/fileutils_test.rb → test_rake_file_utils.rb} +11 -15
  35. data/test/{lib/ftp_test.rb → test_rake_ftp_file.rb} +5 -5
  36. data/test/{functional/session_based_tests.rb → test_rake_functional.rb} +35 -24
  37. data/test/test_rake_invocation_chain.rb +52 -0
  38. data/test/{lib/makefile_loader_test.rb → test_rake_makefile_loader.rb} +2 -5
  39. data/test/{lib/multitask_test.rb → test_rake_multi_task.rb} +5 -7
  40. data/test/{lib/namespace_test.rb → test_rake_name_space.rb} +4 -16
  41. data/test/{lib/package_task_test.rb → test_rake_package_task.rb} +2 -6
  42. data/test/{lib/pathmap_test.rb → test_rake_path_map.rb} +4 -58
  43. data/test/test_rake_path_map_explode.rb +31 -0
  44. data/test/test_rake_path_map_partial.rb +18 -0
  45. data/test/{lib/pseudo_status_test.rb → test_rake_pseudo_status.rb} +2 -8
  46. data/test/{lib/rdoc_task_test.rb → test_rake_rdoc_task.rb} +4 -7
  47. data/test/{lib/require_test.rb → test_rake_require.rb} +3 -9
  48. data/test/{lib/rules_test.rb → test_rake_rules.rb} +11 -13
  49. data/test/{lib/task_test.rb → test_rake_task.rb} +16 -183
  50. data/test/test_rake_task_argument_parsing.rb +126 -0
  51. data/test/{lib/task_arguments_test.rb → test_rake_task_arguments.rb} +2 -5
  52. data/test/{lib/tasklib_test.rb → test_rake_task_lib.rb} +2 -5
  53. data/test/{lib/task_manager_test.rb → test_rake_task_manager.rb} +7 -45
  54. data/test/test_rake_task_manager_argument_resolution.rb +36 -0
  55. data/test/test_rake_task_with_arguments.rb +162 -0
  56. data/test/{lib/test_task_test.rb → test_rake_test_task.rb} +52 -7
  57. data/test/{lib/top_level_functions_test.rb → test_rake_top_level_functions.rb} +8 -20
  58. data/test/{lib/win32_test.rb → test_rake_win32.rb} +5 -12
  59. data/test/{contrib/test_sys.rb → test_sys.rb} +2 -6
  60. metadata +62 -47
  61. data/lib/rake/dsl.rb +0 -2
  62. data/test/capture_stdout.rb +0 -26
  63. data/test/functional/functional_test.rb +0 -25
  64. data/test/lib/application_test.rb +0 -871
  65. data/test/lib/clean_test.rb +0 -15
  66. data/test/lib/dsl_test.rb +0 -52
  67. data/test/lib/invocation_chain_test.rb +0 -81
  68. data/test/lib/testtask_test.rb +0 -49
  69. data/test/rake_test_setup.rb +0 -41
  70. data/test/ruby_version_test.rb +0 -3
  71. data/test/test_helper.rb +0 -19
@@ -0,0 +1,126 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ class TestRakeTaskArgumentParsing < Rake::TestCase
4
+ def setup
5
+ super
6
+
7
+ @app = Rake::Application.new
8
+ @app.options.threads = Rake.application.options.threads
9
+ @app
10
+ end
11
+
12
+ def test_name_only
13
+ name, args = @app.parse_task_string("name")
14
+ assert_equal "name", name
15
+ assert_equal [], args
16
+ end
17
+
18
+ def test_empty_args
19
+ name, args = @app.parse_task_string("name[]")
20
+ assert_equal "name", name
21
+ assert_equal [], args
22
+ end
23
+
24
+ def test_one_argument
25
+ name, args = @app.parse_task_string("name[one]")
26
+ assert_equal "name", name
27
+ assert_equal ["one"], args
28
+ end
29
+
30
+ def test_two_arguments
31
+ name, args = @app.parse_task_string("name[one,two]")
32
+ assert_equal "name", name
33
+ assert_equal ["one", "two"], args
34
+ end
35
+
36
+ def test_can_handle_spaces_between_args
37
+ name, args = @app.parse_task_string("name[one, two,\tthree , \tfour]")
38
+ assert_equal "name", name
39
+ assert_equal ["one", "two", "three", "four"], args
40
+ end
41
+
42
+ def test_keeps_embedded_spaces
43
+ name, args = @app.parse_task_string("name[a one ana, two]")
44
+ assert_equal "name", name
45
+ assert_equal ["a one ana", "two"], args
46
+ end
47
+
48
+ def test_terminal_width_using_env
49
+ app = Rake::Application.new
50
+ app.options.threads = Rake.application.options.threads
51
+ in_environment('RAKE_COLUMNS' => '1234') do
52
+ assert_equal 1234, app.terminal_width
53
+ end
54
+ end
55
+
56
+ def test_terminal_width_using_stty
57
+ app = Rake::Application.new
58
+ app.options.threads = Rake.application.options.threads
59
+ flexmock(app,
60
+ :unix? => true,
61
+ :dynamic_width_stty => 1235,
62
+ :dynamic_width_tput => 0)
63
+ in_environment('RAKE_COLUMNS' => nil) do
64
+ assert_equal 1235, app.terminal_width
65
+ end
66
+ end
67
+
68
+ def test_terminal_width_using_tput
69
+ app = Rake::Application.new
70
+ app.options.threads = Rake.application.options.threads
71
+ flexmock(app,
72
+ :unix? => true,
73
+ :dynamic_width_stty => 0,
74
+ :dynamic_width_tput => 1236)
75
+ in_environment('RAKE_COLUMNS' => nil) do
76
+ assert_equal 1236, app.terminal_width
77
+ end
78
+ end
79
+
80
+ def test_terminal_width_using_hardcoded_80
81
+ app = Rake::Application.new
82
+ app.options.threads = Rake.application.options.threads
83
+ flexmock(app, :unix? => false)
84
+ in_environment('RAKE_COLUMNS' => nil) do
85
+ assert_equal 80, app.terminal_width
86
+ end
87
+ end
88
+
89
+ def test_terminal_width_with_failure
90
+ app = Rake::Application.new
91
+ app.options.threads = Rake.application.options.threads
92
+ flexmock(app).should_receive(:unix?).and_throw(RuntimeError)
93
+ in_environment('RAKE_COLUMNS' => nil) do
94
+ assert_equal 80, app.terminal_width
95
+ end
96
+ end
97
+
98
+ def test_no_rakeopt
99
+ in_environment do
100
+ ARGV << '--trace'
101
+ app = Rake::Application.new
102
+ app.options.threads = Rake.application.options.threads
103
+ app.init
104
+ assert !app.options.silent
105
+ end
106
+ end
107
+
108
+ def test_rakeopt_with_blank_options
109
+ in_environment("RAKEOPT" => "") do
110
+ ARGV << '--trace'
111
+ app = Rake::Application.new
112
+ app.options.threads = Rake.application.options.threads
113
+ app.init
114
+ assert !app.options.silent
115
+ end
116
+ end
117
+
118
+ def test_rakeopt_with_silent_options
119
+ in_environment("RAKEOPT" => "-s") do
120
+ app = Rake::Application.new
121
+ app.options.threads = Rake.application.options.threads
122
+ app.init
123
+ assert app.options.silent
124
+ end
125
+ end
126
+ end
@@ -1,10 +1,7 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require 'rake'
1
+ require File.expand_path('../helper', __FILE__)
5
2
 
6
3
  ######################################################################
7
- class TestTaskArguments < Test::Unit::TestCase
4
+ class TestRakeTaskArguments < Rake::TestCase
8
5
  def teardown
9
6
  ENV.delete('rev')
10
7
  ENV.delete('VER')
@@ -1,10 +1,7 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
1
+ require File.expand_path('../helper', __FILE__)
4
2
  require 'rake/tasklib'
5
3
 
6
-
7
- class TestTaskLib < Test::Unit::TestCase
4
+ class TestRakeTaskLib < Rake::TestCase
8
5
  def test_paste
9
6
  tl = Rake::TaskLib.new
10
7
  assert_equal :ab, tl.paste(:a, :b)
@@ -1,22 +1,15 @@
1
- #!/usr/bin/env ruby
1
+ require File.expand_path('../helper', __FILE__)
2
2
 
3
- require 'test/unit'
4
- require 'rake'
5
- require 'test/rake_test_setup'
6
-
7
- class TaskManager
8
- include Rake::TaskManager
9
- end
10
-
11
- class TestTaskManager < Test::Unit::TestCase
12
- include TestMethods
3
+ class TestRakeTaskManager < Rake::TestCase
13
4
 
14
5
  def setup
15
- @tm = TaskManager.new
6
+ super
7
+
8
+ @tm = Rake::TestCase::TaskManager.new
16
9
  end
17
10
 
18
11
  def test_create_task_manager
19
- assert_not_nil @tm
12
+ refute_nil @tm
20
13
  assert_equal [], @tm.tasks
21
14
  end
22
15
 
@@ -71,7 +64,7 @@ class TestTaskManager < Test::Unit::TestCase
71
64
  end
72
65
 
73
66
  def test_name_lookup_with_nonexistent_task
74
- assert_exception(RuntimeError) {
67
+ assert_raises(RuntimeError) {
75
68
  @tm["DOES NOT EXIST"]
76
69
  }
77
70
  end
@@ -151,34 +144,3 @@ class TestTaskManager < Test::Unit::TestCase
151
144
 
152
145
  end
153
146
 
154
- class TestTaskManagerArgumentResolution < Test::Unit::TestCase
155
- def setup
156
- super
157
- Rake.application.options.ignore_deprecate = true
158
- end
159
-
160
- def teardown
161
- Rake.application.options.ignore_deprecate = false
162
- super
163
- end
164
-
165
- def test_good_arg_patterns
166
- assert_equal [:t, [], []], task(:t)
167
- assert_equal [:t, [], [:x]], task(:t => :x)
168
- assert_equal [:t, [], [:x, :y]], task(:t => [:x, :y])
169
-
170
- assert_equal [:t, [:a, :b], []], task(:t, :a, :b)
171
- assert_equal [:t, [], [:x]], task(:t, :needs => :x)
172
- assert_equal [:t, [:a, :b], [:x]], task(:t, :a, :b, :needs => :x)
173
- assert_equal [:t, [:a, :b], [:x, :y]], task(:t, :a, :b, :needs => [:x, :y])
174
-
175
- assert_equal [:t, [:a, :b], []], task(:t, [:a, :b])
176
- assert_equal [:t, [:a, :b], [:x]], task(:t, [:a, :b] => :x)
177
- assert_equal [:t, [:a, :b], [:x, :y]], task(:t, [:a, :b] => [:x, :y])
178
- end
179
-
180
- def task(*args)
181
- tm = TaskManager.new
182
- tm.resolve_args(args)
183
- end
184
- end
@@ -0,0 +1,36 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ class TestRakeTaskManagerArgumentResolution < Rake::TestCase
4
+
5
+ def setup
6
+ super
7
+
8
+ Rake.application.options.ignore_deprecate = true
9
+ end
10
+
11
+ def teardown
12
+ Rake.application.options.ignore_deprecate = false
13
+
14
+ super
15
+ end
16
+
17
+ def test_good_arg_patterns
18
+ assert_equal [:t, [], []], task(:t)
19
+ assert_equal [:t, [], [:x]], task(:t => :x)
20
+ assert_equal [:t, [], [:x, :y]], task(:t => [:x, :y])
21
+
22
+ assert_equal [:t, [:a, :b], []], task(:t, :a, :b)
23
+ assert_equal [:t, [], [:x]], task(:t, :needs => :x)
24
+ assert_equal [:t, [:a, :b], [:x]], task(:t, :a, :b, :needs => :x)
25
+ assert_equal [:t, [:a, :b], [:x, :y]], task(:t, :a, :b, :needs => [:x, :y])
26
+
27
+ assert_equal [:t, [:a, :b], []], task(:t, [:a, :b])
28
+ assert_equal [:t, [:a, :b], [:x]], task(:t, [:a, :b] => :x)
29
+ assert_equal [:t, [:a, :b], [:x, :y]], task(:t, [:a, :b] => [:x, :y])
30
+ end
31
+
32
+ def task(*args)
33
+ tm = Rake::TestCase::TaskManager.new
34
+ tm.resolve_args(args)
35
+ end
36
+ end
@@ -0,0 +1,162 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ class TestRakeTaskWithArguments < Rake::TestCase
4
+ include Rake
5
+
6
+ def setup
7
+ super
8
+
9
+ Task.clear
10
+ Rake::TaskManager.record_task_metadata = true
11
+ end
12
+
13
+ def teardown
14
+ Rake::TaskManager.record_task_metadata = false
15
+
16
+ super
17
+ end
18
+
19
+ def test_no_args_given
20
+ t = task :t
21
+ assert_equal [], t.arg_names
22
+ end
23
+
24
+ def test_args_given
25
+ t = task :t, :a, :b
26
+ assert_equal [:a, :b], t.arg_names
27
+ end
28
+
29
+ def test_name_and_needs
30
+ t = task(:t => [:pre])
31
+ assert_equal "t", t.name
32
+ assert_equal [], t.arg_names
33
+ assert_equal ["pre"], t.prerequisites
34
+ end
35
+
36
+ def test_name_args_and_explicit_needs
37
+ ignore_deprecations do
38
+ t = task(:t, :x, :y, :needs => [:pre])
39
+ assert_equal "t", t.name
40
+ assert_equal [:x, :y], t.arg_names
41
+ assert_equal ["pre"], t.prerequisites
42
+ end
43
+ end
44
+
45
+ def test_illegal_keys_in_task_name_hash
46
+ ignore_deprecations do
47
+ assert_raises RuntimeError do
48
+ t = task(:t, :x, :y => 1, :needs => [:pre])
49
+ end
50
+ end
51
+ end
52
+
53
+ def test_arg_list_is_empty_if_no_args_given
54
+ t = task(:t) { |tt, args| assert_equal({}, args.to_hash) }
55
+ t.invoke(1, 2, 3)
56
+ end
57
+
58
+ def test_tasks_can_access_arguments_as_hash
59
+ t = task :t, :a, :b, :c do |tt, args|
60
+ assert_equal({:a => 1, :b => 2, :c => 3}, args.to_hash)
61
+ assert_equal 1, args[:a]
62
+ assert_equal 2, args[:b]
63
+ assert_equal 3, args[:c]
64
+ assert_equal 1, args.a
65
+ assert_equal 2, args.b
66
+ assert_equal 3, args.c
67
+ end
68
+ t.invoke(1, 2, 3)
69
+ end
70
+
71
+ def test_actions_of_various_arity_are_ok_with_args
72
+ notes = ThreadSafeArray.new
73
+ t = task(:t, :x) do
74
+ notes << :a
75
+ end
76
+ t.enhance do | |
77
+ notes << :b
78
+ end
79
+ t.enhance do |task|
80
+ notes << :c
81
+ assert_kind_of Task, task
82
+ end
83
+ t.enhance do |t2, args|
84
+ notes << :d
85
+ assert_equal t, t2
86
+ assert_equal({:x => 1}, args.to_hash)
87
+ end
88
+ t.invoke(1)
89
+ assert_equal [:a, :b, :c, :d], notes
90
+ end
91
+
92
+ def test_arguments_are_passed_to_block
93
+ t = task(:t, :a, :b) { |tt, args|
94
+ assert_equal( { :a => 1, :b => 2 }, args.to_hash )
95
+ }
96
+ t.invoke(1, 2)
97
+ end
98
+
99
+ def test_extra_parameters_are_ignored
100
+ t = task(:t, :a) { |tt, args|
101
+ assert_equal 1, args.a
102
+ assert_nil args.b
103
+ }
104
+ t.invoke(1, 2)
105
+ end
106
+
107
+ def test_arguments_are_passed_to_all_blocks
108
+ counter = 0
109
+ t = task :t, :a
110
+ task :t do |tt, args|
111
+ assert_equal 1, args.a
112
+ counter += 1
113
+ end
114
+ task :t do |tt, args|
115
+ assert_equal 1, args.a
116
+ counter += 1
117
+ end
118
+ t.invoke(1)
119
+ assert_equal 2, counter
120
+ end
121
+
122
+ def test_block_with_no_parameters_is_ok
123
+ t = task(:t) { }
124
+ t.invoke(1, 2)
125
+ end
126
+
127
+ def test_name_with_args
128
+ desc "T"
129
+ t = task(:tt, :a, :b)
130
+ assert_equal "tt", t.name
131
+ assert_equal "T", t.comment
132
+ assert_equal "[a,b]", t.arg_description
133
+ assert_equal "tt[a,b]", t.name_with_args
134
+ assert_equal [:a, :b],t.arg_names
135
+ end
136
+
137
+ def test_named_args_are_passed_to_prereqs
138
+ value = nil
139
+ pre = task(:pre, :rev) { |t, args| value = args.rev }
140
+ t = task(:t, [:name, :rev] => [:pre])
141
+ t.invoke("bill", "1.2")
142
+ assert_equal "1.2", value
143
+ end
144
+
145
+ def test_args_not_passed_if_no_prereq_names
146
+ pre = task(:pre) { |t, args|
147
+ assert_equal({}, args.to_hash)
148
+ assert_equal "bill", args.name
149
+ }
150
+ t = task(:t, [:name, :rev] => [:pre])
151
+ t.invoke("bill", "1.2")
152
+ end
153
+
154
+ def test_args_not_passed_if_no_arg_names
155
+ pre = task(:pre, :rev) { |t, args|
156
+ assert_equal({}, args.to_hash)
157
+ }
158
+ t = task(:t => [:pre])
159
+ t.invoke("bill", "1.2")
160
+ end
161
+ end
162
+
@@ -1,19 +1,20 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
1
+ require File.expand_path('../helper', __FILE__)
4
2
  require 'rake/testtask'
5
3
 
6
- class TestTestTask < Test::Unit::TestCase
4
+ class TestRakeTestTask < Rake::TestCase
7
5
  include Rake
8
- include TestMethods
9
6
 
10
7
  def setup
8
+ super
9
+
11
10
  Task.clear
12
11
  ENV.delete('TEST')
13
12
  end
14
13
 
15
14
  def teardown
16
15
  FileUtils.rm_rf("testdata")
16
+
17
+ super
17
18
  end
18
19
 
19
20
  def test_no_task
@@ -22,7 +23,7 @@ class TestTestTask < Test::Unit::TestCase
22
23
 
23
24
  def test_defaults
24
25
  tt = Rake::TestTask.new do |t| end
25
- assert_not_nil tt
26
+ refute_nil tt
26
27
  assert_equal :test, tt.name
27
28
  assert_equal ['lib'], tt.libs
28
29
  assert_equal 'test/test*.rb', tt.pattern
@@ -36,7 +37,7 @@ class TestTestTask < Test::Unit::TestCase
36
37
  t.pattern = 'test/tc_*.rb'
37
38
  t.verbose = true
38
39
  end
39
- assert_not_nil tt
40
+ refute_nil tt
40
41
  assert_equal :example, tt.name
41
42
  assert_equal ['src', 'ext'], tt.libs
42
43
  assert_equal 'test/tc_*.rb', tt.pattern
@@ -74,4 +75,48 @@ class TestTestTask < Test::Unit::TestCase
74
75
  assert_equal ['a.rb', 'b.rb', '*.rb'], tt.file_list.to_a
75
76
  end
76
77
 
78
+ def test_direct_run_has_quoted_paths
79
+ test_task = Rake::TestTask.new(:tx) do |t|
80
+ t.loader = :direct
81
+ end
82
+ assert_match(/-e ".*"/, test_task.run_code)
83
+ end
84
+
85
+ def test_testrb_run_has_quoted_paths_on_ruby_182
86
+ test_task = Rake::TestTask.new(:tx) do |t|
87
+ t.loader = :testrb
88
+ end
89
+ flexmock(test_task).should_receive(:ruby_version).and_return('1.8.2')
90
+ assert_match(/^-S testrb +".*"$/, test_task.run_code)
91
+ end
92
+
93
+ def test_testrb_run_has_quoted_paths_on_ruby_186
94
+ test_task = Rake::TestTask.new(:tx) do |t|
95
+ t.loader = :testrb
96
+ end
97
+ flexmock(test_task).should_receive(:ruby_version).and_return('1.8.6')
98
+ assert_match(/^-S testrb +$/, test_task.run_code)
99
+ end
100
+
101
+ def test_rake_run_has_quoted_paths
102
+ test_task = Rake::TestTask.new(:tx) do |t|
103
+ t.loader = :rake
104
+ end
105
+ assert_match(/".*"/, test_task.run_code)
106
+ end
107
+
108
+ def test_nested_libs_will_be_flattened
109
+ test_task = Rake::TestTask.new(:tx) do |t|
110
+ t.libs << ["A", "B"]
111
+ end
112
+ sep = File::PATH_SEPARATOR
113
+ assert_match(/lib#{sep}A#{sep}B/, test_task.ruby_opts_string)
114
+ end
115
+
116
+ def test_empty_lib_path_implies_no_dash_I_option
117
+ test_task = Rake::TestTask.new(:tx) do |t|
118
+ t.libs = []
119
+ end
120
+ refute_match(/-I/, test_task.ruby_opts_string)
121
+ end
77
122
  end