rake 0.9.2.2 → 13.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +7 -0
  2. data/History.rdoc +2403 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +64 -106
  5. data/doc/command_line_usage.rdoc +65 -21
  6. data/doc/glossary.rdoc +40 -49
  7. data/doc/jamis.rb +1 -0
  8. data/doc/rake.1 +156 -0
  9. data/doc/rakefile.rdoc +127 -62
  10. data/{bin → exe}/rake +1 -7
  11. data/lib/rake/application.rb +507 -271
  12. data/lib/rake/backtrace.rb +24 -0
  13. data/lib/rake/clean.rb +54 -8
  14. data/lib/rake/cloneable.rb +11 -19
  15. data/lib/rake/cpu_counter.rb +107 -0
  16. data/lib/rake/default_loader.rb +5 -0
  17. data/lib/rake/dsl_definition.rb +67 -48
  18. data/lib/rake/early_time.rb +5 -1
  19. data/lib/rake/ext/core.rb +5 -6
  20. data/lib/rake/ext/string.rb +61 -52
  21. data/lib/rake/file_creation_task.rb +4 -3
  22. data/lib/rake/file_list.rb +81 -49
  23. data/lib/rake/file_task.rb +15 -8
  24. data/lib/rake/file_utils.rb +63 -43
  25. data/lib/rake/file_utils_ext.rb +14 -25
  26. data/lib/rake/invocation_chain.rb +25 -19
  27. data/lib/rake/invocation_exception_mixin.rb +1 -0
  28. data/lib/rake/late_time.rb +18 -0
  29. data/lib/rake/linked_list.rb +112 -0
  30. data/lib/rake/loaders/makefile.rb +23 -9
  31. data/lib/rake/multi_task.rb +4 -6
  32. data/lib/rake/name_space.rb +36 -23
  33. data/lib/rake/packagetask.rb +71 -34
  34. data/lib/rake/phony.rb +16 -0
  35. data/lib/rake/private_reader.rb +21 -0
  36. data/lib/rake/promise.rb +100 -0
  37. data/lib/rake/pseudo_status.rb +8 -2
  38. data/lib/rake/rake_module.rb +41 -3
  39. data/lib/rake/rake_test_loader.rb +9 -4
  40. data/lib/rake/rule_recursion_overflow_error.rb +2 -2
  41. data/lib/rake/scope.rb +43 -0
  42. data/lib/rake/task.rb +186 -79
  43. data/lib/rake/task_argument_error.rb +1 -0
  44. data/lib/rake/task_arguments.rb +46 -15
  45. data/lib/rake/task_manager.rb +91 -67
  46. data/lib/rake/tasklib.rb +2 -12
  47. data/lib/rake/testtask.rb +61 -63
  48. data/lib/rake/thread_history_display.rb +49 -0
  49. data/lib/rake/thread_pool.rb +163 -0
  50. data/lib/rake/trace_output.rb +23 -0
  51. data/lib/rake/version.rb +5 -3
  52. data/lib/rake/win32.rb +14 -18
  53. data/lib/rake.rb +35 -33
  54. data/rake.gemspec +100 -0
  55. metadata +74 -176
  56. data/.gemtest +0 -0
  57. data/CHANGES +0 -522
  58. data/Rakefile +0 -369
  59. data/TODO +0 -20
  60. data/doc/rake.1.gz +0 -0
  61. data/doc/release_notes/rake-0.4.14.rdoc +0 -23
  62. data/doc/release_notes/rake-0.4.15.rdoc +0 -35
  63. data/doc/release_notes/rake-0.5.0.rdoc +0 -53
  64. data/doc/release_notes/rake-0.5.3.rdoc +0 -78
  65. data/doc/release_notes/rake-0.5.4.rdoc +0 -46
  66. data/doc/release_notes/rake-0.6.0.rdoc +0 -141
  67. data/doc/release_notes/rake-0.7.0.rdoc +0 -119
  68. data/doc/release_notes/rake-0.7.1.rdoc +0 -59
  69. data/doc/release_notes/rake-0.7.2.rdoc +0 -121
  70. data/doc/release_notes/rake-0.7.3.rdoc +0 -47
  71. data/doc/release_notes/rake-0.8.0.rdoc +0 -114
  72. data/doc/release_notes/rake-0.8.2.rdoc +0 -165
  73. data/doc/release_notes/rake-0.8.3.rdoc +0 -112
  74. data/doc/release_notes/rake-0.8.4.rdoc +0 -147
  75. data/doc/release_notes/rake-0.8.5.rdoc +0 -53
  76. data/doc/release_notes/rake-0.8.6.rdoc +0 -55
  77. data/doc/release_notes/rake-0.8.7.rdoc +0 -55
  78. data/doc/release_notes/rake-0.9.0.rdoc +0 -112
  79. data/doc/release_notes/rake-0.9.1.rdoc +0 -52
  80. data/doc/release_notes/rake-0.9.2.rdoc +0 -49
  81. data/install.rb +0 -90
  82. data/lib/rake/alt_system.rb +0 -109
  83. data/lib/rake/classic_namespace.rb +0 -11
  84. data/lib/rake/contrib/compositepublisher.rb +0 -21
  85. data/lib/rake/contrib/ftptools.rb +0 -150
  86. data/lib/rake/contrib/publisher.rb +0 -73
  87. data/lib/rake/contrib/rubyforgepublisher.rb +0 -16
  88. data/lib/rake/contrib/sshpublisher.rb +0 -50
  89. data/lib/rake/contrib/sys.rb +0 -191
  90. data/lib/rake/ext/module.rb +0 -39
  91. data/lib/rake/ext/time.rb +0 -14
  92. data/lib/rake/gempackagetask.rb +0 -15
  93. data/lib/rake/pathmap.rb +0 -1
  94. data/lib/rake/rdoctask.rb +0 -234
  95. data/lib/rake/ruby182_test_unit_fix.rb +0 -25
  96. data/lib/rake/runtest.rb +0 -21
  97. data/test/file_creation.rb +0 -34
  98. data/test/helper.rb +0 -492
  99. data/test/test_rake.rb +0 -40
  100. data/test/test_rake_application.rb +0 -489
  101. data/test/test_rake_application_options.rb +0 -335
  102. data/test/test_rake_clean.rb +0 -14
  103. data/test/test_rake_definitions.rb +0 -80
  104. data/test/test_rake_directory_task.rb +0 -46
  105. data/test/test_rake_dsl.rb +0 -77
  106. data/test/test_rake_early_time.rb +0 -31
  107. data/test/test_rake_extension.rb +0 -59
  108. data/test/test_rake_file_creation_task.rb +0 -56
  109. data/test/test_rake_file_list.rb +0 -628
  110. data/test/test_rake_file_list_path_map.rb +0 -8
  111. data/test/test_rake_file_task.rb +0 -102
  112. data/test/test_rake_file_utils.rb +0 -305
  113. data/test/test_rake_ftp_file.rb +0 -59
  114. data/test/test_rake_functional.rb +0 -450
  115. data/test/test_rake_invocation_chain.rb +0 -52
  116. data/test/test_rake_makefile_loader.rb +0 -44
  117. data/test/test_rake_multi_task.rb +0 -51
  118. data/test/test_rake_name_space.rb +0 -43
  119. data/test/test_rake_package_task.rb +0 -79
  120. data/test/test_rake_path_map.rb +0 -157
  121. data/test/test_rake_path_map_explode.rb +0 -34
  122. data/test/test_rake_path_map_partial.rb +0 -18
  123. data/test/test_rake_pseudo_status.rb +0 -21
  124. data/test/test_rake_rake_test_loader.rb +0 -21
  125. data/test/test_rake_rdoc_task.rb +0 -83
  126. data/test/test_rake_require.rb +0 -40
  127. data/test/test_rake_rules.rb +0 -327
  128. data/test/test_rake_task.rb +0 -267
  129. data/test/test_rake_task_argument_parsing.rb +0 -103
  130. data/test/test_rake_task_arguments.rb +0 -88
  131. data/test/test_rake_task_lib.rb +0 -9
  132. data/test/test_rake_task_manager.rb +0 -157
  133. data/test/test_rake_task_manager_argument_resolution.rb +0 -36
  134. data/test/test_rake_task_with_arguments.rb +0 -173
  135. data/test/test_rake_test_task.rb +0 -120
  136. data/test/test_rake_top_level_functions.rb +0 -111
  137. data/test/test_rake_win32.rb +0 -72
  138. data/test/test_sys.rb +0 -20
