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.
- data/CHANGES +9 -8
- data/RRR +10 -0
- data/Rakefile +9 -45
- data/bin/rake +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 +44 -0
- data/test/in_environment.rb +4 -1
- data/test/{lib/rake_test.rb → test_rake.rb} +2 -5
- data/test/test_rake_application.rb +364 -0
- data/test/test_rake_application_options.rb +382 -0
- data/test/{lib/clean_test.rb → test_rake_clean.rb} +2 -5
- 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 -182
- data/test/test_rake_task_argument_parsing.rb +116 -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} +4 -12
- data/test/{contrib/test_sys.rb → test_sys.rb} +2 -6
- metadata +60 -44
- 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 -863
- 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 -20
- data/test/ruby_version_test.rb +0 -3
- data/test/test_helper.rb +0 -19
data/CHANGES
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
= Rake Changelog
|
2
2
|
|
3
|
+
== Version 0.9.1
|
4
|
+
|
5
|
+
* Added deprecation warnings to the Rake DSL methods.
|
6
|
+
|
3
7
|
== Version 0.9.0
|
4
8
|
|
5
|
-
*
|
9
|
+
* *Incompatible* *change*: Rake DSL commands ('task', 'file', etc.) are
|
10
|
+
no longer private methods in Object. If you need to call 'task :xzy' inside
|
11
|
+
your class, include Rake::DSL into the class. The DSL is still available at
|
12
|
+
the top level scope (via the top level object which extends Rake::DSL).
|
6
13
|
|
7
|
-
*
|
8
|
-
commands are no longer private methods in Object. (Suggested by
|
9
|
-
James M. Lawrence/quix)
|
14
|
+
* Rake now warns when the deprecated :needs syntax used.
|
10
15
|
|
11
16
|
* Rake history is now UTF-8 encoded.
|
12
17
|
|
@@ -36,10 +41,6 @@
|
|
36
41
|
|
37
42
|
* Rake no longer emits warnings for Config. Patch by Santiago Pastorino.
|
38
43
|
|
39
|
-
* Removed Rake's DSL methods from the top level scope. If you need to
|
40
|
-
call 'task :xzy' in your code, include Rake::DSL into your class, or
|
41
|
-
put the code in a Rake::DSL.environment do ... end block.
|
42
|
-
|
43
44
|
* Split rake.rb into individual files.
|
44
45
|
|
45
46
|
* Support for the --where (-W) flag for showing where a task is defined.
|
data/RRR
ADDED
data/Rakefile
CHANGED
@@ -58,50 +58,15 @@ SRC_RB = FileList['lib/**/*.rb']
|
|
58
58
|
# The default task is run if rake is given no explicit arguments.
|
59
59
|
|
60
60
|
desc "Default Task"
|
61
|
-
task :default =>
|
61
|
+
task :default => :test
|
62
62
|
|
63
63
|
# Test Tasks ---------------------------------------------------------
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
task :tc => "test:contribs"
|
71
|
-
task :test => "test:units"
|
72
|
-
|
73
|
-
module TestFiles
|
74
|
-
UNIT = FileList['test/lib/*_test.rb']
|
75
|
-
FUNCTIONAL = FileList['test/functional/*_test.rb']
|
76
|
-
CONTRIB = FileList['test/contrib/test*.rb']
|
77
|
-
TOP = FileList['test/*_test.rb']
|
78
|
-
ALL = TOP + UNIT + FUNCTIONAL + CONTRIB
|
79
|
-
end
|
80
|
-
|
81
|
-
namespace :test do
|
82
|
-
Rake::TestTask.new(:all) do |t|
|
83
|
-
t.test_files = TestFiles::ALL
|
84
|
-
t.libs << "."
|
85
|
-
t.warning = true
|
86
|
-
end
|
87
|
-
|
88
|
-
Rake::TestTask.new(:units) do |t|
|
89
|
-
t.test_files = TestFiles::UNIT
|
90
|
-
t.libs << "."
|
91
|
-
t.warning = true
|
92
|
-
end
|
93
|
-
|
94
|
-
Rake::TestTask.new(:functional) do |t|
|
95
|
-
t.test_files = TestFiles::FUNCTIONAL
|
96
|
-
t.libs << "."
|
97
|
-
t.warning = true
|
98
|
-
end
|
99
|
-
|
100
|
-
Rake::TestTask.new(:contribs) do |t|
|
101
|
-
t.test_files = TestFiles::CONTRIB
|
102
|
-
t.libs << "."
|
103
|
-
t.warning = true
|
104
|
-
end
|
65
|
+
Rake::TestTask.new do |t|
|
66
|
+
files = FileList['test/helper.rb', 'test/test_*.rb']
|
67
|
+
t.test_files = files
|
68
|
+
t.libs << "."
|
69
|
+
t.warning = true
|
105
70
|
end
|
106
71
|
|
107
72
|
begin
|
@@ -143,9 +108,7 @@ rescue LoadError
|
|
143
108
|
end
|
144
109
|
|
145
110
|
directory 'testdata'
|
146
|
-
|
147
|
-
task t => ['testdata']
|
148
|
-
end
|
111
|
+
task :test => ['testdata']
|
149
112
|
|
150
113
|
# CVS Tasks ----------------------------------------------------------
|
151
114
|
|
@@ -217,6 +180,7 @@ else
|
|
217
180
|
#### Dependencies and requirements.
|
218
181
|
|
219
182
|
s.required_rubygems_version = '>= 1.3.2'
|
183
|
+
s.add_development_dependency 'minitest', '~> 2.1'
|
220
184
|
s.add_development_dependency 'session', '~> 2.4'
|
221
185
|
s.add_development_dependency 'flexmock', '~> 0.8.11'
|
222
186
|
|
@@ -342,7 +306,7 @@ desc "Make a new release"
|
|
342
306
|
task :release, [:rel, :reuse, :reltest] => [
|
343
307
|
:prerelease,
|
344
308
|
:clobber,
|
345
|
-
|
309
|
+
:test,
|
346
310
|
:update_version,
|
347
311
|
:package,
|
348
312
|
:tag
|
data/bin/rake
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
= Rake 0.9.1 Released
|
2
|
+
|
3
|
+
Rake version 0.9.1 has a number of bug fixes and enhancments (see
|
4
|
+
below for more details). Additionally, the internals have be slightly
|
5
|
+
restructured and improved.
|
6
|
+
|
7
|
+
== Changes
|
8
|
+
|
9
|
+
Rake 0.9.1 adds back the global DSL methods, but with deprecation
|
10
|
+
messages. This allows Rake 0.9.1 to be used with older rakefiles with
|
11
|
+
warning messages.
|
12
|
+
|
13
|
+
== What is Rake
|
14
|
+
|
15
|
+
Rake is a build tool similar to the make program in many ways. But
|
16
|
+
instead of cryptic make recipes, Rake uses standard Ruby code to
|
17
|
+
declare tasks and dependencies. You have the full power of a modern
|
18
|
+
scripting language built right into your build tool.
|
19
|
+
|
20
|
+
== Availability
|
21
|
+
|
22
|
+
The easiest way to get and install rake is via RubyGems ...
|
23
|
+
|
24
|
+
gem install rake (you may need root/admin privileges)
|
25
|
+
|
26
|
+
Otherwise, you can get it from the more traditional places:
|
27
|
+
|
28
|
+
Home Page:: http://rake.rubyforge.org/
|
29
|
+
Download:: http://rubyforge.org/project/showfiles.php?group_id=50
|
30
|
+
GitHub:: git://github.com/jimweirich/rake.git
|
31
|
+
|
32
|
+
== Thanks
|
33
|
+
|
34
|
+
As usual, it was input from users that drove a alot of these changes. The
|
35
|
+
following people either contributed patches, made suggestions or made
|
36
|
+
otherwise helpful comments. Thanks to ...
|
37
|
+
|
38
|
+
* James M. Lawrence (quix)
|
39
|
+
* Roger Pack
|
40
|
+
* Cezary Baginski
|
41
|
+
* Sean Scot August Moon
|
42
|
+
* R.T. Lechow
|
43
|
+
* Alex Chaffee
|
44
|
+
* James Tucker
|
45
|
+
* Matthias Lüdtke
|
46
|
+
* Santiago Pastorino
|
47
|
+
|
48
|
+
Also, bit thanks to Eric Hodel for assisting with getting this release
|
49
|
+
out the door (where "assisting" includes, but is not by any means
|
50
|
+
limited to, "pushing" me to get it done).
|
51
|
+
|
52
|
+
-- Jim Weirich
|
data/lib/rake/dsl_definition.rb
CHANGED
@@ -12,6 +12,8 @@ module Rake
|
|
12
12
|
private(*FileUtils.instance_methods(false))
|
13
13
|
private(*FileUtilsExt.instance_methods(false))
|
14
14
|
|
15
|
+
private
|
16
|
+
|
15
17
|
# Declare a basic task.
|
16
18
|
#
|
17
19
|
# Example:
|
@@ -137,7 +139,24 @@ module Rake
|
|
137
139
|
end
|
138
140
|
end
|
139
141
|
|
142
|
+
module DeprecatedObjectDSL
|
143
|
+
dsl = Object.new.extend DSL
|
144
|
+
DSL.private_instance_methods(false).each do |name|
|
145
|
+
define_method name do |*args, &block|
|
146
|
+
unless @rake_dsl_warning
|
147
|
+
$stderr.puts "WARNING: Global access to Rake DSL methods is deprecated. Please Include"
|
148
|
+
$stderr.puts " ... Rake::DSL into classes and modules which use the Rake DSL methods."
|
149
|
+
@rake_dsl_warning = true
|
150
|
+
end
|
151
|
+
$stderr.puts "WARNING: DSL method #{self.class}##{name} called at #{caller.first}"
|
152
|
+
dsl.send(name, *args, &block)
|
153
|
+
end
|
154
|
+
private name
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
140
158
|
extend FileUtilsExt
|
141
159
|
end
|
142
160
|
|
143
161
|
self.extend Rake::DSL
|
162
|
+
include Rake::DeprecatedObjectDSL
|
data/lib/rake/version.rb
CHANGED
data/test/data/access/Rakefile
CHANGED
data/test/data/default/Rakefile
CHANGED
data/test/file_creation.rb
CHANGED
data/test/helper.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'minitest/unit'
|
3
|
+
require 'flexmock/test_unit_integration'
|
4
|
+
require 'minitest/autorun'
|
5
|
+
require 'rake'
|
6
|
+
require File.expand_path('../file_creation', __FILE__)
|
7
|
+
require File.expand_path('../in_environment', __FILE__)
|
8
|
+
|
9
|
+
class Rake::TestCase < MiniTest::Unit::TestCase
|
10
|
+
include FlexMock::ArgumentTypes
|
11
|
+
include FlexMock::MockContainer
|
12
|
+
|
13
|
+
include InEnvironment
|
14
|
+
include FileCreation
|
15
|
+
|
16
|
+
include Rake::DSL
|
17
|
+
|
18
|
+
class TaskManager
|
19
|
+
include Rake::TaskManager
|
20
|
+
end
|
21
|
+
|
22
|
+
def setup
|
23
|
+
@orig_PWD = Dir.pwd
|
24
|
+
end
|
25
|
+
|
26
|
+
def teardown
|
27
|
+
flexmock_teardown
|
28
|
+
|
29
|
+
Dir.chdir @orig_PWD
|
30
|
+
end
|
31
|
+
|
32
|
+
def ignore_deprecations
|
33
|
+
Rake.application.options.ignore_deprecate = true
|
34
|
+
yield
|
35
|
+
ensure
|
36
|
+
Rake.application.options.ignore_deprecate = false
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
# workarounds for 1.8
|
42
|
+
$" << 'test/helper.rb'
|
43
|
+
Test::Unit.run = true if Test::Unit.respond_to? :run=
|
44
|
+
|
data/test/in_environment.rb
CHANGED
@@ -13,10 +13,12 @@ module InEnvironment
|
|
13
13
|
end
|
14
14
|
|
15
15
|
# Set the environment according to the settings hash.
|
16
|
-
def set_env(settings)
|
16
|
+
def set_env(settings) # :nodoc:
|
17
17
|
result = {}
|
18
|
+
|
18
19
|
settings.each do |k, v|
|
19
20
|
result[k] = ENV[k]
|
21
|
+
|
20
22
|
if k == 'PWD'
|
21
23
|
result[k] = Dir.pwd
|
22
24
|
Dir.chdir(v)
|
@@ -26,6 +28,7 @@ module InEnvironment
|
|
26
28
|
ENV[k] = v
|
27
29
|
end
|
28
30
|
end
|
31
|
+
|
29
32
|
result
|
30
33
|
end
|
31
34
|
|
@@ -1,9 +1,6 @@
|
|
1
|
-
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
2
|
|
3
|
-
|
4
|
-
require 'rake'
|
5
|
-
|
6
|
-
class TestRake < Test::Unit::TestCase
|
3
|
+
class TestRake < Rake::TestCase
|
7
4
|
def test_each_dir_parent
|
8
5
|
assert_equal ['a'], alldirs('a')
|
9
6
|
assert_equal ['a/b', 'a'], alldirs('a/b')
|
@@ -0,0 +1,364 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
3
|
+
class TestRakeApplication < Rake::TestCase
|
4
|
+
include InEnvironment
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
|
9
|
+
@app = Rake::Application.new
|
10
|
+
@app.options.rakelib = []
|
11
|
+
Rake::TaskManager.record_task_metadata = true
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
Rake::TaskManager.record_task_metadata = false
|
16
|
+
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_constant_warning
|
21
|
+
_, err = capture_io do @app.instance_eval { const_warning("Task") } end
|
22
|
+
assert_match(/warning/i, err)
|
23
|
+
assert_match(/deprecated/i, err)
|
24
|
+
assert_match(/Task/i, err)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_display_tasks
|
28
|
+
@app.options.show_tasks = :tasks
|
29
|
+
@app.options.show_task_pattern = //
|
30
|
+
@app.last_description = "COMMENT"
|
31
|
+
@app.define_task(Rake::Task, "t")
|
32
|
+
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
33
|
+
assert_match(/^rake t/, out)
|
34
|
+
assert_match(/# COMMENT/, out)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_display_tasks_with_long_comments
|
38
|
+
in_environment('RAKE_COLUMNS' => '80') do
|
39
|
+
@app.options.show_tasks = :tasks
|
40
|
+
@app.options.show_task_pattern = //
|
41
|
+
@app.last_description = "1234567890" * 8
|
42
|
+
@app.define_task(Rake::Task, "t")
|
43
|
+
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
44
|
+
assert_match(/^rake t/, out)
|
45
|
+
assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_display_tasks_with_task_name_wider_than_tty_display
|
50
|
+
in_environment('RAKE_COLUMNS' => '80') do
|
51
|
+
@app.options.show_tasks = :tasks
|
52
|
+
@app.options.show_task_pattern = //
|
53
|
+
task_name = "task name" * 80
|
54
|
+
@app.last_description = "something short"
|
55
|
+
@app.define_task(Rake::Task, task_name )
|
56
|
+
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
57
|
+
# Ensure the entire task name is output and we end up showing no description
|
58
|
+
assert_match(/rake #{task_name} # .../, out)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comment
|
63
|
+
@app.options.show_tasks = :tasks
|
64
|
+
@app.options.show_task_pattern = //
|
65
|
+
@app.tty_output = false
|
66
|
+
description = "something short"
|
67
|
+
task_name = "task name" * 80
|
68
|
+
@app.last_description = "something short"
|
69
|
+
@app.define_task(Rake::Task, task_name )
|
70
|
+
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
71
|
+
# Ensure the entire task name is output and we end up showing no description
|
72
|
+
assert_match(/rake #{task_name} # #{description}/, out)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_display_tasks_with_long_comments_to_a_non_tty_shows_entire_comment
|
76
|
+
@app.options.show_tasks = :tasks
|
77
|
+
@app.options.show_task_pattern = //
|
78
|
+
@app.tty_output = false
|
79
|
+
@app.last_description = "1234567890" * 8
|
80
|
+
@app.define_task(Rake::Task, "t")
|
81
|
+
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
82
|
+
assert_match(/^rake t/, out)
|
83
|
+
assert_match(/# #{@app.last_description}/, out)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_display_tasks_with_long_comments_to_a_non_tty_with_columns_set_truncates_comments
|
87
|
+
in_environment("RAKE_COLUMNS" => '80') do
|
88
|
+
@app.options.show_tasks = :tasks
|
89
|
+
@app.options.show_task_pattern = //
|
90
|
+
@app.tty_output = false
|
91
|
+
@app.last_description = "1234567890" * 8
|
92
|
+
@app.define_task(Rake::Task, "t")
|
93
|
+
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
94
|
+
assert_match(/^rake t/, out)
|
95
|
+
assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_describe_tasks
|
100
|
+
@app.options.show_tasks = :describe
|
101
|
+
@app.options.show_task_pattern = //
|
102
|
+
@app.last_description = "COMMENT"
|
103
|
+
@app.define_task(Rake::Task, "t")
|
104
|
+
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
105
|
+
assert_match(/^rake t$/, out)
|
106
|
+
assert_match(/^ {4}COMMENT$/, out)
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_show_lines
|
110
|
+
@app.options.show_tasks = :lines
|
111
|
+
@app.options.show_task_pattern = //
|
112
|
+
@app.last_description = "COMMENT"
|
113
|
+
@app.define_task(Rake::Task, "t")
|
114
|
+
@app['t'].locations << "HERE:1"
|
115
|
+
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
116
|
+
assert_match(/^rake t +[^:]+:\d+ *$/, out)
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_finding_rakefile
|
120
|
+
assert_match(/Rakefile/i, @app.instance_eval { have_rakefile })
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_not_finding_rakefile
|
124
|
+
@app.instance_eval { @rakefiles = ['NEVER_FOUND'] }
|
125
|
+
assert( ! @app.instance_eval do have_rakefile end )
|
126
|
+
assert_nil @app.rakefile
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_load_rakefile
|
130
|
+
in_environment("PWD" => "test/data/unittest") do
|
131
|
+
@app.instance_eval do
|
132
|
+
handle_options
|
133
|
+
options.silent = true
|
134
|
+
load_rakefile
|
135
|
+
end
|
136
|
+
assert_equal "rakefile", @app.rakefile.downcase
|
137
|
+
assert_match(%r(unittest$), Dir.pwd)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_load_rakefile_doesnt_print_rakefile_directory_from_same_dir
|
142
|
+
in_environment("PWD" => "test/data/unittest") do
|
143
|
+
_, err = capture_io do
|
144
|
+
@app.instance_eval do
|
145
|
+
@original_dir = File.expand_path(".") # pretend we started from the unittest dir
|
146
|
+
raw_load_rakefile
|
147
|
+
end
|
148
|
+
end
|
149
|
+
_, location = @app.find_rakefile_location
|
150
|
+
refute_match(/\(in #{location}\)/, err)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_load_rakefile_from_subdir
|
155
|
+
in_environment("PWD" => "test/data/unittest/subdir") do
|
156
|
+
@app.instance_eval do
|
157
|
+
handle_options
|
158
|
+
options.silent = true
|
159
|
+
load_rakefile
|
160
|
+
end
|
161
|
+
assert_equal "rakefile", @app.rakefile.downcase
|
162
|
+
assert_match(%r(unittest$), Dir.pwd)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_load_rakefile_prints_rakefile_directory_from_subdir
|
167
|
+
in_environment("PWD" => "test/data/unittest/subdir") do
|
168
|
+
_, err = capture_io do
|
169
|
+
@app.instance_eval do
|
170
|
+
raw_load_rakefile
|
171
|
+
end
|
172
|
+
end
|
173
|
+
_, location = @app.find_rakefile_location
|
174
|
+
assert_match(/\(in #{location}\)/, err)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_load_rakefile_doesnt_print_rakefile_directory_from_subdir_if_silent
|
179
|
+
in_environment("PWD" => "test/data/unittest/subdir") do
|
180
|
+
_, err = capture_io do
|
181
|
+
@app.instance_eval do
|
182
|
+
handle_options
|
183
|
+
options.silent = true
|
184
|
+
raw_load_rakefile
|
185
|
+
end
|
186
|
+
end
|
187
|
+
_, location = @app.find_rakefile_location
|
188
|
+
refute_match(/\(in #{location}\)/, err)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_load_rakefile_not_found
|
193
|
+
in_environment("PWD" => "/", "RAKE_SYSTEM" => 'not_exist') do
|
194
|
+
@app.instance_eval do
|
195
|
+
handle_options
|
196
|
+
options.silent = true
|
197
|
+
end
|
198
|
+
ex = assert_raises(RuntimeError) do
|
199
|
+
@app.instance_eval do raw_load_rakefile end
|
200
|
+
end
|
201
|
+
assert_match(/no rakefile found/i, ex.message)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_load_from_system_rakefile
|
206
|
+
in_environment('RAKE_SYSTEM' => 'test/data/sys') do
|
207
|
+
@app.options.rakelib = []
|
208
|
+
@app.instance_eval do
|
209
|
+
handle_options
|
210
|
+
options.silent = true
|
211
|
+
options.load_system = true
|
212
|
+
options.rakelib = []
|
213
|
+
load_rakefile
|
214
|
+
end
|
215
|
+
assert_equal "test/data/sys", @app.system_dir
|
216
|
+
assert_nil @app.rakefile
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
def test_load_from_calculated_system_rakefile
|
221
|
+
flexmock(@app, :standard_system_dir => "__STD_SYS_DIR__")
|
222
|
+
in_environment('RAKE_SYSTEM' => nil) 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 "__STD_SYS_DIR__", @app.system_dir
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_windows
|
236
|
+
assert ! (@app.windows? && @app.unix?)
|
237
|
+
end
|
238
|
+
|
239
|
+
def test_loading_imports
|
240
|
+
mock = flexmock("loader")
|
241
|
+
mock.should_receive(:load).with("x.dummy").once
|
242
|
+
@app.instance_eval do
|
243
|
+
add_loader("dummy", mock)
|
244
|
+
add_import("x.dummy")
|
245
|
+
load_imports
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
def test_building_imported_files_on_demand
|
250
|
+
mock = flexmock("loader")
|
251
|
+
mock.should_receive(:load).with("x.dummy").once
|
252
|
+
mock.should_receive(:make_dummy).with_no_args.once
|
253
|
+
@app.instance_eval do
|
254
|
+
intern(Rake::Task, "x.dummy").enhance do mock.make_dummy end
|
255
|
+
add_loader("dummy", mock)
|
256
|
+
add_import("x.dummy")
|
257
|
+
load_imports
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
def test_handle_options_should_strip_options_from_ARGV
|
262
|
+
assert !@app.options.trace
|
263
|
+
|
264
|
+
valid_option = '--trace'
|
265
|
+
ARGV.clear
|
266
|
+
ARGV << valid_option
|
267
|
+
|
268
|
+
@app.handle_options
|
269
|
+
|
270
|
+
assert !ARGV.include?(valid_option)
|
271
|
+
assert @app.options.trace
|
272
|
+
end
|
273
|
+
|
274
|
+
def test_good_run
|
275
|
+
ran = false
|
276
|
+
ARGV.clear
|
277
|
+
ARGV << '--rakelib=""'
|
278
|
+
@app.options.silent = true
|
279
|
+
@app.instance_eval do
|
280
|
+
intern(Rake::Task, "default").enhance { ran = true }
|
281
|
+
end
|
282
|
+
in_environment("PWD" => "test/data/default") do
|
283
|
+
@app.run
|
284
|
+
end
|
285
|
+
assert ran
|
286
|
+
end
|
287
|
+
|
288
|
+
def test_display_task_run
|
289
|
+
ran = false
|
290
|
+
ARGV.clear
|
291
|
+
ARGV << '-f' << '-s' << '--tasks' << '--rakelib=""'
|
292
|
+
@app.last_description = "COMMENT"
|
293
|
+
@app.define_task(Rake::Task, "default")
|
294
|
+
out, = capture_io { @app.run }
|
295
|
+
assert @app.options.show_tasks
|
296
|
+
assert ! ran
|
297
|
+
assert_match(/rake default/, out)
|
298
|
+
assert_match(/# COMMENT/, out)
|
299
|
+
end
|
300
|
+
|
301
|
+
def test_display_prereqs
|
302
|
+
ran = false
|
303
|
+
ARGV.clear
|
304
|
+
ARGV << '-f' << '-s' << '--prereqs' << '--rakelib=""'
|
305
|
+
@app.last_description = "COMMENT"
|
306
|
+
t = @app.define_task(Rake::Task, "default")
|
307
|
+
t.enhance([:a, :b])
|
308
|
+
@app.define_task(Rake::Task, "a")
|
309
|
+
@app.define_task(Rake::Task, "b")
|
310
|
+
out, = capture_io { @app.run }
|
311
|
+
assert @app.options.show_prereqs
|
312
|
+
assert ! ran
|
313
|
+
assert_match(/rake a$/, out)
|
314
|
+
assert_match(/rake b$/, out)
|
315
|
+
assert_match(/rake default\n( *(a|b)\n){2}/m, out)
|
316
|
+
end
|
317
|
+
|
318
|
+
def test_bad_run
|
319
|
+
@app.intern(Rake::Task, "default").enhance { fail }
|
320
|
+
ARGV.clear
|
321
|
+
ARGV << '-f' << '-s' << '--rakelib=""'
|
322
|
+
assert_raises(SystemExit) {
|
323
|
+
_, err = capture_io { @app.run }
|
324
|
+
assert_match(/see full trace/, err)
|
325
|
+
}
|
326
|
+
ensure
|
327
|
+
ARGV.clear
|
328
|
+
end
|
329
|
+
|
330
|
+
def test_bad_run_with_trace
|
331
|
+
@app.intern(Rake::Task, "default").enhance { fail }
|
332
|
+
ARGV.clear
|
333
|
+
ARGV << '-f' << '-s' << '-t'
|
334
|
+
assert_raises(SystemExit) {
|
335
|
+
_, err = capture_io { @app.run }
|
336
|
+
refute_match(/see full trace/, err)
|
337
|
+
}
|
338
|
+
ensure
|
339
|
+
ARGV.clear
|
340
|
+
end
|
341
|
+
|
342
|
+
def test_run_with_bad_options
|
343
|
+
@app.intern(Rake::Task, "default").enhance { fail }
|
344
|
+
ARGV.clear
|
345
|
+
ARGV << '-f' << '-s' << '--xyzzy'
|
346
|
+
assert_raises(SystemExit) {
|
347
|
+
capture_io { @app.run }
|
348
|
+
}
|
349
|
+
ensure
|
350
|
+
ARGV.clear
|
351
|
+
end
|
352
|
+
|
353
|
+
def test_deprecation_message
|
354
|
+
in_environment do
|
355
|
+
_, err = capture_io do
|
356
|
+
@app.deprecate("a", "b", "c")
|
357
|
+
end
|
358
|
+
assert_match(/'a' is deprecated/i, err)
|
359
|
+
assert_match(/use 'b' instead/i, err)
|
360
|
+
assert_match(/at c$/i, err)
|
361
|
+
end
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|