drake 0.9.0.0.3.0 → 0.9.1.0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
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/CHANGES-drake
CHANGED
data/Rakefile
CHANGED
@@ -59,58 +59,24 @@ SRC_RB = FileList['lib/**/*.rb']
|
|
59
59
|
# The default task is run if rake is given no explicit arguments.
|
60
60
|
|
61
61
|
desc "Default Task"
|
62
|
-
task :default =>
|
62
|
+
task :default => :test
|
63
63
|
|
64
64
|
# Test Tasks ---------------------------------------------------------
|
65
65
|
|
66
|
-
|
66
|
+
task :test => [:test_serial, :test_parallel]
|
67
67
|
|
68
|
-
|
69
|
-
task :tf => "test:functional"
|
70
|
-
task :tu => "test:units"
|
71
|
-
task :tc => "test:contribs"
|
72
|
-
task :test => "test:units"
|
68
|
+
TEST_FILES = FileList['test/helper.rb', 'test/test_*.rb']
|
73
69
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
TOP = FileList['test/*_test.rb']
|
79
|
-
ALL = TOP + UNIT + FUNCTIONAL + CONTRIB
|
70
|
+
Rake::TestTask.new :test_serial do |t|
|
71
|
+
t.test_files = ['test/setup_serial.rb'] + TEST_FILES
|
72
|
+
t.libs << "."
|
73
|
+
t.warning = true
|
80
74
|
end
|
81
75
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
t.test_files = ['test/serial_setup.rb'] + TestFiles::ALL
|
87
|
-
t.libs << "."
|
88
|
-
t.warning = true
|
89
|
-
end
|
90
|
-
|
91
|
-
Rake::TestTask.new(:parallel) do |t|
|
92
|
-
t.test_files = ['test/parallel_setup.rb'] + TestFiles::ALL
|
93
|
-
t.libs << "."
|
94
|
-
t.warning = true
|
95
|
-
end
|
96
|
-
|
97
|
-
Rake::TestTask.new(:units) do |t|
|
98
|
-
t.test_files = TestFiles::UNIT
|
99
|
-
t.libs << "."
|
100
|
-
t.warning = true
|
101
|
-
end
|
102
|
-
|
103
|
-
Rake::TestTask.new(:functional) do |t|
|
104
|
-
t.test_files = TestFiles::FUNCTIONAL
|
105
|
-
t.libs << "."
|
106
|
-
t.warning = true
|
107
|
-
end
|
108
|
-
|
109
|
-
Rake::TestTask.new(:contribs) do |t|
|
110
|
-
t.test_files = TestFiles::CONTRIB
|
111
|
-
t.libs << "."
|
112
|
-
t.warning = true
|
113
|
-
end
|
76
|
+
Rake::TestTask.new :test_parallel do |t|
|
77
|
+
t.test_files = ['test/setup_parallel.rb'] + TEST_FILES
|
78
|
+
t.libs << "."
|
79
|
+
t.warning = true
|
114
80
|
end
|
115
81
|
|
116
82
|
begin
|
@@ -152,9 +118,7 @@ rescue LoadError
|
|
152
118
|
end
|
153
119
|
|
154
120
|
directory 'testdata'
|
155
|
-
|
156
|
-
task t => ['testdata']
|
157
|
-
end
|
121
|
+
task :test => ['testdata']
|
158
122
|
|
159
123
|
# CVS Tasks ----------------------------------------------------------
|
160
124
|
|
@@ -228,6 +192,7 @@ else
|
|
228
192
|
s.add_dependency('comp_tree', '>= 1.1.3')
|
229
193
|
|
230
194
|
s.required_rubygems_version = '>= 1.3.2'
|
195
|
+
s.add_development_dependency 'minitest', '~> 2.1'
|
231
196
|
s.add_development_dependency 'session', '~> 2.4'
|
232
197
|
s.add_development_dependency 'flexmock', '~> 0.8.11'
|
233
198
|
|
@@ -356,7 +321,7 @@ desc "Make a new release"
|
|
356
321
|
task :release, [:rel, :reuse, :reltest] => [
|
357
322
|
:prerelease,
|
358
323
|
:clobber,
|
359
|
-
|
324
|
+
:test,
|
360
325
|
:update_version,
|
361
326
|
:package,
|
362
327
|
:tag
|
data/Rakefile-drake
CHANGED
@@ -52,6 +52,7 @@ task :drake_publish => :rdoc do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
task :drake_finish_release do
|
55
|
+
gem = "#{SPEC.name}-#{SPEC.version}.gem"
|
55
56
|
git "tag", "drake-#{SPEC.version}"
|
56
57
|
git "push", "--tags", "origin", "master"
|
57
58
|
sh "gem", "push", gem
|
@@ -61,7 +62,7 @@ task :drake_release =>
|
|
61
62
|
[
|
62
63
|
:drake_prerelease,
|
63
64
|
:gem,
|
64
|
-
|
65
|
+
:test,
|
65
66
|
:drake_finish_release,
|
66
67
|
]
|
67
68
|
|
data/bin/drake
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,63 @@
|
|
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
|
+
|
45
|
+
class ThreadSafeArray
|
46
|
+
def initialize
|
47
|
+
@mutex = Mutex.new
|
48
|
+
@array = Array.new
|
49
|
+
end
|
50
|
+
|
51
|
+
Array.public_instance_methods.each do |method_name|
|
52
|
+
unless method_name =~ %r!\A__! or method_name =~ %r!\A(object_)?id\Z!
|
53
|
+
# TODO: jettison 1.8.6; use define_method with |&block|
|
54
|
+
eval %{
|
55
|
+
def #{method_name}(*args, &block)
|
56
|
+
@mutex.synchronize {
|
57
|
+
@array.send('#{method_name}', *args, &block)
|
58
|
+
}
|
59
|
+
end
|
60
|
+
}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
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
|
|
File without changes
|
File without changes
|
@@ -2,10 +2,12 @@
|
|
2
2
|
require 'rbconfig'
|
3
3
|
require 'test/unit'
|
4
4
|
require 'rake'
|
5
|
-
require 'test/
|
5
|
+
require 'test/helper'
|
6
6
|
|
7
7
|
if Rake.application.options.threads != 1
|
8
8
|
class TestParallel < Test::Unit::TestCase
|
9
|
+
include Rake::DSL
|
10
|
+
|
9
11
|
VISUALS = false
|
10
12
|
TIME_STEP = 0.25
|
11
13
|
TIME_EPSILON = 0.05
|
@@ -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,365 @@
|
|
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.threads = Rake.application.options.threads
|
11
|
+
@app.options.rakelib = []
|
12
|
+
Rake::TaskManager.record_task_metadata = true
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
Rake::TaskManager.record_task_metadata = false
|
17
|
+
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_constant_warning
|
22
|
+
_, err = capture_io do @app.instance_eval { const_warning("Task") } end
|
23
|
+
assert_match(/warning/i, err)
|
24
|
+
assert_match(/deprecated/i, err)
|
25
|
+
assert_match(/Task/i, err)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_display_tasks
|
29
|
+
@app.options.show_tasks = :tasks
|
30
|
+
@app.options.show_task_pattern = //
|
31
|
+
@app.last_description = "COMMENT"
|
32
|
+
@app.define_task(Rake::Task, "t")
|
33
|
+
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
34
|
+
assert_match(/^rake t/, out)
|
35
|
+
assert_match(/# COMMENT/, out)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_display_tasks_with_long_comments
|
39
|
+
in_environment('RAKE_COLUMNS' => '80') do
|
40
|
+
@app.options.show_tasks = :tasks
|
41
|
+
@app.options.show_task_pattern = //
|
42
|
+
@app.last_description = "1234567890" * 8
|
43
|
+
@app.define_task(Rake::Task, "t")
|
44
|
+
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
45
|
+
assert_match(/^rake t/, out)
|
46
|
+
assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_display_tasks_with_task_name_wider_than_tty_display
|
51
|
+
in_environment('RAKE_COLUMNS' => '80') do
|
52
|
+
@app.options.show_tasks = :tasks
|
53
|
+
@app.options.show_task_pattern = //
|
54
|
+
task_name = "task name" * 80
|
55
|
+
@app.last_description = "something short"
|
56
|
+
@app.define_task(Rake::Task, task_name )
|
57
|
+
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
58
|
+
# Ensure the entire task name is output and we end up showing no description
|
59
|
+
assert_match(/rake #{task_name} # .../, out)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comment
|
64
|
+
@app.options.show_tasks = :tasks
|
65
|
+
@app.options.show_task_pattern = //
|
66
|
+
@app.tty_output = false
|
67
|
+
description = "something short"
|
68
|
+
task_name = "task name" * 80
|
69
|
+
@app.last_description = "something short"
|
70
|
+
@app.define_task(Rake::Task, task_name )
|
71
|
+
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
72
|
+
# Ensure the entire task name is output and we end up showing no description
|
73
|
+
assert_match(/rake #{task_name} # #{description}/, out)
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_display_tasks_with_long_comments_to_a_non_tty_shows_entire_comment
|
77
|
+
@app.options.show_tasks = :tasks
|
78
|
+
@app.options.show_task_pattern = //
|
79
|
+
@app.tty_output = false
|
80
|
+
@app.last_description = "1234567890" * 8
|
81
|
+
@app.define_task(Rake::Task, "t")
|
82
|
+
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
83
|
+
assert_match(/^rake t/, out)
|
84
|
+
assert_match(/# #{@app.last_description}/, out)
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_display_tasks_with_long_comments_to_a_non_tty_with_columns_set_truncates_comments
|
88
|
+
in_environment("RAKE_COLUMNS" => '80') do
|
89
|
+
@app.options.show_tasks = :tasks
|
90
|
+
@app.options.show_task_pattern = //
|
91
|
+
@app.tty_output = false
|
92
|
+
@app.last_description = "1234567890" * 8
|
93
|
+
@app.define_task(Rake::Task, "t")
|
94
|
+
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
95
|
+
assert_match(/^rake t/, out)
|
96
|
+
assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_describe_tasks
|
101
|
+
@app.options.show_tasks = :describe
|
102
|
+
@app.options.show_task_pattern = //
|
103
|
+
@app.last_description = "COMMENT"
|
104
|
+
@app.define_task(Rake::Task, "t")
|
105
|
+
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
106
|
+
assert_match(/^rake t$/, out)
|
107
|
+
assert_match(/^ {4}COMMENT$/, out)
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_show_lines
|
111
|
+
@app.options.show_tasks = :lines
|
112
|
+
@app.options.show_task_pattern = //
|
113
|
+
@app.last_description = "COMMENT"
|
114
|
+
@app.define_task(Rake::Task, "t")
|
115
|
+
@app['t'].locations << "HERE:1"
|
116
|
+
out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
|
117
|
+
assert_match(/^rake t +[^:]+:\d+ *$/, out)
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_finding_rakefile
|
121
|
+
assert_match(/Rakefile/i, @app.instance_eval { have_rakefile })
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_not_finding_rakefile
|
125
|
+
@app.instance_eval { @rakefiles = ['NEVER_FOUND'] }
|
126
|
+
assert( ! @app.instance_eval do have_rakefile end )
|
127
|
+
assert_nil @app.rakefile
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_load_rakefile
|
131
|
+
in_environment("PWD" => "test/data/unittest") do
|
132
|
+
@app.instance_eval do
|
133
|
+
handle_options
|
134
|
+
options.silent = true
|
135
|
+
load_rakefile
|
136
|
+
end
|
137
|
+
assert_equal "rakefile", @app.rakefile.downcase
|
138
|
+
assert_match(%r(unittest$), Dir.pwd)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_load_rakefile_doesnt_print_rakefile_directory_from_same_dir
|
143
|
+
in_environment("PWD" => "test/data/unittest") do
|
144
|
+
_, err = capture_io do
|
145
|
+
@app.instance_eval do
|
146
|
+
@original_dir = File.expand_path(".") # pretend we started from the unittest dir
|
147
|
+
raw_load_rakefile
|
148
|
+
end
|
149
|
+
end
|
150
|
+
_, location = @app.find_rakefile_location
|
151
|
+
refute_match(/\(in #{location}\)/, err)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_load_rakefile_from_subdir
|
156
|
+
in_environment("PWD" => "test/data/unittest/subdir") do
|
157
|
+
@app.instance_eval do
|
158
|
+
handle_options
|
159
|
+
options.silent = true
|
160
|
+
load_rakefile
|
161
|
+
end
|
162
|
+
assert_equal "rakefile", @app.rakefile.downcase
|
163
|
+
assert_match(%r(unittest$), Dir.pwd)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_load_rakefile_prints_rakefile_directory_from_subdir
|
168
|
+
in_environment("PWD" => "test/data/unittest/subdir") do
|
169
|
+
_, err = capture_io do
|
170
|
+
@app.instance_eval do
|
171
|
+
raw_load_rakefile
|
172
|
+
end
|
173
|
+
end
|
174
|
+
_, location = @app.find_rakefile_location
|
175
|
+
assert_match(/\(in #{location}\)/, err)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_load_rakefile_doesnt_print_rakefile_directory_from_subdir_if_silent
|
180
|
+
in_environment("PWD" => "test/data/unittest/subdir") do
|
181
|
+
_, err = capture_io do
|
182
|
+
@app.instance_eval do
|
183
|
+
handle_options
|
184
|
+
options.silent = true
|
185
|
+
raw_load_rakefile
|
186
|
+
end
|
187
|
+
end
|
188
|
+
_, location = @app.find_rakefile_location
|
189
|
+
refute_match(/\(in #{location}\)/, err)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_load_rakefile_not_found
|
194
|
+
in_environment("PWD" => "/", "RAKE_SYSTEM" => 'not_exist') do
|
195
|
+
@app.instance_eval do
|
196
|
+
handle_options
|
197
|
+
options.silent = true
|
198
|
+
end
|
199
|
+
ex = assert_raises(RuntimeError) do
|
200
|
+
@app.instance_eval do raw_load_rakefile end
|
201
|
+
end
|
202
|
+
assert_match(/no rakefile found/i, ex.message)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_load_from_system_rakefile
|
207
|
+
in_environment('RAKE_SYSTEM' => 'test/data/sys') do
|
208
|
+
@app.options.rakelib = []
|
209
|
+
@app.instance_eval do
|
210
|
+
handle_options
|
211
|
+
options.silent = true
|
212
|
+
options.load_system = true
|
213
|
+
options.rakelib = []
|
214
|
+
load_rakefile
|
215
|
+
end
|
216
|
+
assert_equal "test/data/sys", @app.system_dir
|
217
|
+
assert_nil @app.rakefile
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def test_load_from_calculated_system_rakefile
|
222
|
+
flexmock(@app, :standard_system_dir => "__STD_SYS_DIR__")
|
223
|
+
in_environment('RAKE_SYSTEM' => nil) do
|
224
|
+
@app.options.rakelib = []
|
225
|
+
@app.instance_eval do
|
226
|
+
handle_options
|
227
|
+
options.silent = true
|
228
|
+
options.load_system = true
|
229
|
+
options.rakelib = []
|
230
|
+
load_rakefile
|
231
|
+
end
|
232
|
+
assert_equal "__STD_SYS_DIR__", @app.system_dir
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
def test_windows
|
237
|
+
assert ! (@app.windows? && @app.unix?)
|
238
|
+
end
|
239
|
+
|
240
|
+
def test_loading_imports
|
241
|
+
mock = flexmock("loader")
|
242
|
+
mock.should_receive(:load).with("x.dummy").once
|
243
|
+
@app.instance_eval do
|
244
|
+
add_loader("dummy", mock)
|
245
|
+
add_import("x.dummy")
|
246
|
+
load_imports
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
def test_building_imported_files_on_demand
|
251
|
+
mock = flexmock("loader")
|
252
|
+
mock.should_receive(:load).with("x.dummy").once
|
253
|
+
mock.should_receive(:make_dummy).with_no_args.once
|
254
|
+
@app.instance_eval do
|
255
|
+
intern(Rake::Task, "x.dummy").enhance do mock.make_dummy end
|
256
|
+
add_loader("dummy", mock)
|
257
|
+
add_import("x.dummy")
|
258
|
+
load_imports
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
def test_handle_options_should_strip_options_from_ARGV
|
263
|
+
assert !@app.options.trace
|
264
|
+
|
265
|
+
valid_option = '--trace'
|
266
|
+
ARGV.clear
|
267
|
+
ARGV << valid_option
|
268
|
+
|
269
|
+
@app.handle_options
|
270
|
+
|
271
|
+
assert !ARGV.include?(valid_option)
|
272
|
+
assert @app.options.trace
|
273
|
+
end
|
274
|
+
|
275
|
+
def test_good_run
|
276
|
+
ran = false
|
277
|
+
ARGV.clear
|
278
|
+
ARGV << '--rakelib=""'
|
279
|
+
@app.options.silent = true
|
280
|
+
@app.instance_eval do
|
281
|
+
intern(Rake::Task, "default").enhance { ran = true }
|
282
|
+
end
|
283
|
+
in_environment("PWD" => "test/data/default") do
|
284
|
+
@app.run
|
285
|
+
end
|
286
|
+
assert ran
|
287
|
+
end
|
288
|
+
|
289
|
+
def test_display_task_run
|
290
|
+
ran = false
|
291
|
+
ARGV.clear
|
292
|
+
ARGV << '-f' << '-s' << '--tasks' << '--rakelib=""'
|
293
|
+
@app.last_description = "COMMENT"
|
294
|
+
@app.define_task(Rake::Task, "default")
|
295
|
+
out, = capture_io { @app.run }
|
296
|
+
assert @app.options.show_tasks
|
297
|
+
assert ! ran
|
298
|
+
assert_match(/rake default/, out)
|
299
|
+
assert_match(/# COMMENT/, out)
|
300
|
+
end
|
301
|
+
|
302
|
+
def test_display_prereqs
|
303
|
+
ran = false
|
304
|
+
ARGV.clear
|
305
|
+
ARGV << '-f' << '-s' << '--prereqs' << '--rakelib=""'
|
306
|
+
@app.last_description = "COMMENT"
|
307
|
+
t = @app.define_task(Rake::Task, "default")
|
308
|
+
t.enhance([:a, :b])
|
309
|
+
@app.define_task(Rake::Task, "a")
|
310
|
+
@app.define_task(Rake::Task, "b")
|
311
|
+
out, = capture_io { @app.run }
|
312
|
+
assert @app.options.show_prereqs
|
313
|
+
assert ! ran
|
314
|
+
assert_match(/rake a$/, out)
|
315
|
+
assert_match(/rake b$/, out)
|
316
|
+
assert_match(/rake default\n( *(a|b)\n){2}/m, out)
|
317
|
+
end
|
318
|
+
|
319
|
+
def test_bad_run
|
320
|
+
@app.intern(Rake::Task, "default").enhance { fail }
|
321
|
+
ARGV.clear
|
322
|
+
ARGV << '-f' << '-s' << '--rakelib=""'
|
323
|
+
assert_raises(SystemExit) {
|
324
|
+
_, err = capture_io { @app.run }
|
325
|
+
assert_match(/see full trace/, err)
|
326
|
+
}
|
327
|
+
ensure
|
328
|
+
ARGV.clear
|
329
|
+
end
|
330
|
+
|
331
|
+
def test_bad_run_with_trace
|
332
|
+
@app.intern(Rake::Task, "default").enhance { fail }
|
333
|
+
ARGV.clear
|
334
|
+
ARGV << '-f' << '-s' << '-t'
|
335
|
+
assert_raises(SystemExit) {
|
336
|
+
_, err = capture_io { @app.run }
|
337
|
+
refute_match(/see full trace/, err)
|
338
|
+
}
|
339
|
+
ensure
|
340
|
+
ARGV.clear
|
341
|
+
end
|
342
|
+
|
343
|
+
def test_run_with_bad_options
|
344
|
+
@app.intern(Rake::Task, "default").enhance { fail }
|
345
|
+
ARGV.clear
|
346
|
+
ARGV << '-f' << '-s' << '--xyzzy'
|
347
|
+
assert_raises(SystemExit) {
|
348
|
+
capture_io { @app.run }
|
349
|
+
}
|
350
|
+
ensure
|
351
|
+
ARGV.clear
|
352
|
+
end
|
353
|
+
|
354
|
+
def test_deprecation_message
|
355
|
+
in_environment do
|
356
|
+
_, err = capture_io do
|
357
|
+
@app.deprecate("a", "b", "c")
|
358
|
+
end
|
359
|
+
assert_match(/'a' is deprecated/i, err)
|
360
|
+
assert_match(/use 'b' instead/i, err)
|
361
|
+
assert_match(/at c$/i, err)
|
362
|
+
end
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|