jimweirich-rake 0.8.1.8 → 0.8.1.9
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.
- data/lib/rake.rb +7 -3
- data/test/in_environment.rb +28 -0
- data/test/session_functional.rb +80 -37
- data/test/test_application.rb +3 -25
- data/test/test_filelist.rb +1 -1
- data/test/test_tasks.rb +1 -1
- metadata +3 -2
data/lib/rake.rb
CHANGED
@@ -29,7 +29,7 @@
|
|
29
29
|
# as a library via a require statement, but it can be distributed
|
30
30
|
# independently as an application.
|
31
31
|
|
32
|
-
RAKEVERSION = '0.8.1.
|
32
|
+
RAKEVERSION = '0.8.1.9'
|
33
33
|
|
34
34
|
require 'rbconfig'
|
35
35
|
require 'getoptlong'
|
@@ -2274,7 +2274,7 @@ module Rake
|
|
2274
2274
|
while ! (fn = have_rakefile)
|
2275
2275
|
Dir.chdir("..")
|
2276
2276
|
if Dir.pwd == here || options.nosearch
|
2277
|
-
|
2277
|
+
return nil
|
2278
2278
|
end
|
2279
2279
|
here = Dir.pwd
|
2280
2280
|
end
|
@@ -2285,12 +2285,16 @@ module Rake
|
|
2285
2285
|
|
2286
2286
|
def raw_load_rakefile # :nodoc:
|
2287
2287
|
rakefile, location = find_rakefile_location
|
2288
|
-
if (! options.ignore_system) &&
|
2288
|
+
if (! options.ignore_system) &&
|
2289
|
+
(options.load_system || rakefile.nil?) &&
|
2290
|
+
File.directory?(system_dir)
|
2289
2291
|
puts "(in #{Dir.pwd})" unless options.silent
|
2290
2292
|
Dir["#{system_dir}/*.rake"].each do |name|
|
2291
2293
|
add_import name
|
2292
2294
|
end
|
2293
2295
|
else
|
2296
|
+
fail "No Rakefile found (looking for: #{@rakefiles.join(', ')})" if
|
2297
|
+
rakefile.nil?
|
2294
2298
|
@rakefile = rakefile
|
2295
2299
|
Dir.chdir(location)
|
2296
2300
|
puts "(in #{Dir.pwd})" unless options.silent
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module InEnvironment
|
2
|
+
private
|
3
|
+
|
4
|
+
# Create an environment for a test. At the completion of the yielded
|
5
|
+
# block, the environment is restored to its original conditions.
|
6
|
+
def in_environment(settings)
|
7
|
+
original_dir = Dir.pwd
|
8
|
+
original_settings = set_env(settings)
|
9
|
+
yield
|
10
|
+
ensure
|
11
|
+
set_env(original_settings)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Set the environment according to the settings hash.
|
15
|
+
def set_env(settings) # :nodoc:
|
16
|
+
result = {}
|
17
|
+
settings.each do |k, v|
|
18
|
+
result[k] = ENV[k]
|
19
|
+
if k == 'PWD'
|
20
|
+
Dir.chdir(v)
|
21
|
+
else
|
22
|
+
ENV[k] = v
|
23
|
+
end
|
24
|
+
end
|
25
|
+
result
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/test/session_functional.rb
CHANGED
@@ -7,6 +7,7 @@ end
|
|
7
7
|
require 'test/unit'
|
8
8
|
require 'fileutils'
|
9
9
|
require 'session'
|
10
|
+
require 'test/in_environment'
|
10
11
|
|
11
12
|
# Version 2.1.9 of session has a bug where the @debug instance
|
12
13
|
# variable is not initialized, causing warning messages. This snippet
|
@@ -22,6 +23,7 @@ module Session
|
|
22
23
|
end
|
23
24
|
|
24
25
|
class FunctionalTest < Test::Unit::TestCase
|
26
|
+
include InEnvironment
|
25
27
|
|
26
28
|
RUBY_COMMAND = 'ruby'
|
27
29
|
|
@@ -66,18 +68,22 @@ class FunctionalTest < Test::Unit::TestCase
|
|
66
68
|
end
|
67
69
|
|
68
70
|
def test_multi_desc
|
69
|
-
|
70
|
-
|
71
|
+
in_environment(
|
72
|
+
'RAKE_COLUMNS' => "80",
|
73
|
+
"PWD" => "test/data/multidesc"
|
74
|
+
) do
|
75
|
+
rake "-T"
|
76
|
+
end
|
71
77
|
assert_match %r{^rake a *# A / A2 *$}, @out
|
72
78
|
assert_match %r{^rake b *# B *$}, @out
|
73
79
|
assert_no_match %r{^rake c}, @out
|
74
80
|
assert_match %r{^rake d *# x{65}\.\.\.$}, @out
|
75
|
-
ensure
|
76
|
-
ENV['RAKE_COLUMNS'] = nil
|
77
81
|
end
|
78
|
-
|
82
|
+
|
79
83
|
def test_long_description
|
80
|
-
|
84
|
+
in_environment("PWD" => "test/data/multidesc") do
|
85
|
+
rake "--describe"
|
86
|
+
end
|
81
87
|
assert_match %r{^rake a\n *A / A2 *$}m, @out
|
82
88
|
assert_match %r{^rake b\n *B *$}m, @out
|
83
89
|
assert_match %r{^rake d\n *x{80}}m, @out
|
@@ -85,34 +91,59 @@ class FunctionalTest < Test::Unit::TestCase
|
|
85
91
|
end
|
86
92
|
|
87
93
|
def test_rbext
|
88
|
-
|
94
|
+
in_environment("PWD" => "test/data/rbext") do
|
95
|
+
rake "-N"
|
96
|
+
end
|
89
97
|
assert_match %r{^OK$}, @out
|
90
98
|
end
|
91
99
|
|
92
100
|
def test_system
|
93
|
-
|
94
|
-
|
101
|
+
in_environment('RAKE_SYSTEM' => 'test/data/sys') do
|
102
|
+
rake '-g', "sys1"
|
103
|
+
end
|
104
|
+
assert_match %r{^SYS1}, @out
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_implicit_system
|
108
|
+
in_environment('RAKE_SYSTEM' => File.expand_path('test/data/sys'), "PWD" => "/") do
|
109
|
+
rake "sys1", "--trace"
|
110
|
+
end
|
95
111
|
assert_match %r{^SYS1}, @out
|
96
|
-
ensure
|
97
|
-
ENV['RAKE_SYSTEM'] = nil
|
98
112
|
end
|
99
113
|
|
100
114
|
def test_no_system
|
101
|
-
|
102
|
-
|
115
|
+
in_environment('RAKE_SYSTEM' => 'test/data/sys') do
|
116
|
+
rake '-G', "sys1"
|
117
|
+
end
|
103
118
|
assert_match %r{^Don't know how to build task}, @err # emacs wart: '
|
104
|
-
ensure
|
105
|
-
ENV['RAKE_SYSTEM'] = nil
|
106
119
|
end
|
107
120
|
|
108
|
-
def
|
109
|
-
|
110
|
-
|
121
|
+
def test_nosearch_with_rakefile_uses_local_rakefile
|
122
|
+
in_environment("PWD" => "test/data/default") do
|
123
|
+
rake "--nosearch"
|
124
|
+
end
|
125
|
+
assert_match %r{^DEFAULT}, @out
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_nosearch_without_rakefile_finds_system
|
129
|
+
in_environment(
|
130
|
+
"PWD" => "test/data/nosearch",
|
131
|
+
"RAKE_SYSTEM" => File.expand_path("test/data/sys")
|
132
|
+
) do
|
133
|
+
rake "--nosearch", "sys1"
|
134
|
+
end
|
135
|
+
assert_match %r{^SYS1}, @out
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_nosearch_without_rakefile_and_no_system_fails
|
139
|
+
in_environment("PWD" => "test/data/nosearch", "RAKE_SYSTEM" => "not_exist") do
|
140
|
+
rake "--nosearch"
|
141
|
+
end
|
111
142
|
assert_match %r{^No Rakefile found}, @err
|
112
143
|
end
|
113
144
|
|
114
145
|
def test_dry_run
|
115
|
-
|
146
|
+
in_environment("PWD" => "test/data/default") do rake "-n", "other" end
|
116
147
|
assert_match %r{Execute \(dry run\) default}, @out
|
117
148
|
assert_match %r{Execute \(dry run\) other}, @out
|
118
149
|
assert_no_match %r{DEFAULT}, @out
|
@@ -121,18 +152,26 @@ class FunctionalTest < Test::Unit::TestCase
|
|
121
152
|
|
122
153
|
# Test for the trace/dry_run bug found by Brian Chandler
|
123
154
|
def test_dry_run_bug
|
124
|
-
|
155
|
+
in_environment("PWD" => "test/data/dryrun") do
|
156
|
+
rake
|
157
|
+
end
|
125
158
|
FileUtils.rm_f "test/data/dryrun/temp_one"
|
126
|
-
|
159
|
+
in_environment("PWD" => "test/data/dryrun") do
|
160
|
+
rake "--dry-run"
|
161
|
+
end
|
127
162
|
assert_no_match(/No such file/, @out)
|
128
163
|
assert_status
|
129
164
|
end
|
130
165
|
|
131
166
|
# Test for the trace/dry_run bug found by Brian Chandler
|
132
167
|
def test_trace_bug
|
133
|
-
|
168
|
+
in_environment("PWD" => "test/data/dryrun") do
|
169
|
+
rake
|
170
|
+
end
|
134
171
|
FileUtils.rm_f "test/data/dryrun/temp_one"
|
135
|
-
|
172
|
+
in_environment("PWD" => "test/data/dryrun") do
|
173
|
+
rake "--trace"
|
174
|
+
end
|
136
175
|
assert_no_match(/No such file/, @out)
|
137
176
|
assert_status
|
138
177
|
end
|
@@ -142,7 +181,9 @@ class FunctionalTest < Test::Unit::TestCase
|
|
142
181
|
f.puts 'puts "STATIC"'
|
143
182
|
end
|
144
183
|
FileUtils.rm_f "test/data/imports/dynamic_deps"
|
145
|
-
|
184
|
+
in_environment("PWD" => "test/data/imports") do
|
185
|
+
rake
|
186
|
+
end
|
146
187
|
assert File.exist?("test/data/imports/dynamic_deps"),
|
147
188
|
"'dynamic_deps' file should exist"
|
148
189
|
assert_match(/^FIRST$\s+^DYNAMIC$\s+^STATIC$\s+^OTHER$/, @out)
|
@@ -153,7 +194,9 @@ class FunctionalTest < Test::Unit::TestCase
|
|
153
194
|
|
154
195
|
def test_rules_chaining_to_file_task
|
155
196
|
remove_chaining_files
|
156
|
-
|
197
|
+
in_environment("PWD" => "test/data/chains") do
|
198
|
+
rake
|
199
|
+
end
|
157
200
|
assert File.exist?("test/data/chains/play.app"),
|
158
201
|
"'play.app' file should exist"
|
159
202
|
assert_status
|
@@ -161,12 +204,12 @@ class FunctionalTest < Test::Unit::TestCase
|
|
161
204
|
end
|
162
205
|
|
163
206
|
def test_file_creation_task
|
164
|
-
|
207
|
+
in_environment("PWD" => "test/data/file_creation_task") do
|
165
208
|
rake "prep"
|
166
209
|
rake "run"
|
167
210
|
rake "run"
|
168
|
-
assert(@err !~ /^cp src/, "Should not recopy data")
|
169
211
|
end
|
212
|
+
assert(@err !~ /^cp src/, "Should not recopy data")
|
170
213
|
end
|
171
214
|
|
172
215
|
def test_dash_f_with_no_arg_foils_rakefile_lookup
|
@@ -180,63 +223,63 @@ class FunctionalTest < Test::Unit::TestCase
|
|
180
223
|
end
|
181
224
|
|
182
225
|
def test_can_invoke_task_in_toplevel_namespace
|
183
|
-
|
226
|
+
in_environment("PWD" => "test/data/namespace") do
|
184
227
|
rake "copy"
|
185
|
-
assert_match(/^COPY$/, @out)
|
186
228
|
end
|
229
|
+
assert_match(/^COPY$/, @out)
|
187
230
|
end
|
188
231
|
|
189
232
|
def test_can_invoke_task_in_nested_namespace
|
190
|
-
|
233
|
+
in_environment("PWD" => "test/data/namespace") do
|
191
234
|
rake "nest:copy"
|
192
235
|
assert_match(/^NEST COPY$/, @out)
|
193
236
|
end
|
194
237
|
end
|
195
238
|
|
196
239
|
def test_tasks_can_reference_task_in_same_namespace
|
197
|
-
|
240
|
+
in_environment("PWD" => "test/data/namespace") do
|
198
241
|
rake "nest:xx"
|
199
242
|
assert_match(/^NEST COPY$/m, @out)
|
200
243
|
end
|
201
244
|
end
|
202
245
|
|
203
246
|
def test_tasks_can_reference_task_in_other_namespaces
|
204
|
-
|
247
|
+
in_environment("PWD" => "test/data/namespace") do
|
205
248
|
rake "b:run"
|
206
249
|
assert_match(/^IN A\nIN B$/m, @out)
|
207
250
|
end
|
208
251
|
end
|
209
252
|
|
210
253
|
def test_anonymous_tasks_can_be_invoked_indirectly
|
211
|
-
|
254
|
+
in_environment("PWD" => "test/data/namespace") do
|
212
255
|
rake "anon"
|
213
256
|
assert_match(/^ANON COPY$/m, @out)
|
214
257
|
end
|
215
258
|
end
|
216
259
|
|
217
260
|
def test_rake_namespace_refers_to_toplevel
|
218
|
-
|
261
|
+
in_environment("PWD" => "test/data/namespace") do
|
219
262
|
rake "very:nested:run"
|
220
263
|
assert_match(/^COPY$/m, @out)
|
221
264
|
end
|
222
265
|
end
|
223
266
|
|
224
267
|
def test_file_task_are_not_scoped_by_namespaces
|
225
|
-
|
268
|
+
in_environment("PWD" => "test/data/namespace") do
|
226
269
|
rake "xyz.rb"
|
227
270
|
assert_match(/^XYZ1\nXYZ2$/m, @out)
|
228
271
|
end
|
229
272
|
end
|
230
273
|
|
231
274
|
def test_rake_returns_status_error_values
|
232
|
-
|
275
|
+
in_environment("PWD" => "test/data/statusreturn") do
|
233
276
|
rake "exit5"
|
234
277
|
assert_status(5)
|
235
278
|
end
|
236
279
|
end
|
237
280
|
|
238
281
|
def test_rake_returns_no_status_error_on_normal_exit
|
239
|
-
|
282
|
+
in_environment("PWD" => "test/data/statusreturn") do
|
240
283
|
rake "normal"
|
241
284
|
assert_status(0)
|
242
285
|
end
|
data/test/test_application.rb
CHANGED
@@ -10,12 +10,14 @@ require 'test/unit'
|
|
10
10
|
require 'rake'
|
11
11
|
require 'test/rake_test_setup'
|
12
12
|
require 'test/capture_stdout'
|
13
|
+
require 'test/in_environment'
|
13
14
|
|
14
15
|
TESTING_REQUIRE = [ ]
|
15
16
|
|
16
17
|
######################################################################
|
17
18
|
class TestApplication < Test::Unit::TestCase
|
18
19
|
include CaptureStdout
|
20
|
+
include InEnvironment
|
19
21
|
|
20
22
|
def setup
|
21
23
|
@app = Rake::Application.new
|
@@ -141,7 +143,7 @@ class TestApplication < Test::Unit::TestCase
|
|
141
143
|
end
|
142
144
|
|
143
145
|
def test_load_rakefile_not_found
|
144
|
-
in_environment("PWD" => "/") do
|
146
|
+
in_environment("PWD" => "/", "RAKE_SYSTEM" => 'not_exist') do
|
145
147
|
@app.instance_eval do
|
146
148
|
handle_options
|
147
149
|
options.silent = true
|
@@ -265,30 +267,6 @@ class TestApplication < Test::Unit::TestCase
|
|
265
267
|
ensure
|
266
268
|
ARGV.clear
|
267
269
|
end
|
268
|
-
|
269
|
-
private
|
270
|
-
|
271
|
-
def set_env(settings)
|
272
|
-
result = {}
|
273
|
-
settings.each do |k, v|
|
274
|
-
result[k] = ENV[k]
|
275
|
-
if k == 'PWD'
|
276
|
-
Dir.chdir(v)
|
277
|
-
else
|
278
|
-
ENV[k] = v
|
279
|
-
end
|
280
|
-
end
|
281
|
-
result
|
282
|
-
end
|
283
|
-
|
284
|
-
def in_environment(settings)
|
285
|
-
original_dir = Dir.pwd
|
286
|
-
original_settings = set_env(settings)
|
287
|
-
yield
|
288
|
-
ensure
|
289
|
-
set_env(original_settings)
|
290
|
-
end
|
291
|
-
|
292
270
|
end
|
293
271
|
|
294
272
|
|
data/test/test_filelist.rb
CHANGED
data/test/test_tasks.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jimweirich-rake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.1.
|
4
|
+
version: 0.8.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Weirich
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-08-
|
12
|
+
date: 2008-08-30 21:00:00 -07:00
|
13
13
|
default_executable: rake
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- test/data/rbext/rakefile.rb
|
74
74
|
- test/filecreation.rb
|
75
75
|
- test/functional.rb
|
76
|
+
- test/in_environment.rb
|
76
77
|
- test/rake_test_setup.rb
|
77
78
|
- test/reqfile.rb
|
78
79
|
- test/reqfile2.rb
|