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.
- data/CHANGES +9 -8
- data/CHANGES-drake +4 -0
- data/Rakefile +14 -49
- data/Rakefile-drake +2 -1
- data/bin/drake +4 -3
- data/doc/release_notes/rake-0.9.1.rdoc +52 -0
- data/lib/rake/dsl_definition.rb +19 -0
- data/lib/rake/version.rb +1 -1
- data/test/data/access/Rakefile +3 -1
- data/test/data/default/Rakefile +0 -2
- data/test/data/file_creation_task/Rakefile +0 -2
- data/test/data/multidesc/Rakefile +0 -2
- data/test/data/namespace/Rakefile +0 -2
- data/test/data/statusreturn/Rakefile +0 -2
- data/test/file_creation.rb +0 -2
- data/test/helper.rb +63 -0
- data/test/in_environment.rb +4 -1
- data/test/{parallel_setup.rb → setup_parallel.rb} +0 -0
- data/test/{serial_setup.rb → setup_serial.rb} +0 -0
- data/test/{lib/parallel_test.rb → test_parallel.rb} +3 -1
- data/test/{lib/rake_test.rb → test_rake.rb} +2 -5
- data/test/test_rake_application.rb +365 -0
- data/test/test_rake_application_options.rb +383 -0
- data/test/test_rake_clean.rb +14 -0
- data/test/{lib/definitions_test.rb → test_rake_definitions.rb} +5 -10
- data/test/test_rake_directory_task.rb +55 -0
- data/test/test_rake_dsl.rb +53 -0
- data/test/{lib/earlytime_test.rb → test_rake_early_time.rb} +2 -5
- data/test/{lib/extension_test.rb → test_rake_extension.rb} +2 -6
- data/test/{lib/file_creation_task_test.rb → test_rake_file_creation_task.rb} +7 -7
- data/test/{lib/filelist_test.rb → test_rake_file_list.rb} +18 -22
- data/test/test_rake_file_list_path_map.rb +8 -0
- data/test/{lib/file_task_test.rb → test_rake_file_task.rb} +22 -61
- data/test/{lib/fileutils_test.rb → test_rake_file_utils.rb} +11 -15
- data/test/{lib/ftp_test.rb → test_rake_ftp_file.rb} +5 -5
- data/test/{functional/session_based_tests.rb → test_rake_functional.rb} +35 -24
- data/test/test_rake_invocation_chain.rb +52 -0
- data/test/{lib/makefile_loader_test.rb → test_rake_makefile_loader.rb} +2 -5
- data/test/{lib/multitask_test.rb → test_rake_multi_task.rb} +5 -7
- data/test/{lib/namespace_test.rb → test_rake_name_space.rb} +4 -16
- data/test/{lib/package_task_test.rb → test_rake_package_task.rb} +2 -6
- data/test/{lib/pathmap_test.rb → test_rake_path_map.rb} +4 -58
- data/test/test_rake_path_map_explode.rb +31 -0
- data/test/test_rake_path_map_partial.rb +18 -0
- data/test/{lib/pseudo_status_test.rb → test_rake_pseudo_status.rb} +2 -8
- data/test/{lib/rdoc_task_test.rb → test_rake_rdoc_task.rb} +4 -7
- data/test/{lib/require_test.rb → test_rake_require.rb} +3 -9
- data/test/{lib/rules_test.rb → test_rake_rules.rb} +11 -13
- data/test/{lib/task_test.rb → test_rake_task.rb} +16 -183
- data/test/test_rake_task_argument_parsing.rb +126 -0
- data/test/{lib/task_arguments_test.rb → test_rake_task_arguments.rb} +2 -5
- data/test/{lib/tasklib_test.rb → test_rake_task_lib.rb} +2 -5
- data/test/{lib/task_manager_test.rb → test_rake_task_manager.rb} +7 -45
- data/test/test_rake_task_manager_argument_resolution.rb +36 -0
- data/test/test_rake_task_with_arguments.rb +162 -0
- data/test/{lib/test_task_test.rb → test_rake_test_task.rb} +52 -7
- data/test/{lib/top_level_functions_test.rb → test_rake_top_level_functions.rb} +8 -20
- data/test/{lib/win32_test.rb → test_rake_win32.rb} +5 -12
- data/test/{contrib/test_sys.rb → test_sys.rb} +2 -6
- metadata +62 -47
- data/lib/rake/dsl.rb +0 -2
- data/test/capture_stdout.rb +0 -26
- data/test/functional/functional_test.rb +0 -25
- data/test/lib/application_test.rb +0 -871
- data/test/lib/clean_test.rb +0 -15
- data/test/lib/dsl_test.rb +0 -52
- data/test/lib/invocation_chain_test.rb +0 -81
- data/test/lib/testtask_test.rb +0 -49
- data/test/rake_test_setup.rb +0 -41
- data/test/ruby_version_test.rb +0 -3
- data/test/test_helper.rb +0 -19
@@ -1,23 +1,10 @@
|
|
1
|
-
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
2
|
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
rescue LoadError
|
6
|
-
# got no gems
|
7
|
-
end
|
8
|
-
|
9
|
-
require 'test/unit'
|
10
|
-
require 'flexmock/test_unit'
|
11
|
-
require 'test/capture_stdout'
|
12
|
-
require 'test/rake_test_setup'
|
13
|
-
require 'rake'
|
14
|
-
|
15
|
-
class TestTopLevelFunctions < Test::Unit::TestCase
|
16
|
-
include CaptureStdout
|
17
|
-
include TestMethods
|
3
|
+
class TestRakeTopLevelFunctions < Rake::TestCase
|
18
4
|
|
19
5
|
def setup
|
20
6
|
super
|
7
|
+
|
21
8
|
@app = Rake.application
|
22
9
|
Rake.application = flexmock("app")
|
23
10
|
Rake.application.should_receive(:deprecate).
|
@@ -26,6 +13,7 @@ class TestTopLevelFunctions < Test::Unit::TestCase
|
|
26
13
|
|
27
14
|
def teardown
|
28
15
|
Rake.application = @app
|
16
|
+
|
29
17
|
super
|
30
18
|
end
|
31
19
|
|
@@ -42,7 +30,7 @@ class TestTopLevelFunctions < Test::Unit::TestCase
|
|
42
30
|
end
|
43
31
|
|
44
32
|
def test_when_writing
|
45
|
-
out =
|
33
|
+
out, = capture_io do
|
46
34
|
when_writing("NOTWRITING") do
|
47
35
|
puts "WRITING"
|
48
36
|
end
|
@@ -52,12 +40,12 @@ class TestTopLevelFunctions < Test::Unit::TestCase
|
|
52
40
|
|
53
41
|
def test_when_not_writing
|
54
42
|
Rake::FileUtilsExt.nowrite_flag = true
|
55
|
-
|
43
|
+
_, err = capture_io do
|
56
44
|
when_writing("NOTWRITING") do
|
57
45
|
puts "WRITING"
|
58
46
|
end
|
59
47
|
end
|
60
|
-
assert_equal "DRYRUN: NOTWRITING\n",
|
48
|
+
assert_equal "DRYRUN: NOTWRITING\n", err
|
61
49
|
ensure
|
62
50
|
Rake::FileUtilsExt.nowrite_flag = false
|
63
51
|
end
|
@@ -83,6 +71,6 @@ class TestTopLevelFunctions < Test::Unit::TestCase
|
|
83
71
|
end
|
84
72
|
|
85
73
|
def test_missing_other_constant
|
86
|
-
|
74
|
+
assert_raises(NameError) do Object.const_missing(:Xyz) end
|
87
75
|
end
|
88
76
|
end
|
@@ -1,15 +1,7 @@
|
|
1
|
-
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
2
|
|
3
|
-
|
4
|
-
require 'test/rake_test_setup'
|
5
|
-
require 'test/in_environment'
|
6
|
-
|
7
|
-
require 'rake'
|
8
|
-
|
9
|
-
class TestWin32 < Test::Unit::TestCase
|
3
|
+
class TestRakeWin32 < Rake::TestCase
|
10
4
|
include InEnvironment
|
11
|
-
include TestMethods
|
12
|
-
include CaptureStdout
|
13
5
|
|
14
6
|
Win32 = Rake::Win32
|
15
7
|
|
@@ -64,7 +56,7 @@ class TestWin32 < Test::Unit::TestCase
|
|
64
56
|
'APPDATA' => nil,
|
65
57
|
"USERPROFILE" => nil
|
66
58
|
) do
|
67
|
-
|
59
|
+
assert_raises(Rake::Win32::Win32HomeError) do
|
68
60
|
Win32.win32_system_dir
|
69
61
|
end
|
70
62
|
end
|
@@ -80,10 +72,11 @@ class TestWin32 < Test::Unit::TestCase
|
|
80
72
|
ex.set_backtrace ['abc', 'rakefile']
|
81
73
|
|
82
74
|
rake = Rake::Application.new
|
75
|
+
rake.options.threads = Rake.application.options.threads
|
83
76
|
rake.options.trace = true
|
84
77
|
rake.instance_variable_set(:@rakefile, 'Rakefile')
|
85
78
|
|
86
|
-
err =
|
79
|
+
_, err = capture_io { rake.display_error_message(ex) }
|
87
80
|
|
88
81
|
assert_match(/rakefile/, err)
|
89
82
|
end
|
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'test/file_creation'
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
5
2
|
begin
|
6
3
|
old_verbose = $VERBOSE
|
7
4
|
$VERBOSE = nil
|
@@ -10,8 +7,7 @@ ensure
|
|
10
7
|
$VERBOSE = old_verbose
|
11
8
|
end
|
12
9
|
|
13
|
-
class TestSys <
|
14
|
-
include FileCreation
|
10
|
+
class TestSys < Rake::TestCase
|
15
11
|
|
16
12
|
def test_split_all
|
17
13
|
assert_equal ['a'], Sys.split_all('a')
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: drake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.9.
|
5
|
+
version: 0.9.1.0.3.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- James M. Lawrence
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-06-01 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: comp_tree
|
@@ -24,27 +24,38 @@ dependencies:
|
|
24
24
|
type: :runtime
|
25
25
|
version_requirements: *id001
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
|
-
name:
|
27
|
+
name: minitest
|
28
28
|
prerelease: false
|
29
29
|
requirement: &id002 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
32
|
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: "2.
|
34
|
+
version: "2.1"
|
35
35
|
type: :development
|
36
36
|
version_requirements: *id002
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
38
|
+
name: session
|
39
39
|
prerelease: false
|
40
40
|
requirement: &id003 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
45
|
+
version: "2.4"
|
46
46
|
type: :development
|
47
47
|
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: flexmock
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.8.11
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id004
|
48
59
|
description: " Drake is an auto-parallelizing branch of Rake, a Make-like program\n implemented in Ruby. Tasks and dependencies are specified in standard\n Ruby syntax.\n"
|
49
60
|
email: quixoticsycophant@gmail.com
|
50
61
|
executables:
|
@@ -81,6 +92,7 @@ extra_rdoc_files:
|
|
81
92
|
- doc/release_notes/rake-0.8.6.rdoc
|
82
93
|
- doc/release_notes/rake-0.8.7.rdoc
|
83
94
|
- doc/release_notes/rake-0.9.0.rdoc
|
95
|
+
- doc/release_notes/rake-0.9.1.rdoc
|
84
96
|
files:
|
85
97
|
- .gemtest
|
86
98
|
- install.rb
|
@@ -104,7 +116,6 @@ files:
|
|
104
116
|
- lib/rake/contrib/sshpublisher.rb
|
105
117
|
- lib/rake/contrib/sys.rb
|
106
118
|
- lib/rake/default_loader.rb
|
107
|
-
- lib/rake/dsl.rb
|
108
119
|
- lib/rake/dsl_definition.rb
|
109
120
|
- lib/rake/early_time.rb
|
110
121
|
- lib/rake/ext/core.rb
|
@@ -141,55 +152,58 @@ files:
|
|
141
152
|
- lib/rake/version.rb
|
142
153
|
- lib/rake/win32.rb
|
143
154
|
- lib/rake.rb
|
144
|
-
- test/capture_stdout.rb
|
145
155
|
- test/check_expansion.rb
|
146
156
|
- test/check_no_expansion.rb
|
147
|
-
- test/contrib/test_sys.rb
|
148
157
|
- test/data/rakelib/test1.rb
|
149
158
|
- test/data/rbext/rakefile.rb
|
150
159
|
- test/file_creation.rb
|
151
|
-
- test/
|
152
|
-
- test/functional/session_based_tests.rb
|
160
|
+
- test/helper.rb
|
153
161
|
- test/in_environment.rb
|
154
|
-
- test/lib/application_test.rb
|
155
|
-
- test/lib/clean_test.rb
|
156
|
-
- test/lib/definitions_test.rb
|
157
|
-
- test/lib/dsl_test.rb
|
158
|
-
- test/lib/earlytime_test.rb
|
159
|
-
- test/lib/extension_test.rb
|
160
|
-
- test/lib/file_creation_task_test.rb
|
161
|
-
- test/lib/file_task_test.rb
|
162
|
-
- test/lib/filelist_test.rb
|
163
|
-
- test/lib/fileutils_test.rb
|
164
|
-
- test/lib/ftp_test.rb
|
165
|
-
- test/lib/invocation_chain_test.rb
|
166
|
-
- test/lib/makefile_loader_test.rb
|
167
|
-
- test/lib/multitask_test.rb
|
168
|
-
- test/lib/namespace_test.rb
|
169
|
-
- test/lib/package_task_test.rb
|
170
|
-
- test/lib/parallel_test.rb
|
171
|
-
- test/lib/pathmap_test.rb
|
172
|
-
- test/lib/pseudo_status_test.rb
|
173
|
-
- test/lib/rake_test.rb
|
174
|
-
- test/lib/rdoc_task_test.rb
|
175
|
-
- test/lib/require_test.rb
|
176
|
-
- test/lib/rules_test.rb
|
177
|
-
- test/lib/task_arguments_test.rb
|
178
|
-
- test/lib/task_manager_test.rb
|
179
|
-
- test/lib/task_test.rb
|
180
|
-
- test/lib/tasklib_test.rb
|
181
|
-
- test/lib/test_task_test.rb
|
182
|
-
- test/lib/testtask_test.rb
|
183
|
-
- test/lib/top_level_functions_test.rb
|
184
|
-
- test/lib/win32_test.rb
|
185
|
-
- test/parallel_setup.rb
|
186
|
-
- test/rake_test_setup.rb
|
187
162
|
- test/reqfile.rb
|
188
163
|
- test/reqfile2.rb
|
189
|
-
- test/
|
190
|
-
- test/
|
164
|
+
- test/setup_parallel.rb
|
165
|
+
- test/setup_serial.rb
|
191
166
|
- test/shellcommand.rb
|
192
|
-
- test/
|
167
|
+
- test/test_parallel.rb
|
168
|
+
- test/test_rake.rb
|
169
|
+
- test/test_rake_application.rb
|
170
|
+
- test/test_rake_application_options.rb
|
171
|
+
- test/test_rake_clean.rb
|
172
|
+
- test/test_rake_definitions.rb
|
173
|
+
- test/test_rake_directory_task.rb
|
174
|
+
- test/test_rake_dsl.rb
|
175
|
+
- test/test_rake_early_time.rb
|
176
|
+
- test/test_rake_extension.rb
|
177
|
+
- test/test_rake_file_creation_task.rb
|
178
|
+
- test/test_rake_file_list.rb
|
179
|
+
- test/test_rake_file_list_path_map.rb
|
180
|
+
- test/test_rake_file_task.rb
|
181
|
+
- test/test_rake_file_utils.rb
|
182
|
+
- test/test_rake_ftp_file.rb
|
183
|
+
- test/test_rake_functional.rb
|
184
|
+
- test/test_rake_invocation_chain.rb
|
185
|
+
- test/test_rake_makefile_loader.rb
|
186
|
+
- test/test_rake_multi_task.rb
|
187
|
+
- test/test_rake_name_space.rb
|
188
|
+
- test/test_rake_package_task.rb
|
189
|
+
- test/test_rake_path_map.rb
|
190
|
+
- test/test_rake_path_map_explode.rb
|
191
|
+
- test/test_rake_path_map_partial.rb
|
192
|
+
- test/test_rake_pseudo_status.rb
|
193
|
+
- test/test_rake_rdoc_task.rb
|
194
|
+
- test/test_rake_require.rb
|
195
|
+
- test/test_rake_rules.rb
|
196
|
+
- test/test_rake_task.rb
|
197
|
+
- test/test_rake_task_argument_parsing.rb
|
198
|
+
- test/test_rake_task_arguments.rb
|
199
|
+
- test/test_rake_task_lib.rb
|
200
|
+
- test/test_rake_task_manager.rb
|
201
|
+
- test/test_rake_task_manager_argument_resolution.rb
|
202
|
+
- test/test_rake_task_with_arguments.rb
|
203
|
+
- test/test_rake_test_task.rb
|
204
|
+
- test/test_rake_top_level_functions.rb
|
205
|
+
- test/test_rake_win32.rb
|
206
|
+
- test/test_sys.rb
|
193
207
|
- test/data/imports/deps.mf
|
194
208
|
- test/data/sample.mf
|
195
209
|
- test/data/access/Rakefile
|
@@ -236,6 +250,7 @@ files:
|
|
236
250
|
- doc/release_notes/rake-0.8.6.rdoc
|
237
251
|
- doc/release_notes/rake-0.8.7.rdoc
|
238
252
|
- doc/release_notes/rake-0.9.0.rdoc
|
253
|
+
- doc/release_notes/rake-0.9.1.rdoc
|
239
254
|
homepage: http://quix.github.com/rake
|
240
255
|
licenses: []
|
241
256
|
|
data/lib/rake/dsl.rb
DELETED
data/test/capture_stdout.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'stringio'
|
4
|
-
|
5
|
-
# Mix-in for capturing standard output.
|
6
|
-
module CaptureStdout
|
7
|
-
def capture_stdout
|
8
|
-
s = StringIO.new
|
9
|
-
oldstdout = $stdout
|
10
|
-
$stdout = s
|
11
|
-
yield
|
12
|
-
s.string
|
13
|
-
ensure
|
14
|
-
$stdout = oldstdout
|
15
|
-
end
|
16
|
-
|
17
|
-
def capture_stderr
|
18
|
-
s = StringIO.new
|
19
|
-
oldstderr = $stderr
|
20
|
-
$stderr = s
|
21
|
-
yield
|
22
|
-
s.string
|
23
|
-
ensure
|
24
|
-
$stderr = oldstderr
|
25
|
-
end
|
26
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
begin
|
4
|
-
old_verbose = $VERBOSE
|
5
|
-
require 'rubygems'
|
6
|
-
$VERBOSE = nil
|
7
|
-
gem 'session'
|
8
|
-
require 'session'
|
9
|
-
rescue LoadError
|
10
|
-
if File::ALT_SEPARATOR
|
11
|
-
puts "Unable to run functional tests on MS Windows. Skipping."
|
12
|
-
else
|
13
|
-
puts "Unable to run functional tests -- please run \"gem install session\""
|
14
|
-
end
|
15
|
-
ensure
|
16
|
-
$VERBOSE = old_verbose
|
17
|
-
end
|
18
|
-
|
19
|
-
if defined?(Session)
|
20
|
-
if File::ALT_SEPARATOR
|
21
|
-
puts "Unable to run functional tests on MS Windows. Skipping."
|
22
|
-
else
|
23
|
-
require 'test/functional/session_based_tests.rb'
|
24
|
-
end
|
25
|
-
end
|
@@ -1,871 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'rubygems'
|
5
|
-
rescue LoadError
|
6
|
-
# got no gems
|
7
|
-
end
|
8
|
-
|
9
|
-
require 'test/unit'
|
10
|
-
require 'rake'
|
11
|
-
require 'test/rake_test_setup'
|
12
|
-
require 'test/capture_stdout'
|
13
|
-
require 'test/in_environment'
|
14
|
-
|
15
|
-
TESTING_REQUIRE = [ ]
|
16
|
-
|
17
|
-
######################################################################
|
18
|
-
class TestApplication < Test::Unit::TestCase
|
19
|
-
include CaptureStdout
|
20
|
-
include InEnvironment
|
21
|
-
include TestMethods
|
22
|
-
|
23
|
-
def setup
|
24
|
-
super
|
25
|
-
@app = Rake::Application.new
|
26
|
-
@app.options.threads = Rake.application.options.threads
|
27
|
-
@app.options.rakelib = []
|
28
|
-
Rake::TaskManager.record_task_metadata = true
|
29
|
-
end
|
30
|
-
|
31
|
-
def teardown
|
32
|
-
Rake::TaskManager.record_task_metadata = false
|
33
|
-
super
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_constant_warning
|
37
|
-
error_messages = capture_stderr do @app.instance_eval { const_warning("Task") } end
|
38
|
-
assert_match(/warning/i, error_messages)
|
39
|
-
assert_match(/deprecated/i, error_messages)
|
40
|
-
assert_match(/Task/i, error_messages)
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_display_tasks
|
44
|
-
@app.options.show_tasks = :tasks
|
45
|
-
@app.options.show_task_pattern = //
|
46
|
-
@app.last_description = "COMMENT"
|
47
|
-
@app.define_task(Rake::Task, "t")
|
48
|
-
out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
|
49
|
-
assert_match(/^rake t/, out)
|
50
|
-
assert_match(/# COMMENT/, out)
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_display_tasks_with_long_comments
|
54
|
-
in_environment('RAKE_COLUMNS' => '80') do
|
55
|
-
@app.options.show_tasks = :tasks
|
56
|
-
@app.options.show_task_pattern = //
|
57
|
-
@app.last_description = "1234567890" * 8
|
58
|
-
@app.define_task(Rake::Task, "t")
|
59
|
-
out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
|
60
|
-
assert_match(/^rake t/, out)
|
61
|
-
assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_display_tasks_with_task_name_wider_than_tty_display
|
66
|
-
in_environment('RAKE_COLUMNS' => '80') do
|
67
|
-
@app.options.show_tasks = :tasks
|
68
|
-
@app.options.show_task_pattern = //
|
69
|
-
task_name = "task name" * 80
|
70
|
-
@app.last_description = "something short"
|
71
|
-
@app.define_task(Rake::Task, task_name )
|
72
|
-
out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
|
73
|
-
# Ensure the entire task name is output and we end up showing no description
|
74
|
-
assert_match(/rake #{task_name} # .../, out)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comment
|
79
|
-
@app.options.show_tasks = :tasks
|
80
|
-
@app.options.show_task_pattern = //
|
81
|
-
@app.tty_output = false
|
82
|
-
description = "something short"
|
83
|
-
task_name = "task name" * 80
|
84
|
-
@app.last_description = "something short"
|
85
|
-
@app.define_task(Rake::Task, task_name )
|
86
|
-
out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
|
87
|
-
# Ensure the entire task name is output and we end up showing no description
|
88
|
-
assert_match(/rake #{task_name} # #{description}/, out)
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_display_tasks_with_long_comments_to_a_non_tty_shows_entire_comment
|
92
|
-
@app.options.show_tasks = :tasks
|
93
|
-
@app.options.show_task_pattern = //
|
94
|
-
@app.tty_output = false
|
95
|
-
@app.last_description = "1234567890" * 8
|
96
|
-
@app.define_task(Rake::Task, "t")
|
97
|
-
out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
|
98
|
-
assert_match(/^rake t/, out)
|
99
|
-
assert_match(/# #{@app.last_description}/, out)
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_display_tasks_with_long_comments_to_a_non_tty_with_columns_set_truncates_comments
|
103
|
-
in_environment("RAKE_COLUMNS" => '80') do
|
104
|
-
@app.options.show_tasks = :tasks
|
105
|
-
@app.options.show_task_pattern = //
|
106
|
-
@app.tty_output = false
|
107
|
-
@app.last_description = "1234567890" * 8
|
108
|
-
@app.define_task(Rake::Task, "t")
|
109
|
-
out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
|
110
|
-
assert_match(/^rake t/, out)
|
111
|
-
assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_describe_tasks
|
116
|
-
@app.options.show_tasks = :describe
|
117
|
-
@app.options.show_task_pattern = //
|
118
|
-
@app.last_description = "COMMENT"
|
119
|
-
@app.define_task(Rake::Task, "t")
|
120
|
-
out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
|
121
|
-
assert_match(/^rake t$/, out)
|
122
|
-
assert_match(/^ {4}COMMENT$/, out)
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_show_lines
|
126
|
-
@app.options.show_tasks = :lines
|
127
|
-
@app.options.show_task_pattern = //
|
128
|
-
@app.last_description = "COMMENT"
|
129
|
-
@app.define_task(Rake::Task, "t")
|
130
|
-
@app['t'].locations << "HERE:1"
|
131
|
-
out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end
|
132
|
-
assert_match(/^rake t +[^:]+:\d+ *$/, out)
|
133
|
-
end
|
134
|
-
|
135
|
-
def test_finding_rakefile
|
136
|
-
assert_match(/Rakefile/i, @app.instance_eval { have_rakefile })
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_not_finding_rakefile
|
140
|
-
@app.instance_eval { @rakefiles = ['NEVER_FOUND'] }
|
141
|
-
assert( ! @app.instance_eval do have_rakefile end )
|
142
|
-
assert_nil @app.rakefile
|
143
|
-
end
|
144
|
-
|
145
|
-
def test_load_rakefile
|
146
|
-
in_environment("PWD" => "test/data/unittest") do
|
147
|
-
@app.instance_eval do
|
148
|
-
handle_options
|
149
|
-
options.silent = true
|
150
|
-
load_rakefile
|
151
|
-
end
|
152
|
-
assert_equal "rakefile", @app.rakefile.downcase
|
153
|
-
assert_match(%r(unittest$), Dir.pwd)
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def test_load_rakefile_doesnt_print_rakefile_directory_from_same_dir
|
158
|
-
in_environment("PWD" => "test/data/unittest") do
|
159
|
-
error_messages = capture_stderr do
|
160
|
-
@app.instance_eval do
|
161
|
-
@original_dir = File.expand_path(".") # pretend we started from the unittest dir
|
162
|
-
raw_load_rakefile
|
163
|
-
end
|
164
|
-
end
|
165
|
-
_, location = @app.find_rakefile_location
|
166
|
-
assert_no_match(/\(in #{location}\)/, error_messages)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
def test_load_rakefile_from_subdir
|
171
|
-
in_environment("PWD" => "test/data/unittest/subdir") do
|
172
|
-
@app.instance_eval do
|
173
|
-
handle_options
|
174
|
-
options.silent = true
|
175
|
-
load_rakefile
|
176
|
-
end
|
177
|
-
assert_equal "rakefile", @app.rakefile.downcase
|
178
|
-
assert_match(%r(unittest$), Dir.pwd)
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
def test_load_rakefile_prints_rakefile_directory_from_subdir
|
183
|
-
in_environment("PWD" => "test/data/unittest/subdir") do
|
184
|
-
error_messages = capture_stderr do
|
185
|
-
@app.instance_eval do
|
186
|
-
raw_load_rakefile
|
187
|
-
end
|
188
|
-
end
|
189
|
-
_, location = @app.find_rakefile_location
|
190
|
-
assert_match(/\(in #{location}\)/, error_messages)
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
def test_load_rakefile_doesnt_print_rakefile_directory_from_subdir_if_silent
|
195
|
-
in_environment("PWD" => "test/data/unittest/subdir") do
|
196
|
-
error_messages = capture_stderr do
|
197
|
-
@app.instance_eval do
|
198
|
-
handle_options
|
199
|
-
options.silent = true
|
200
|
-
raw_load_rakefile
|
201
|
-
end
|
202
|
-
end
|
203
|
-
_, location = @app.find_rakefile_location
|
204
|
-
assert_no_match(/\(in #{location}\)/, error_messages)
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
def test_load_rakefile_not_found
|
209
|
-
in_environment("PWD" => "/", "RAKE_SYSTEM" => 'not_exist') do
|
210
|
-
@app.instance_eval do
|
211
|
-
handle_options
|
212
|
-
options.silent = true
|
213
|
-
end
|
214
|
-
ex = assert_exception(RuntimeError) do
|
215
|
-
@app.instance_eval do raw_load_rakefile end
|
216
|
-
end
|
217
|
-
assert_match(/no rakefile found/i, ex.message)
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
def test_load_from_system_rakefile
|
222
|
-
in_environment('RAKE_SYSTEM' => 'test/data/sys') do
|
223
|
-
@app.options.rakelib = []
|
224
|
-
@app.instance_eval do
|
225
|
-
handle_options
|
226
|
-
options.silent = true
|
227
|
-
options.load_system = true
|
228
|
-
options.rakelib = []
|
229
|
-
load_rakefile
|
230
|
-
end
|
231
|
-
assert_equal "test/data/sys", @app.system_dir
|
232
|
-
assert_nil @app.rakefile
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
def test_load_from_calculated_system_rakefile
|
237
|
-
flexmock(@app, :standard_system_dir => "__STD_SYS_DIR__")
|
238
|
-
in_environment('RAKE_SYSTEM' => nil) do
|
239
|
-
@app.options.rakelib = []
|
240
|
-
@app.instance_eval do
|
241
|
-
handle_options
|
242
|
-
options.silent = true
|
243
|
-
options.load_system = true
|
244
|
-
options.rakelib = []
|
245
|
-
load_rakefile
|
246
|
-
end
|
247
|
-
assert_equal "__STD_SYS_DIR__", @app.system_dir
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
|
-
def test_windows
|
252
|
-
assert ! (@app.windows? && @app.unix?)
|
253
|
-
end
|
254
|
-
|
255
|
-
def test_loading_imports
|
256
|
-
mock = flexmock("loader")
|
257
|
-
mock.should_receive(:load).with("x.dummy").once
|
258
|
-
@app.instance_eval do
|
259
|
-
add_loader("dummy", mock)
|
260
|
-
add_import("x.dummy")
|
261
|
-
load_imports
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
def test_building_imported_files_on_demand
|
266
|
-
mock = flexmock("loader")
|
267
|
-
mock.should_receive(:load).with("x.dummy").once
|
268
|
-
mock.should_receive(:make_dummy).with_no_args.once
|
269
|
-
@app.instance_eval do
|
270
|
-
intern(Rake::Task, "x.dummy").enhance do mock.make_dummy end
|
271
|
-
add_loader("dummy", mock)
|
272
|
-
add_import("x.dummy")
|
273
|
-
load_imports
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
|
-
def test_handle_options_should_strip_options_from_ARGV
|
278
|
-
assert !@app.options.trace
|
279
|
-
|
280
|
-
valid_option = '--trace'
|
281
|
-
ARGV.clear
|
282
|
-
ARGV << valid_option
|
283
|
-
|
284
|
-
@app.handle_options
|
285
|
-
|
286
|
-
assert !ARGV.include?(valid_option)
|
287
|
-
assert @app.options.trace
|
288
|
-
end
|
289
|
-
|
290
|
-
def test_good_run
|
291
|
-
ran = false
|
292
|
-
ARGV.clear
|
293
|
-
ARGV << '--rakelib=""'
|
294
|
-
@app.options.silent = true
|
295
|
-
@app.instance_eval do
|
296
|
-
intern(Rake::Task, "default").enhance { ran = true }
|
297
|
-
end
|
298
|
-
in_environment("PWD" => "test/data/default") do
|
299
|
-
@app.run
|
300
|
-
end
|
301
|
-
assert ran
|
302
|
-
end
|
303
|
-
|
304
|
-
def test_display_task_run
|
305
|
-
ran = false
|
306
|
-
ARGV.clear
|
307
|
-
ARGV << '-f' << '-s' << '--tasks' << '--rakelib=""'
|
308
|
-
@app.last_description = "COMMENT"
|
309
|
-
@app.define_task(Rake::Task, "default")
|
310
|
-
out = capture_stdout { @app.run }
|
311
|
-
assert @app.options.show_tasks
|
312
|
-
assert ! ran
|
313
|
-
assert_match(/rake default/, out)
|
314
|
-
assert_match(/# COMMENT/, out)
|
315
|
-
end
|
316
|
-
|
317
|
-
def test_display_prereqs
|
318
|
-
ran = false
|
319
|
-
ARGV.clear
|
320
|
-
ARGV << '-f' << '-s' << '--prereqs' << '--rakelib=""'
|
321
|
-
@app.last_description = "COMMENT"
|
322
|
-
t = @app.define_task(Rake::Task, "default")
|
323
|
-
t.enhance([:a, :b])
|
324
|
-
@app.define_task(Rake::Task, "a")
|
325
|
-
@app.define_task(Rake::Task, "b")
|
326
|
-
out = capture_stdout { @app.run }
|
327
|
-
assert @app.options.show_prereqs
|
328
|
-
assert ! ran
|
329
|
-
assert_match(/rake a$/, out)
|
330
|
-
assert_match(/rake b$/, out)
|
331
|
-
assert_match(/rake default\n( *(a|b)\n){2}/m, out)
|
332
|
-
end
|
333
|
-
|
334
|
-
def test_bad_run
|
335
|
-
@app.intern(Rake::Task, "default").enhance { fail }
|
336
|
-
ARGV.clear
|
337
|
-
ARGV << '-f' << '-s' << '--rakelib=""'
|
338
|
-
assert_exception(SystemExit) {
|
339
|
-
error_messages = capture_stderr { @app.run }
|
340
|
-
assert_match(/see full trace/, error_messages)
|
341
|
-
}
|
342
|
-
ensure
|
343
|
-
ARGV.clear
|
344
|
-
end
|
345
|
-
|
346
|
-
def test_bad_run_with_trace
|
347
|
-
@app.intern(Rake::Task, "default").enhance { fail }
|
348
|
-
ARGV.clear
|
349
|
-
ARGV << '-f' << '-s' << '-t'
|
350
|
-
assert_exception(SystemExit) {
|
351
|
-
error_messages = capture_stderr { capture_stdout { @app.run } }
|
352
|
-
assert_no_match(/see full trace/, error_messages)
|
353
|
-
}
|
354
|
-
ensure
|
355
|
-
ARGV.clear
|
356
|
-
end
|
357
|
-
|
358
|
-
def test_run_with_bad_options
|
359
|
-
@app.intern(Rake::Task, "default").enhance { fail }
|
360
|
-
ARGV.clear
|
361
|
-
ARGV << '-f' << '-s' << '--xyzzy'
|
362
|
-
assert_exception(SystemExit) {
|
363
|
-
capture_stderr { capture_stdout { @app.run } }
|
364
|
-
}
|
365
|
-
ensure
|
366
|
-
ARGV.clear
|
367
|
-
end
|
368
|
-
|
369
|
-
def test_deprecation_message
|
370
|
-
in_environment do
|
371
|
-
error_messages = capture_stderr do
|
372
|
-
@app.deprecate("a", "b", "c")
|
373
|
-
end
|
374
|
-
assert_match(/'a' is deprecated/i, error_messages)
|
375
|
-
assert_match(/use 'b' instead/i, error_messages)
|
376
|
-
assert_match(/at c$/i, error_messages)
|
377
|
-
end
|
378
|
-
end
|
379
|
-
end
|
380
|
-
|
381
|
-
|
382
|
-
######################################################################
|
383
|
-
class TestApplicationOptions < Test::Unit::TestCase
|
384
|
-
include CaptureStdout
|
385
|
-
include TestMethods
|
386
|
-
include InEnvironment
|
387
|
-
|
388
|
-
def setup
|
389
|
-
clear_argv
|
390
|
-
Rake::FileUtilsExt.verbose_flag = false
|
391
|
-
Rake::FileUtilsExt.nowrite_flag = false
|
392
|
-
TESTING_REQUIRE.clear
|
393
|
-
end
|
394
|
-
|
395
|
-
def teardown
|
396
|
-
clear_argv
|
397
|
-
Rake::FileUtilsExt.verbose_flag = false
|
398
|
-
Rake::FileUtilsExt.nowrite_flag = false
|
399
|
-
end
|
400
|
-
|
401
|
-
def clear_argv
|
402
|
-
while ! ARGV.empty?
|
403
|
-
ARGV.pop
|
404
|
-
end
|
405
|
-
end
|
406
|
-
|
407
|
-
def test_default_options
|
408
|
-
in_environment("RAKEOPT" => nil) do
|
409
|
-
opts = command_line
|
410
|
-
assert_nil opts.classic_namespace
|
411
|
-
assert_nil opts.dryrun
|
412
|
-
assert_nil opts.ignore_system
|
413
|
-
assert_nil opts.load_system
|
414
|
-
assert_nil opts.nosearch
|
415
|
-
assert_equal ['rakelib'], opts.rakelib
|
416
|
-
assert_nil opts.show_prereqs
|
417
|
-
assert_nil opts.show_task_pattern
|
418
|
-
assert_nil opts.show_tasks
|
419
|
-
assert_nil opts.silent
|
420
|
-
assert_nil opts.trace
|
421
|
-
assert_equal ['rakelib'], opts.rakelib
|
422
|
-
assert ! Rake::FileUtilsExt.verbose_flag
|
423
|
-
assert ! Rake::FileUtilsExt.nowrite_flag
|
424
|
-
end
|
425
|
-
end
|
426
|
-
|
427
|
-
def test_dry_run
|
428
|
-
in_environment do
|
429
|
-
flags('--dry-run', '-n') do |opts|
|
430
|
-
assert opts.dryrun
|
431
|
-
assert opts.trace
|
432
|
-
assert Rake::FileUtilsExt.verbose_flag
|
433
|
-
assert Rake::FileUtilsExt.nowrite_flag
|
434
|
-
end
|
435
|
-
end
|
436
|
-
end
|
437
|
-
|
438
|
-
def test_describe
|
439
|
-
in_environment do
|
440
|
-
flags('--describe') do |opts|
|
441
|
-
assert_equal :describe, opts.show_tasks
|
442
|
-
assert_equal(//.to_s, opts.show_task_pattern.to_s)
|
443
|
-
end
|
444
|
-
end
|
445
|
-
end
|
446
|
-
|
447
|
-
def test_describe_with_pattern
|
448
|
-
in_environment do
|
449
|
-
flags('--describe=X') do |opts|
|
450
|
-
assert_equal :describe, opts.show_tasks
|
451
|
-
assert_equal(/X/.to_s, opts.show_task_pattern.to_s)
|
452
|
-
end
|
453
|
-
end
|
454
|
-
end
|
455
|
-
|
456
|
-
def test_execute
|
457
|
-
in_environment do
|
458
|
-
$xyzzy = 0
|
459
|
-
flags('--execute=$xyzzy=1', '-e $xyzzy=1') do |opts|
|
460
|
-
assert_equal 1, $xyzzy
|
461
|
-
assert_equal :exit, @exit
|
462
|
-
$xyzzy = 0
|
463
|
-
end
|
464
|
-
end
|
465
|
-
end
|
466
|
-
|
467
|
-
def test_execute_and_continue
|
468
|
-
in_environment do
|
469
|
-
$xyzzy = 0
|
470
|
-
flags('--execute-continue=$xyzzy=1', '-E $xyzzy=1') do |opts|
|
471
|
-
assert_equal 1, $xyzzy
|
472
|
-
assert_not_equal :exit, @exit
|
473
|
-
$xyzzy = 0
|
474
|
-
end
|
475
|
-
end
|
476
|
-
end
|
477
|
-
|
478
|
-
def test_execute_and_print
|
479
|
-
in_environment do
|
480
|
-
$xyzzy = 0
|
481
|
-
flags('--execute-print=$xyzzy="pugh"', '-p $xyzzy="pugh"') do |opts|
|
482
|
-
assert_equal 'pugh', $xyzzy
|
483
|
-
assert_equal :exit, @exit
|
484
|
-
assert_match(/^pugh$/, @out)
|
485
|
-
$xyzzy = 0
|
486
|
-
end
|
487
|
-
end
|
488
|
-
end
|
489
|
-
|
490
|
-
def test_help
|
491
|
-
in_environment do
|
492
|
-
flags('--help', '-H', '-h') do |opts|
|
493
|
-
assert_match(/\Adrake/, @out)
|
494
|
-
assert_match(/\boptions\b/, @out)
|
495
|
-
assert_match(/\btargets\b/, @out)
|
496
|
-
assert_equal :exit, @exit
|
497
|
-
assert_equal :exit, @exit
|
498
|
-
end
|
499
|
-
end
|
500
|
-
end
|
501
|
-
|
502
|
-
def test_libdir
|
503
|
-
in_environment do
|
504
|
-
flags(['--libdir', 'xx'], ['-I', 'xx'], ['-Ixx']) do |opts|
|
505
|
-
$:.include?('xx')
|
506
|
-
end
|
507
|
-
end
|
508
|
-
ensure
|
509
|
-
$:.delete('xx')
|
510
|
-
end
|
511
|
-
|
512
|
-
def test_rakefile
|
513
|
-
in_environment do
|
514
|
-
flags(['--rakefile', 'RF'], ['--rakefile=RF'], ['-f', 'RF'], ['-fRF']) do |opts|
|
515
|
-
assert_equal ['RF'], @app.instance_eval { @rakefiles }
|
516
|
-
end
|
517
|
-
end
|
518
|
-
end
|
519
|
-
|
520
|
-
def test_rakelib
|
521
|
-
in_environment do
|
522
|
-
flags(['--rakelibdir', 'A:B:C'], ['--rakelibdir=A:B:C'], ['-R', 'A:B:C'], ['-RA:B:C']) do |opts|
|
523
|
-
assert_equal ['A', 'B', 'C'], opts.rakelib
|
524
|
-
end
|
525
|
-
end
|
526
|
-
end
|
527
|
-
|
528
|
-
def test_require
|
529
|
-
in_environment do
|
530
|
-
flags(['--require', 'test/reqfile'], '-rtest/reqfile2', '-rtest/reqfile3') do |opts|
|
531
|
-
end
|
532
|
-
assert TESTING_REQUIRE.include?(1)
|
533
|
-
assert TESTING_REQUIRE.include?(2)
|
534
|
-
assert TESTING_REQUIRE.include?(3)
|
535
|
-
assert_equal 3, TESTING_REQUIRE.size
|
536
|
-
end
|
537
|
-
end
|
538
|
-
|
539
|
-
def test_missing_require
|
540
|
-
in_environment do
|
541
|
-
ex = assert_exception(LoadError) do
|
542
|
-
flags(['--require', 'test/missing']) do |opts|
|
543
|
-
end
|
544
|
-
end
|
545
|
-
assert_match(/such file/, ex.message)
|
546
|
-
assert_match(/test\/missing/, ex.message)
|
547
|
-
end
|
548
|
-
end
|
549
|
-
|
550
|
-
def test_prereqs
|
551
|
-
in_environment do
|
552
|
-
flags('--prereqs', '-P') do |opts|
|
553
|
-
assert opts.show_prereqs
|
554
|
-
end
|
555
|
-
end
|
556
|
-
end
|
557
|
-
|
558
|
-
def test_quiet
|
559
|
-
in_environment do
|
560
|
-
flags('--quiet', '-q') do |opts|
|
561
|
-
assert ! Rake::FileUtilsExt.verbose_flag
|
562
|
-
assert ! opts.silent
|
563
|
-
end
|
564
|
-
end
|
565
|
-
end
|
566
|
-
|
567
|
-
def test_no_search
|
568
|
-
in_environment do
|
569
|
-
flags('--nosearch', '--no-search', '-N') do |opts|
|
570
|
-
assert opts.nosearch
|
571
|
-
end
|
572
|
-
end
|
573
|
-
end
|
574
|
-
|
575
|
-
def test_silent
|
576
|
-
in_environment do
|
577
|
-
flags('--silent', '-s') do |opts|
|
578
|
-
assert ! Rake::FileUtilsExt.verbose_flag
|
579
|
-
assert opts.silent
|
580
|
-
end
|
581
|
-
end
|
582
|
-
end
|
583
|
-
|
584
|
-
def test_system
|
585
|
-
in_environment do
|
586
|
-
flags('--system', '-g') do |opts|
|
587
|
-
assert opts.load_system
|
588
|
-
end
|
589
|
-
end
|
590
|
-
end
|
591
|
-
|
592
|
-
def test_no_system
|
593
|
-
in_environment do
|
594
|
-
flags('--no-system', '-G') do |opts|
|
595
|
-
assert opts.ignore_system
|
596
|
-
end
|
597
|
-
end
|
598
|
-
end
|
599
|
-
|
600
|
-
def test_trace
|
601
|
-
in_environment do
|
602
|
-
flags('--trace', '-t') do |opts|
|
603
|
-
assert opts.trace
|
604
|
-
assert Rake::FileUtilsExt.verbose_flag
|
605
|
-
assert ! Rake::FileUtilsExt.nowrite_flag
|
606
|
-
end
|
607
|
-
end
|
608
|
-
end
|
609
|
-
|
610
|
-
def test_trace_rules
|
611
|
-
in_environment do
|
612
|
-
flags('--rules') do |opts|
|
613
|
-
assert opts.trace_rules
|
614
|
-
end
|
615
|
-
end
|
616
|
-
end
|
617
|
-
|
618
|
-
def test_tasks
|
619
|
-
in_environment do
|
620
|
-
flags('--tasks', '-T') do |opts|
|
621
|
-
assert_equal :tasks, opts.show_tasks
|
622
|
-
assert_equal(//.to_s, opts.show_task_pattern.to_s)
|
623
|
-
end
|
624
|
-
flags(['--tasks', 'xyz'], ['-Txyz']) do |opts|
|
625
|
-
assert_equal :tasks, opts.show_tasks
|
626
|
-
assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s)
|
627
|
-
end
|
628
|
-
end
|
629
|
-
end
|
630
|
-
|
631
|
-
def test_where
|
632
|
-
in_environment do
|
633
|
-
flags('--where', '-W') do |opts|
|
634
|
-
assert_equal :lines, opts.show_tasks
|
635
|
-
assert_equal(//.to_s, opts.show_task_pattern.to_s)
|
636
|
-
end
|
637
|
-
flags(['--where', 'xyz'], ['-Wxyz']) do |opts|
|
638
|
-
assert_equal :lines, opts.show_tasks
|
639
|
-
assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s)
|
640
|
-
end
|
641
|
-
end
|
642
|
-
end
|
643
|
-
|
644
|
-
def test_no_deprecated_messages
|
645
|
-
in_environment do
|
646
|
-
flags('--no-deprecation-warnings', '-X') do |opts|
|
647
|
-
assert opts.ignore_deprecate
|
648
|
-
end
|
649
|
-
end
|
650
|
-
end
|
651
|
-
|
652
|
-
def test_verbose
|
653
|
-
in_environment do
|
654
|
-
flags('--verbose', '-V') do |opts|
|
655
|
-
assert Rake::FileUtilsExt.verbose_flag
|
656
|
-
assert ! opts.silent
|
657
|
-
end
|
658
|
-
end
|
659
|
-
end
|
660
|
-
|
661
|
-
def test_version
|
662
|
-
in_environment do
|
663
|
-
flags('--version', '-V') do |opts|
|
664
|
-
assert_match(/\bversion\b/, @out)
|
665
|
-
assert_match(/\b#{RAKEVERSION}\b/, @out)
|
666
|
-
assert_equal :exit, @exit
|
667
|
-
end
|
668
|
-
end
|
669
|
-
end
|
670
|
-
|
671
|
-
def test_classic_namespace
|
672
|
-
in_environment do
|
673
|
-
error_messages = capture_stderr do
|
674
|
-
flags(['--classic-namespace'], ['-C', '-T', '-P', '-n', '-s', '-t']) do |opts|
|
675
|
-
assert opts.classic_namespace
|
676
|
-
assert_equal opts.show_tasks, $show_tasks
|
677
|
-
assert_equal opts.show_prereqs, $show_prereqs
|
678
|
-
assert_equal opts.trace, $trace
|
679
|
-
assert_equal opts.dryrun, $dryrun
|
680
|
-
assert_equal opts.silent, $silent
|
681
|
-
end
|
682
|
-
end
|
683
|
-
assert_match(/deprecated/, error_messages)
|
684
|
-
end
|
685
|
-
end
|
686
|
-
|
687
|
-
def test_bad_option
|
688
|
-
in_environment do
|
689
|
-
error_messages = capture_stderr do
|
690
|
-
ex = assert_exception(OptionParser::InvalidOption) do
|
691
|
-
flags('--bad-option')
|
692
|
-
end
|
693
|
-
if ex.message =~ /^While/ # Ruby 1.9 error message
|
694
|
-
assert_match(/while parsing/i, ex.message)
|
695
|
-
else # Ruby 1.8 error message
|
696
|
-
assert_match(/(invalid|unrecognized) option/i, ex.message)
|
697
|
-
assert_match(/--bad-option/, ex.message)
|
698
|
-
end
|
699
|
-
end
|
700
|
-
assert_equal '', error_messages
|
701
|
-
end
|
702
|
-
end
|
703
|
-
|
704
|
-
def test_task_collection
|
705
|
-
command_line("a", "b")
|
706
|
-
assert_equal ["a", "b"], @tasks.sort
|
707
|
-
end
|
708
|
-
|
709
|
-
def test_default_task_collection
|
710
|
-
command_line()
|
711
|
-
assert_equal ["default"], @tasks
|
712
|
-
end
|
713
|
-
|
714
|
-
def test_environment_definition
|
715
|
-
ENV.delete('TESTKEY')
|
716
|
-
command_line("a", "TESTKEY=12")
|
717
|
-
assert_equal ["a"], @tasks.sort
|
718
|
-
assert '12', ENV['TESTKEY']
|
719
|
-
end
|
720
|
-
|
721
|
-
private
|
722
|
-
|
723
|
-
def flags(*sets)
|
724
|
-
sets.each do |set|
|
725
|
-
ARGV.clear
|
726
|
-
@out = capture_stdout {
|
727
|
-
@exit = catch(:system_exit) { command_line(*set) }
|
728
|
-
}
|
729
|
-
yield(@app.options) if block_given?
|
730
|
-
end
|
731
|
-
end
|
732
|
-
|
733
|
-
def command_line(*options)
|
734
|
-
options.each do |opt| ARGV << opt end
|
735
|
-
@app = Rake::Application.new
|
736
|
-
@app.options.threads = Rake.application.options.threads
|
737
|
-
def @app.exit(*args)
|
738
|
-
throw :system_exit, :exit
|
739
|
-
end
|
740
|
-
@app.instance_eval do
|
741
|
-
handle_options
|
742
|
-
collect_tasks
|
743
|
-
end
|
744
|
-
@tasks = @app.top_level_tasks
|
745
|
-
@app.options
|
746
|
-
end
|
747
|
-
end
|
748
|
-
|
749
|
-
class TestTaskArgumentParsing < Test::Unit::TestCase
|
750
|
-
def setup
|
751
|
-
@app = Rake::Application.new
|
752
|
-
@app.options.threads = Rake.application.options.threads
|
753
|
-
end
|
754
|
-
|
755
|
-
def test_name_only
|
756
|
-
name, args = @app.parse_task_string("name")
|
757
|
-
assert_equal "name", name
|
758
|
-
assert_equal [], args
|
759
|
-
end
|
760
|
-
|
761
|
-
def test_empty_args
|
762
|
-
name, args = @app.parse_task_string("name[]")
|
763
|
-
assert_equal "name", name
|
764
|
-
assert_equal [], args
|
765
|
-
end
|
766
|
-
|
767
|
-
def test_one_argument
|
768
|
-
name, args = @app.parse_task_string("name[one]")
|
769
|
-
assert_equal "name", name
|
770
|
-
assert_equal ["one"], args
|
771
|
-
end
|
772
|
-
|
773
|
-
def test_two_arguments
|
774
|
-
name, args = @app.parse_task_string("name[one,two]")
|
775
|
-
assert_equal "name", name
|
776
|
-
assert_equal ["one", "two"], args
|
777
|
-
end
|
778
|
-
|
779
|
-
def test_can_handle_spaces_between_args
|
780
|
-
name, args = @app.parse_task_string("name[one, two,\tthree , \tfour]")
|
781
|
-
assert_equal "name", name
|
782
|
-
assert_equal ["one", "two", "three", "four"], args
|
783
|
-
end
|
784
|
-
|
785
|
-
def test_keeps_embedded_spaces
|
786
|
-
name, args = @app.parse_task_string("name[a one ana, two]")
|
787
|
-
assert_equal "name", name
|
788
|
-
assert_equal ["a one ana", "two"], args
|
789
|
-
end
|
790
|
-
|
791
|
-
end
|
792
|
-
|
793
|
-
class TestTaskArgumentParsing < Test::Unit::TestCase
|
794
|
-
include InEnvironment
|
795
|
-
|
796
|
-
def test_terminal_width_using_env
|
797
|
-
app = Rake::Application.new
|
798
|
-
app.options.threads = Rake.application.options.threads
|
799
|
-
in_environment('RAKE_COLUMNS' => '1234') do
|
800
|
-
assert_equal 1234, app.terminal_width
|
801
|
-
end
|
802
|
-
end
|
803
|
-
|
804
|
-
def test_terminal_width_using_stty
|
805
|
-
app = Rake::Application.new
|
806
|
-
app.options.threads = Rake.application.options.threads
|
807
|
-
flexmock(app,
|
808
|
-
:unix? => true,
|
809
|
-
:dynamic_width_stty => 1235,
|
810
|
-
:dynamic_width_tput => 0)
|
811
|
-
in_environment('RAKE_COLUMNS' => nil) do
|
812
|
-
assert_equal 1235, app.terminal_width
|
813
|
-
end
|
814
|
-
end
|
815
|
-
|
816
|
-
def test_terminal_width_using_tput
|
817
|
-
app = Rake::Application.new
|
818
|
-
app.options.threads = Rake.application.options.threads
|
819
|
-
flexmock(app,
|
820
|
-
:unix? => true,
|
821
|
-
:dynamic_width_stty => 0,
|
822
|
-
:dynamic_width_tput => 1236)
|
823
|
-
in_environment('RAKE_COLUMNS' => nil) do
|
824
|
-
assert_equal 1236, app.terminal_width
|
825
|
-
end
|
826
|
-
end
|
827
|
-
|
828
|
-
def test_terminal_width_using_hardcoded_80
|
829
|
-
app = Rake::Application.new
|
830
|
-
app.options.threads = Rake.application.options.threads
|
831
|
-
flexmock(app, :unix? => false)
|
832
|
-
in_environment('RAKE_COLUMNS' => nil) do
|
833
|
-
assert_equal 80, app.terminal_width
|
834
|
-
end
|
835
|
-
end
|
836
|
-
|
837
|
-
def test_terminal_width_with_failure
|
838
|
-
app = Rake::Application.new
|
839
|
-
app.options.threads = Rake.application.options.threads
|
840
|
-
flexmock(app).should_receive(:unix?).and_throw(RuntimeError)
|
841
|
-
in_environment('RAKE_COLUMNS' => nil) do
|
842
|
-
assert_equal 80, app.terminal_width
|
843
|
-
end
|
844
|
-
end
|
845
|
-
|
846
|
-
def test_no_rakeopt
|
847
|
-
in_environment do
|
848
|
-
ARGV << '--trace'
|
849
|
-
app = Rake::Application.new
|
850
|
-
app.init
|
851
|
-
assert !app.options.silent
|
852
|
-
end
|
853
|
-
end
|
854
|
-
|
855
|
-
def test_rakeopt_with_blank_options
|
856
|
-
in_environment("RAKEOPT" => "") do
|
857
|
-
ARGV << '--trace'
|
858
|
-
app = Rake::Application.new
|
859
|
-
app.init
|
860
|
-
assert !app.options.silent
|
861
|
-
end
|
862
|
-
end
|
863
|
-
|
864
|
-
def test_rakeopt_with_silent_options
|
865
|
-
in_environment("RAKEOPT" => "-s") do
|
866
|
-
app = Rake::Application.new
|
867
|
-
app.init
|
868
|
-
assert app.options.silent
|
869
|
-
end
|
870
|
-
end
|
871
|
-
end
|