rake 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rake might be problematic. Click here for more details.

Files changed (66) hide show
  1. data/CHANGES +9 -8
  2. data/RRR +10 -0
  3. data/Rakefile +9 -45
  4. data/bin/rake +4 -3
  5. data/doc/release_notes/rake-0.9.1.rdoc +52 -0
  6. data/lib/rake/dsl_definition.rb +19 -0
  7. data/lib/rake/version.rb +1 -1
  8. data/test/data/access/Rakefile +3 -1
  9. data/test/data/default/Rakefile +0 -2
  10. data/test/data/file_creation_task/Rakefile +0 -2
  11. data/test/data/multidesc/Rakefile +0 -2
  12. data/test/data/namespace/Rakefile +0 -2
  13. data/test/data/statusreturn/Rakefile +0 -2
  14. data/test/file_creation.rb +0 -2
  15. data/test/helper.rb +44 -0
  16. data/test/in_environment.rb +4 -1
  17. data/test/{lib/rake_test.rb → test_rake.rb} +2 -5
  18. data/test/test_rake_application.rb +364 -0
  19. data/test/test_rake_application_options.rb +382 -0
  20. data/test/{lib/clean_test.rb → test_rake_clean.rb} +2 -5
  21. data/test/{lib/definitions_test.rb → test_rake_definitions.rb} +5 -10
  22. data/test/test_rake_directory_task.rb +55 -0
  23. data/test/test_rake_dsl.rb +53 -0
  24. data/test/{lib/earlytime_test.rb → test_rake_early_time.rb} +2 -5
  25. data/test/{lib/extension_test.rb → test_rake_extension.rb} +2 -6
  26. data/test/{lib/file_creation_task_test.rb → test_rake_file_creation_task.rb} +7 -7
  27. data/test/{lib/filelist_test.rb → test_rake_file_list.rb} +18 -22
  28. data/test/test_rake_file_list_path_map.rb +8 -0
  29. data/test/{lib/file_task_test.rb → test_rake_file_task.rb} +22 -61
  30. data/test/{lib/fileutils_test.rb → test_rake_file_utils.rb} +11 -15
  31. data/test/{lib/ftp_test.rb → test_rake_ftp_file.rb} +5 -5
  32. data/test/{functional/session_based_tests.rb → test_rake_functional.rb} +35 -24
  33. data/test/test_rake_invocation_chain.rb +52 -0
  34. data/test/{lib/makefile_loader_test.rb → test_rake_makefile_loader.rb} +2 -5
  35. data/test/{lib/multitask_test.rb → test_rake_multi_task.rb} +5 -7
  36. data/test/{lib/namespace_test.rb → test_rake_name_space.rb} +4 -16
  37. data/test/{lib/package_task_test.rb → test_rake_package_task.rb} +2 -6
  38. data/test/{lib/pathmap_test.rb → test_rake_path_map.rb} +4 -58
  39. data/test/test_rake_path_map_explode.rb +31 -0
  40. data/test/test_rake_path_map_partial.rb +18 -0
  41. data/test/{lib/pseudo_status_test.rb → test_rake_pseudo_status.rb} +2 -8
  42. data/test/{lib/rdoc_task_test.rb → test_rake_rdoc_task.rb} +4 -7
  43. data/test/{lib/require_test.rb → test_rake_require.rb} +3 -9
  44. data/test/{lib/rules_test.rb → test_rake_rules.rb} +11 -13
  45. data/test/{lib/task_test.rb → test_rake_task.rb} +16 -182
  46. data/test/test_rake_task_argument_parsing.rb +116 -0
  47. data/test/{lib/task_arguments_test.rb → test_rake_task_arguments.rb} +2 -5
  48. data/test/{lib/tasklib_test.rb → test_rake_task_lib.rb} +2 -5
  49. data/test/{lib/task_manager_test.rb → test_rake_task_manager.rb} +7 -45
  50. data/test/test_rake_task_manager_argument_resolution.rb +36 -0
  51. data/test/test_rake_task_with_arguments.rb +162 -0
  52. data/test/{lib/test_task_test.rb → test_rake_test_task.rb} +52 -7
  53. data/test/{lib/top_level_functions_test.rb → test_rake_top_level_functions.rb} +8 -20
  54. data/test/{lib/win32_test.rb → test_rake_win32.rb} +4 -12
  55. data/test/{contrib/test_sys.rb → test_sys.rb} +2 -6
  56. metadata +60 -44
  57. data/lib/rake/dsl.rb +0 -2
  58. data/test/capture_stdout.rb +0 -26
  59. data/test/functional/functional_test.rb +0 -25
  60. data/test/lib/application_test.rb +0 -863
  61. data/test/lib/dsl_test.rb +0 -52
  62. data/test/lib/invocation_chain_test.rb +0 -81
  63. data/test/lib/testtask_test.rb +0 -49
  64. data/test/rake_test_setup.rb +0 -20
  65. data/test/ruby_version_test.rb +0 -3
  66. data/test/test_helper.rb +0 -19