@@ -1,88 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
-
3
- ######################################################################
4
- class TestRakeTaskArguments < Rake::TestCase
5
- def teardown
6
- ENV.delete('rev')
7
- ENV.delete('VER')
8
-
9
- super
10
- end
11
-
12
- def test_empty_arg_list_is_empty
13
- ta = Rake::TaskArguments.new([], [])
14
- assert_equal({}, ta.to_hash)
15
- end
16
-
17
- def test_multiple_values_in_args
18
- ta = Rake::TaskArguments.new([:a, :b, :c], [:one, :two, :three])
19
- assert_equal({:a => :one, :b => :two, :c => :three}, ta.to_hash)
20
- end
21
-
22
- def test_to_s
23
- ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2, 3])
24
- assert_equal ta.to_hash.inspect, ta.to_s
25
- assert_equal ta.to_hash.inspect, ta.inspect
26
- end
27
-
28
- def test_enumerable_behavior
29
- ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2 ,3])
30
- assert_equal [10, 20, 30], ta.collect { |k,v| v * 10 }.sort
31
- end
32
-
33
- def test_named_args
34
- ta = Rake::TaskArguments.new(["aa", "bb"], [1, 2])
35
- assert_equal 1, ta.aa
36
- assert_equal 1, ta[:aa]
37
- assert_equal 1, ta["aa"]
38
- assert_equal 2, ta.bb
39
- assert_nil ta.cc
40
- end
41
-
42
- def test_args_knows_its_names
43
- ta = Rake::TaskArguments.new(["aa", "bb"], [1, 2])
44
- assert_equal ["aa", "bb"], ta.names
45
- end
46
-
47
- def test_extra_names_are_nil
48
- ta = Rake::TaskArguments.new(["aa", "bb", "cc"], [1, 2])
49
- assert_nil ta.cc
50
- end
51
-
52
- def test_args_do_not_reference_env_values
53
- ta = Rake::TaskArguments.new(["aa"], [1])
54
- ENV['rev'] = "1.2"
55
- ENV['VER'] = "2.3"
56
- assert_nil ta.rev
57
- assert_nil ta.ver
58
- end
59
-
60
- def test_creating_new_argument_scopes
61
- parent = Rake::TaskArguments.new(['p'], [1])
62
- child = parent.new_scope(['c', 'p'])
63
- assert_equal({:p=>1}, child.to_hash)
64
- assert_equal 1, child.p
65
- assert_equal 1, child["p"]
66
- assert_equal 1, child[:p]
67
- assert_nil child.c
68
- end
69
-
70
- def test_child_hides_parent_arg_names
71
- parent = Rake::TaskArguments.new(['aa'], [1])
72
- child = Rake::TaskArguments.new(['aa'], [2], parent)
73
- assert_equal 2, child.aa
74
- end
75
-
76
- def test_default_arguments_values_can_be_merged
77
- ta = Rake::TaskArguments.new(["aa", "bb"], [nil, "original_val"])
78
- ta.with_defaults({ :aa => 'default_val' })
79
- assert_equal 'default_val', ta[:aa]
80
- assert_equal 'original_val', ta[:bb]
81
- end
82
-
83
- def test_default_arguments_that_dont_match_names_are_ignored
84
- ta = Rake::TaskArguments.new(["aa", "bb"], [nil, "original_val"])
85
- ta.with_defaults({ "cc" => "default_val" })
86
- assert_nil ta[:cc]
87
- end
88
- end
@@ -1,9 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
- require 'rake/tasklib'
3
-
4
- class TestRakeTaskLib < Rake::TestCase
5
- def test_paste
6
- tl = Rake::TaskLib.new
7
- assert_equal :ab, tl.paste(:a, :b)
8
- end
9
- end
@@ -1,157 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
-
3
- class TestRakeTaskManager < Rake::TestCase
4
-
5
- def setup
6
- super
7
-
8
- @tm = Rake::TestCase::TaskManager.new
9
- end
10
-
11
- def test_create_task_manager
12
- refute_nil @tm
13
- assert_equal [], @tm.tasks
14
- end
15
-
16
- def test_define_task
17
- t = @tm.define_task(Rake::Task, :t)
18
- assert_equal "t", t.name
19
- assert_equal @tm, t.application
20
- end
21
-
22
- def test_index
23
- e = assert_raises RuntimeError do
24
- @tm['bad']
25
- end
26
-
27
- assert_equal "Don't know how to build task 'bad'", e.message
28
- end
29
-
30
- def test_name_lookup
31
- t = @tm.define_task(Rake::Task, :t)
32
- assert_equal t, @tm[:t]
33
- end
34
-
35
- def test_namespace_task_create
36
- @tm.in_namespace("x") do
37
- t = @tm.define_task(Rake::Task, :t)
38
- assert_equal "x:t", t.name
39
- end
40
- assert_equal ["x:t"], @tm.tasks.collect { |t| t.name }
41
- end
42
-
43
- def test_anonymous_namespace
44
- anon_ns = @tm.in_namespace(nil) do
45
- t = @tm.define_task(Rake::Task, :t)
46
- assert_equal "_anon_1:t", t.name
47
- end
48
- task = anon_ns[:t]
49
- assert_equal "_anon_1:t", task.name
50
- end
51
-
52
- def test_create_filetask_in_namespace
53
- @tm.in_namespace("x") do
54
- t = @tm.define_task(Rake::FileTask, "fn")
55
- assert_equal "fn", t.name
56
- end
57
-
58
- assert_equal ["fn"], @tm.tasks.collect { |t| t.name }
59
- end
60
-
61
- def test_namespace_yields_same_namespace_as_returned
62
- yielded_namespace = nil
63
- returned_namespace = @tm.in_namespace("x") do |ns|
64
- yielded_namespace = ns
65
- end
66
- assert_equal returned_namespace, yielded_namespace
67
- end
68
-
69
- def test_name_lookup_with_implicit_file_tasks
70
- FileUtils.touch 'README.rdoc'
71
-
72
- t = @tm["README.rdoc"]
73
-
74
- assert_equal "README.rdoc", t.name
75
- assert Rake::FileTask === t
76
- end
77
-
78
- def test_name_lookup_with_nonexistent_task
79
- assert_raises(RuntimeError) {
80
- @tm["DOES NOT EXIST"]
81
- }
82
- end
83
-
84
- def test_name_lookup_in_multiple_scopes
85
- aa = nil
86
- bb = nil
87
- xx = @tm.define_task(Rake::Task, :xx)
88
- top_z = @tm.define_task(Rake::Task, :z)
89
- @tm.in_namespace("a") do
90
- aa = @tm.define_task(Rake::Task, :aa)
91
- mid_z = @tm.define_task(Rake::Task, :z)
92
- @tm.in_namespace("b") do
93
- bb = @tm.define_task(Rake::Task, :bb)
94
- bot_z = @tm.define_task(Rake::Task, :z)
95
-
96
- assert_equal ["a", "b"], @tm.current_scope
97
-
98
- assert_equal bb, @tm["a:b:bb"]
99
- assert_equal aa, @tm["a:aa"]
100
- assert_equal xx, @tm["xx"]
101
- assert_equal bot_z, @tm["z"]
102
- assert_equal mid_z, @tm["^z"]
103
- assert_equal top_z, @tm["^^z"]
104
- assert_equal top_z, @tm["rake:z"]
105
- end
106
-
107
- assert_equal ["a"], @tm.current_scope
108
-
109
- assert_equal bb, @tm["a:b:bb"]
110
- assert_equal aa, @tm["a:aa"]
111
- assert_equal xx, @tm["xx"]
112
- assert_equal bb, @tm["b:bb"]
113
- assert_equal aa, @tm["aa"]
114
- assert_equal mid_z, @tm["z"]
115
- assert_equal top_z, @tm["^z"]
116
- assert_equal top_z, @tm["rake:z"]
117
- end
118
-
119
- assert_equal [], @tm.current_scope
120
-
121
- assert_equal [], xx.scope
122
- assert_equal ['a'], aa.scope
123
- assert_equal ['a', 'b'], bb.scope
124
- end
125
-
126
- def test_lookup_with_explicit_scopes
127
- t1, t2, t3, s = (0...4).collect { nil }
128
- t1 = @tm.define_task(Rake::Task, :t)
129
- @tm.in_namespace("a") do
130
- t2 = @tm.define_task(Rake::Task, :t)
131
- s = @tm.define_task(Rake::Task, :s)
132
- @tm.in_namespace("b") do
133
- t3 = @tm.define_task(Rake::Task, :t)
134
- end
135
- end
136
- assert_equal t1, @tm[:t, []]
137
- assert_equal t2, @tm[:t, ["a"]]
138
- assert_equal t3, @tm[:t, ["a", "b"]]
139
- assert_equal s, @tm[:s, ["a", "b"]]
140
- assert_equal s, @tm[:s, ["a"]]
141
- end
142
-
143
- def test_correctly_scoped_prerequisites_are_invoked
144
- values = []
145
- @tm = Rake::Application.new
146
- @tm.define_task(Rake::Task, :z) do values << "top z" end
147
- @tm.in_namespace("a") do
148
- @tm.define_task(Rake::Task, :z) do values << "next z" end
149
- @tm.define_task(Rake::Task, :x => :z)
150
- end
151
-
152
- @tm["a:x"].invoke
153
- assert_equal ["next z"], values
154
- end
155
-
156
- end
157
-
@@ -1,36 +0,0 @@
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
@@ -1,173 +0,0 @@
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
-
162
- def test_values_at
163
- t = task(:pre, [:a, :b, :c]) { |task, args|
164
- a, b, c = args.values_at(:a, :b, :c)
165
- assert_equal %w[1 2 3], [a, b, c]
166
- }
167
-
168
- t.invoke(*%w[1 2 3])
169
-
170
- # HACK no assertions
171
- end
172
- end
173
-
@@ -1,120 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
- require 'rake/testtask'
3
-
4
- class TestRakeTestTask < Rake::TestCase
5
- include Rake
6
-
7
- def test_initialize
8
- tt = Rake::TestTask.new do |t| end
9
- refute_nil tt
10
- assert_equal :test, tt.name
11
- assert_equal ['lib'], tt.libs
12
- assert_equal 'test/test*.rb', tt.pattern
13
- assert_equal false, tt.verbose
14
- assert Task.task_defined?(:test)
15
- end
16
-
17
- def test_initialize_override
18
- tt = Rake::TestTask.new(:example) do |t|
19
- t.libs = ['src', 'ext']
20
- t.pattern = 'test/tc_*.rb'
21
- t.verbose = true
22
- end
23
- refute_nil tt
24
- assert_equal :example, tt.name
25
- assert_equal ['src', 'ext'], tt.libs
26
- assert_equal 'test/tc_*.rb', tt.pattern
27
- assert_equal true, tt.verbose
28
- assert Task.task_defined?(:example)
29
- end
30
-
31
- def test_file_list_ENV_TEST
32
- ENV['TEST'] = 'testfile.rb'
33
- tt = Rake::TestTask.new do |t|
34
- t.pattern = '*'
35
- end
36
-
37
- assert_equal ["testfile.rb"], tt.file_list.to_a
38
- ensure
39
- ENV.delete 'TEST'
40
- end
41
-
42
- def test_libs_equals
43
- test_task = Rake::TestTask.new do |t|
44
- t.libs << ["A", "B"]
45
- end
46
-
47
- path = %w[lib A B].join File::PATH_SEPARATOR
48
-
49
- assert_equal "-I\"#{path}\"", test_task.ruby_opts_string
50
- end
51
-
52
- def test_libs_equals_empty
53
- test_task = Rake::TestTask.new do |t|
54
- t.libs = []
55
- end
56
-
57
- assert_equal '', test_task.ruby_opts_string
58
- end
59
-
60
- def test_pattern_equals
61
- tt = Rake::TestTask.new do |t|
62
- t.pattern = '*.rb'
63
- end
64
- assert_equal ['*.rb'], tt.file_list.to_a
65
- end
66
-
67
- def test_pattern_equals_test_files_equals
68
- tt = Rake::TestTask.new do |t|
69
- t.test_files = FileList['a.rb', 'b.rb']
70
- t.pattern = '*.rb'
71
- end
72
- assert_equal ['a.rb', 'b.rb', '*.rb'], tt.file_list.to_a
73
- end
74
-
75
- def test_run_code_direct
76
- test_task = Rake::TestTask.new do |t|
77
- t.loader = :direct
78
- end
79
-
80
- assert_equal '-e "ARGV.each{|f| require f}"', test_task.run_code
81
- end
82
-
83
- def test_run_code_rake
84
- test_task = Rake::TestTask.new do |t|
85
- t.loader = :rake
86
- end
87
-
88
- assert_match(/-I".*?" ".*?"/, test_task.run_code)
89
- end
90
-
91
- def test_run_code_testrb_ruby_1_8_2
92
- test_task = Rake::TestTask.new do |t|
93
- t.loader = :testrb
94
- end
95
-
96
- def test_task.ruby_version() '1.8.2' end
97
-
98
- assert_match(/^-S testrb +".*"$/, test_task.run_code)
99
- end
100
-
101
- def test_run_code_testrb_ruby_1_8_6
102
- test_task = Rake::TestTask.new do |t|
103
- t.loader = :testrb
104
- end
105
-
106
- def test_task.ruby_version() '1.8.6' end
107
-
108
- assert_match(/^-S testrb +$/, test_task.run_code)
109
- end
110
-
111
- def test_test_files_equals
112
- tt = Rake::TestTask.new do |t|
113
- t.test_files = FileList['a.rb', 'b.rb']
114
- end
115
-
116
- assert_equal ["a.rb", 'b.rb'], tt.file_list.to_a
117
- end
118
-
119
- end
120
-
@@ -1,111 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
-
3
- class TestRakeTopLevelFunctions < Rake::TestCase
4
-
5
- def setup
6
- super
7
-
8
- @app = Object.new
9
-
10
- def @app.called
11
- @called
12
- end
13
-
14
- def @app.method_missing(*a, &b)
15
- @called ||= []
16
- @called << [a, b]
17
- nil
18
- end
19
-
20
- Rake.application = @app
21
- end
22
-
23
- def test_namespace
24
- block = proc do end
25
-
26
- namespace("xyz", &block)
27
-
28
- expected = [
29
- [[:in_namespace, 'xyz'], block]
30
- ]
31
-
32
- assert_equal expected, @app.called
33
- end
34
-
35
- def test_import
36
- import('x', 'y', 'z')
37
-
38
- expected = [
39
- [[:add_import, 'x'], nil],
40
- [[:add_import, 'y'], nil],
41
- [[:add_import, 'z'], nil],
42
- ]
43
-
44
- assert_equal expected, @app.called
45
- end
46
-
47
- def test_when_writing
48
- out, = capture_io do
49
- when_writing("NOTWRITING") do
50
- puts "WRITING"
51
- end
52
- end
53
- assert_equal "WRITING\n", out
54
- end
55
-
56
- def test_when_not_writing
57
- Rake::FileUtilsExt.nowrite_flag = true
58
- _, err = capture_io do
59
- when_writing("NOTWRITING") do
60
- puts "WRITING"
61
- end
62
- end
63
- assert_equal "DRYRUN: NOTWRITING\n", err
64
- ensure
65
- Rake::FileUtilsExt.nowrite_flag = false
66
- end
67
-
68
- def test_missing_constants_task
69
- Object.const_missing(:Task)
70
-
71
- expected = [
72
- [[:const_warning, :Task], nil]
73
- ]
74
-
75
- assert_equal expected, @app.called
76
- end
77
-
78
- def test_missing_constants_file_task
79
- Object.const_missing(:FileTask)
80
-
81
- expected = [
82
- [[:const_warning, :FileTask], nil]
83
- ]
84
-
85
- assert_equal expected, @app.called
86
- end
87
-
88
- def test_missing_constants_file_creation_task
89
- Object.const_missing(:FileCreationTask)
90
-
91
- expected = [
92
- [[:const_warning, :FileCreationTask], nil]
93
- ]
94
-
95
- assert_equal expected, @app.called
96
- end
97
-
98
- def test_missing_constants_rake_app
99
- Object.const_missing(:RakeApp)
100
-
101
- expected = [
102
- [[:const_warning, :RakeApp], nil]
103
- ]
104
-
105
- assert_equal expected, @app.called
106
- end
107
-
108
- def test_missing_other_constant
109
- assert_raises(NameError) do Object.const_missing(:Xyz) end
110
- end
111
- end