@@ -0,0 +1,116 @@
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
+ end
9
+
10
+ def test_name_only
11
+ name, args = @app.parse_task_string("name")
12
+ assert_equal "name", name
13
+ assert_equal [], args
14
+ end
15
+
16
+ def test_empty_args
17
+ name, args = @app.parse_task_string("name[]")
18
+ assert_equal "name", name
19
+ assert_equal [], args
20
+ end
21
+
22
+ def test_one_argument
23
+ name, args = @app.parse_task_string("name[one]")
24
+ assert_equal "name", name
25
+ assert_equal ["one"], args
26
+ end
27
+
28
+ def test_two_arguments
29
+ name, args = @app.parse_task_string("name[one,two]")
30
+ assert_equal "name", name
31
+ assert_equal ["one", "two"], args
32
+ end
33
+
34
+ def test_can_handle_spaces_between_args
35
+ name, args = @app.parse_task_string("name[one, two,\tthree , \tfour]")
36
+ assert_equal "name", name
37
+ assert_equal ["one", "two", "three", "four"], args
38
+ end
39
+
40
+ def test_keeps_embedded_spaces
41
+ name, args = @app.parse_task_string("name[a one ana, two]")
42
+ assert_equal "name", name
43
+ assert_equal ["a one ana", "two"], args
44
+ end
45
+
46
+ def test_terminal_width_using_env
47
+ app = Rake::Application.new
48
+ in_environment('RAKE_COLUMNS' => '1234') do
49
+ assert_equal 1234, app.terminal_width
50
+ end
51
+ end
52
+
53
+ def test_terminal_width_using_stty
54
+ app = Rake::Application.new
55
+ flexmock(app,
56
+ :unix? => true,
57
+ :dynamic_width_stty => 1235,
58
+ :dynamic_width_tput => 0)
59
+ in_environment('RAKE_COLUMNS' => nil) do
60
+ assert_equal 1235, app.terminal_width
61
+ end
62
+ end
63
+
64
+ def test_terminal_width_using_tput
65
+ app = Rake::Application.new
66
+ flexmock(app,
67
+ :unix? => true,
68
+ :dynamic_width_stty => 0,
69
+ :dynamic_width_tput => 1236)
70
+ in_environment('RAKE_COLUMNS' => nil) do
71
+ assert_equal 1236, app.terminal_width
72
+ end
73
+ end
74
+
75
+ def test_terminal_width_using_hardcoded_80
76
+ app = Rake::Application.new
77
+ flexmock(app, :unix? => false)
78
+ in_environment('RAKE_COLUMNS' => nil) do
79
+ assert_equal 80, app.terminal_width
80
+ end
81
+ end
82
+
83
+ def test_terminal_width_with_failure
84
+ app = Rake::Application.new
85
+ flexmock(app).should_receive(:unix?).and_throw(RuntimeError)
86
+ in_environment('RAKE_COLUMNS' => nil) do
87
+ assert_equal 80, app.terminal_width
88
+ end
89
+ end
90
+
91
+ def test_no_rakeopt
92
+ in_environment do
93
+ ARGV << '--trace'
94
+ app = Rake::Application.new
95
+ app.init
96
+ assert !app.options.silent
97
+ end
98
+ end
99
+
100
+ def test_rakeopt_with_blank_options
101
+ in_environment("RAKEOPT" => "") do
102
+ ARGV << '--trace'
103
+ app = Rake::Application.new
104
+ app.init
105
+ assert !app.options.silent
106
+ end
107
+ end
108
+
109
+ def test_rakeopt_with_silent_options
110
+ in_environment("RAKEOPT" => "-s") do
111
+ app = Rake::Application.new
112
+ app.init
113
+ assert app.options.silent
114
+ end
115
+ end
116
+ 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
@@ -150,34 +143,3 @@ class TestTaskManager < Test::Unit::TestCase
150
143
 
151
144
  end
152
145
 
153
- class TestTaskManagerArgumentResolution < Test::Unit::TestCase
154
- def setup
155
- super
156
- Rake.application.options.ignore_deprecate = true
157
- end
158
-
159
- def teardown
160
- Rake.application.options.ignore_deprecate = false
161
- super
162
- end
163
-
164
- def test_good_arg_patterns
165
- assert_equal [:t, [], []], task(:t)
166
- assert_equal [:t, [], [:x]], task(:t => :x)
167
- assert_equal [:t, [], [:x, :y]], task(:t => [:x, :y])
168
-
169
- assert_equal [:t, [:a, :b], []], task(:t, :a, :b)
170
- assert_equal [:t, [], [:x]], task(:t, :needs => :x)
171
- assert_equal [:t, [:a, :b], [:x]], task(:t, :a, :b, :needs => :x)
172
- assert_equal [:t, [:a, :b], [:x, :y]], task(:t, :a, :b, :needs => [:x, :y])
173
-
174
- assert_equal [:t, [:a, :b], []], task(:t, [:a, :b])
175
- assert_equal [:t, [:a, :b], [:x]], task(:t, [:a, :b] => :x)
176
- assert_equal [:t, [:a, :b], [:x, :y]], task(:t, [:a, :b] => [:x, :y])
177
- end
178
-
179
- def task(*args)
180
- tm = TaskManager.new
181
- tm.resolve_args(args)
182
- end
183
- 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 = []
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