rake 0.9.0.beta.4 → 0.9.0.beta.5

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/Rakefile CHANGED
@@ -106,16 +106,28 @@ end
106
106
 
107
107
  begin
108
108
  require 'rcov/rcovtask'
109
+ IGNORE_COVERAGE_IN = FileList[
110
+ 'lib/rake/rdoctask.rb',
111
+ 'lib/rake/testtask.rb',
112
+ 'lib/rake/packagetask.rb',
113
+ 'lib/rake/clean.rb',
114
+ ]
115
+
116
+ unless File::ALT_SEPARATOR
117
+ IGNORE_COVERAGE_IN.include(
118
+ 'lib/rake/alt_system.rb',
119
+ 'lib/rake/win32.rb')
120
+ end
109
121
 
110
122
  Rcov::RcovTask.new do |t|
111
123
  t.libs << "test"
112
- dot_rakes =
113
124
  t.rcov_opts = [
114
125
  '-xRakefile', '-xrakefile', '-xpublish.rf',
115
- '-xlib/rake/contrib', '-x/Library',
126
+ '-xlib/rake/contrib', '-x/Library', '-x.rvm',
116
127
  '--text-report',
117
128
  '--sort coverage'
118
- ] + FileList['rakelib/*.rake'].pathmap("-x%p")
129
+ ] + FileList['rakelib/*.rake'].pathmap("-x%p") +
130
+ IGNORE_COVERAGE_IN.map { |fn| "-x#{fn}" }
119
131
  t.test_files = FileList[
120
132
  'test/lib/*_test.rb',
121
133
  'test/contrib/*_test.rb',
@@ -248,7 +260,7 @@ else
248
260
  # end
249
261
  end
250
262
 
251
- package_task = Gem::PackageTask.new(SPEC) do |pkg|
263
+ Gem::PackageTask.new(SPEC) do |pkg|
252
264
  pkg.need_zip = true
253
265
  pkg.need_tar = true
254
266
  end
@@ -56,7 +56,6 @@ require 'rake/early_time'
56
56
  require 'rake/name_space'
57
57
  require 'rake/task_manager'
58
58
  require 'rake/application'
59
- require 'rake/environment'
60
59
 
61
60
  $trace = false
62
61
 
@@ -449,7 +449,7 @@ module Rake
449
449
  paths.each do |path|
450
450
  full_path = File.join(path, fn)
451
451
  if File.exist?(full_path)
452
- Rake::Environment.load_rakefile(full_path)
452
+ Rake.load_rakefile(full_path)
453
453
  loaded << fn
454
454
  return true
455
455
  end
@@ -492,7 +492,7 @@ module Rake
492
492
  Dir.chdir(location)
493
493
  print_rakefile_directory(location)
494
494
  $rakefile = @rakefile if options.classic_namespace
495
- Rake::Environment.load_rakefile(File.expand_path(@rakefile)) if @rakefile && @rakefile != ''
495
+ Rake.load_rakefile(File.expand_path(@rakefile)) if @rakefile && @rakefile != ''
496
496
  options.rakelib.each do |rlib|
497
497
  glob("#{rlib}/*.rake") do |name|
498
498
  add_import name
@@ -13,21 +13,19 @@
13
13
 
14
14
  require 'rake'
15
15
 
16
- Rake::DSL.environment do
17
- CLEAN = Rake::FileList["**/*~", "**/*.bak", "**/core"]
18
- CLEAN.clear_exclude.exclude { |fn|
19
- fn.pathmap("%f") == 'core' && File.directory?(fn)
20
- }
16
+ CLEAN = Rake::FileList["**/*~", "**/*.bak", "**/core"]
17
+ CLEAN.clear_exclude.exclude { |fn|
18
+ fn.pathmap("%f") == 'core' && File.directory?(fn)
19
+ }
21
20
 
22
- desc "Remove any temporary products."
23
- task :clean do
24
- CLEAN.each { |fn| rm_r fn rescue nil }
25
- end
21
+ desc "Remove any temporary products."
22
+ task :clean do
23
+ CLEAN.each { |fn| rm_r fn rescue nil }
24
+ end
26
25
 
27
- CLOBBER = Rake::FileList.new
26
+ CLOBBER = Rake::FileList.new
28
27
 
29
- desc "Remove any generated file."
30
- task :clobber => [:clean] do
31
- CLOBBER.each { |fn| rm_r fn rescue nil }
32
- end
28
+ desc "Remove any generated file."
29
+ task :clobber => [:clean] do
30
+ CLOBBER.each { |fn| rm_r fn rescue nil }
33
31
  end
@@ -3,7 +3,7 @@ module Rake
3
3
  # Default Rakefile loader used by +import+.
4
4
  class DefaultLoader
5
5
  def load(fn)
6
- Rake::Environment.load_rakefile(File.expand_path(fn))
6
+ Rake.load_rakefile(File.expand_path(fn))
7
7
  end
8
8
  end
9
9
 
@@ -20,6 +20,10 @@ module Rake
20
20
  application.original_dir
21
21
  end
22
22
 
23
+ # Load a rakefile.
24
+ def load_rakefile(path)
25
+ load(path)
26
+ end
23
27
  end
24
28
 
25
29
  end
@@ -238,8 +238,7 @@ module Rake
238
238
  end
239
239
 
240
240
  def trace_rule(level, message)
241
- $stderr.puts "#{" "*level}#{message}" if
242
- Rake.application.options.trace_rules
241
+ $stderr.puts "#{" "*level}#{message}" if Rake.application.options.trace_rules
243
242
  end
244
243
 
245
244
  # Attempt to create a rule given the list of prerequisites.
@@ -266,7 +265,7 @@ module Rake
266
265
  # Make a list of sources from the list of file name extensions /
267
266
  # translation procs.
268
267
  def make_sources(task_name, extensions)
269
- extensions.collect { |ext|
268
+ result = extensions.collect { |ext|
270
269
  case ext
271
270
  when /%/
272
271
  task_name.pathmap(ext)
@@ -285,7 +284,8 @@ module Rake
285
284
  else
286
285
  fail "Don't know how to handle rule dependent: #{ext.inspect}"
287
286
  end
288
- }.flatten
287
+ }
288
+ result.flatten
289
289
  end
290
290
 
291
291
 
@@ -103,7 +103,12 @@ module Rake
103
103
  end
104
104
 
105
105
  def option_list # :nodoc:
106
- ENV['TESTOPTS'] || @options || ""
106
+ (ENV['TESTOPTS'] ||
107
+ ENV['TESTOPT'] ||
108
+ ENV['TEST_OPTS'] ||
109
+ ENV['TEST_OPT'] ||
110
+ @options ||
111
+ "")
107
112
  end
108
113
 
109
114
  def ruby_opts_string
@@ -5,7 +5,7 @@ module Rake
5
5
  MINOR = 9,
6
6
  BUILD = 0,
7
7
  BETA = 'beta',
8
- BETANUM = 4,
8
+ BETANUM = 5,
9
9
  ]
10
10
  end
11
11
  VERSION = Version::NUMBERS.join('.')
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'test/unit'
4
- require 'test/filecreation'
4
+ require 'test/file_creation'
5
5
  begin
6
6
  old_verbose = $VERBOSE
7
7
  $VERBOSE = nil
@@ -1,5 +1,4 @@
1
- Rake::DSL.environment do
2
- task :default do
3
- puts "TEST1"
4
- end
1
+
2
+ task :default do
3
+ puts "TEST1"
5
4
  end
@@ -5,13 +5,16 @@ module FileCreation
5
5
  NEWFILE = "testdata/new"
6
6
 
7
7
  def create_timed_files(oldfile, *newfiles)
8
- return if File.exist?(oldfile) && newfiles.all? { |newfile| File.exist?(newfile) }
9
- old_time = create_file(oldfile)
8
+ return if (File.exist?(oldfile) &&
9
+ newfiles.all? { |newfile|
10
+ File.exist?(newfile) && File.stat(newfile).mtime > File.stat(oldfile).mtime
11
+ })
12
+ now = Time.now
13
+
14
+ create_file(oldfile, now - 60)
15
+
10
16
  newfiles.each do |newfile|
11
- while create_file(newfile) <= old_time
12
- sleep(0.1)
13
- File.delete(newfile) rescue nil
14
- end
17
+ create_file(newfile, now)
15
18
  end
16
19
  end
17
20
 
@@ -20,9 +23,10 @@ module FileCreation
20
23
  File.stat(dirname).mtime
21
24
  end
22
25
 
23
- def create_file(name)
26
+ def create_file(name, file_time=nil)
24
27
  create_dir(File.dirname(name))
25
28
  FileUtils.touch(name) unless File.exist?(name)
29
+ File.utime(file_time, file_time, name) unless file_time.nil?
26
30
  File.stat(name).mtime
27
31
  end
28
32
 
@@ -33,10 +33,10 @@ class TestApplication < Test::Unit::TestCase
33
33
  end
34
34
 
35
35
  def test_constant_warning
36
- err = capture_stderr do @app.instance_eval { const_warning("Task") } end
37
- assert_match(/warning/i, err)
38
- assert_match(/deprecated/i, err)
39
- assert_match(/Task/i, err)
36
+ error_messages = capture_stderr do @app.instance_eval { const_warning("Task") } end
37
+ assert_match(/warning/i, error_messages)
38
+ assert_match(/deprecated/i, error_messages)
39
+ assert_match(/Task/i, error_messages)
40
40
  end
41
41
 
42
42
  def test_display_tasks
@@ -155,14 +155,14 @@ class TestApplication < Test::Unit::TestCase
155
155
 
156
156
  def test_load_rakefile_doesnt_print_rakefile_directory_from_same_dir
157
157
  in_environment("PWD" => "test/data/unittest") do
158
- err = capture_stderr do
158
+ error_messages = capture_stderr do
159
159
  @app.instance_eval do
160
160
  @original_dir = File.expand_path(".") # pretend we started from the unittest dir
161
161
  raw_load_rakefile
162
162
  end
163
163
  end
164
164
  _, location = @app.find_rakefile_location
165
- assert_no_match(/\(in #{location}\)/, err)
165
+ assert_no_match(/\(in #{location}\)/, error_messages)
166
166
  end
167
167
  end
168
168
 
@@ -180,19 +180,19 @@ class TestApplication < Test::Unit::TestCase
180
180
 
181
181
  def test_load_rakefile_prints_rakefile_directory_from_subdir
182
182
  in_environment("PWD" => "test/data/unittest/subdir") do
183
- err = capture_stderr do
183
+ error_messages = capture_stderr do
184
184
  @app.instance_eval do
185
185
  raw_load_rakefile
186
186
  end
187
187
  end
188
188
  _, location = @app.find_rakefile_location
189
- assert_match(/\(in #{location}\)/, err)
189
+ assert_match(/\(in #{location}\)/, error_messages)
190
190
  end
191
191
  end
192
192
 
193
193
  def test_load_rakefile_doesnt_print_rakefile_directory_from_subdir_if_silent
194
194
  in_environment("PWD" => "test/data/unittest/subdir") do
195
- err = capture_stderr do
195
+ error_messages = capture_stderr do
196
196
  @app.instance_eval do
197
197
  handle_options
198
198
  options.silent = true
@@ -200,7 +200,7 @@ class TestApplication < Test::Unit::TestCase
200
200
  end
201
201
  end
202
202
  _, location = @app.find_rakefile_location
203
- assert_no_match(/\(in #{location}\)/, err)
203
+ assert_no_match(/\(in #{location}\)/, error_messages)
204
204
  end
205
205
  end
206
206
 
@@ -232,6 +232,21 @@ class TestApplication < Test::Unit::TestCase
232
232
  end
233
233
  end
234
234
 
235
+ def test_load_from_calculated_system_rakefile
236
+ flexmock(@app, :standard_system_dir => "__STD_SYS_DIR__")
237
+ in_environment('RAKE_SYSTEM' => nil) do
238
+ @app.options.rakelib = []
239
+ @app.instance_eval do
240
+ handle_options
241
+ options.silent = true
242
+ options.load_system = true
243
+ options.rakelib = []
244
+ load_rakefile
245
+ end
246
+ assert_equal "__STD_SYS_DIR__", @app.system_dir
247
+ end
248
+ end
249
+
235
250
  def test_windows
236
251
  assert ! (@app.windows? && @app.unix?)
237
252
  end
@@ -320,8 +335,8 @@ class TestApplication < Test::Unit::TestCase
320
335
  ARGV.clear
321
336
  ARGV << '-f' << '-s' << '--rakelib=""'
322
337
  assert_exception(SystemExit) {
323
- err = capture_stderr { @app.run }
324
- assert_match(/see full trace/, err)
338
+ error_messages = capture_stderr { @app.run }
339
+ assert_match(/see full trace/, error_messages)
325
340
  }
326
341
  ensure
327
342
  ARGV.clear
@@ -332,8 +347,8 @@ class TestApplication < Test::Unit::TestCase
332
347
  ARGV.clear
333
348
  ARGV << '-f' << '-s' << '-t'
334
349
  assert_exception(SystemExit) {
335
- err = capture_stderr { capture_stdout { @app.run } }
336
- assert_no_match(/see full trace/, err)
350
+ error_messages = capture_stderr { capture_stdout { @app.run } }
351
+ assert_no_match(/see full trace/, error_messages)
337
352
  }
338
353
  ensure
339
354
  ARGV.clear
@@ -349,6 +364,17 @@ class TestApplication < Test::Unit::TestCase
349
364
  ensure
350
365
  ARGV.clear
351
366
  end
367
+
368
+ def test_deprecation_message
369
+ in_environment do
370
+ error_messages = capture_stderr do
371
+ @app.deprecate("a", "b", "c")
372
+ end
373
+ assert_match(/'a' is deprecated/i, error_messages)
374
+ assert_match(/use 'b' instead/i, error_messages)
375
+ assert_match(/at c$/i, error_messages)
376
+ end
377
+ end
352
378
  end
353
379
 
354
380
 
@@ -596,7 +622,28 @@ class TestApplicationOptions < Test::Unit::TestCase
596
622
  end
597
623
  flags(['--tasks', 'xyz'], ['-Txyz']) do |opts|
598
624
  assert_equal :tasks, opts.show_tasks
599
- assert_equal(/xyz/, opts.show_task_pattern)
625
+ assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s)
626
+ end
627
+ end
628
+ end
629
+
630
+ def test_where
631
+ in_environment do
632
+ flags('--where', '-W') do |opts|
633
+ assert_equal :lines, opts.show_tasks
634
+ assert_equal(//.to_s, opts.show_task_pattern.to_s)
635
+ end
636
+ flags(['--where', 'xyz'], ['-Wxyz']) do |opts|
637
+ assert_equal :lines, opts.show_tasks
638
+ assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s)
639
+ end
640
+ end
641
+ end
642
+
643
+ def test_no_deprecated_messages
644
+ in_environment do
645
+ flags('--no-deprecation-warnings', '-X') do |opts|
646
+ assert opts.ignore_deprecate
600
647
  end
601
648
  end
602
649
  end
@@ -622,7 +669,7 @@ class TestApplicationOptions < Test::Unit::TestCase
622
669
 
623
670
  def test_classic_namespace
624
671
  in_environment do
625
- error_output = capture_stderr do
672
+ error_messages = capture_stderr do
626
673
  flags(['--classic-namespace'], ['-C', '-T', '-P', '-n', '-s', '-t']) do |opts|
627
674
  assert opts.classic_namespace
628
675
  assert_equal opts.show_tasks, $show_tasks
@@ -632,13 +679,13 @@ class TestApplicationOptions < Test::Unit::TestCase
632
679
  assert_equal opts.silent, $silent
633
680
  end
634
681
  end
635
- assert_match(/deprecated/, error_output)
682
+ assert_match(/deprecated/, error_messages)
636
683
  end
637
684
  end
638
685
 
639
686
  def test_bad_option
640
687
  in_environment do
641
- error_output = capture_stderr do
688
+ error_messages = capture_stderr do
642
689
  ex = assert_exception(OptionParser::InvalidOption) do
643
690
  flags('--bad-option')
644
691
  end
@@ -649,7 +696,7 @@ class TestApplicationOptions < Test::Unit::TestCase
649
696
  assert_match(/--bad-option/, ex.message)
650
697
  end
651
698
  end
652
- assert_equal '', error_output
699
+ assert_equal '', error_messages
653
700
  end
654
701
  end
655
702
 
@@ -3,7 +3,7 @@
3
3
  require 'test/unit'
4
4
  require 'fileutils'
5
5
  require 'rake'
6
- require 'test/filecreation'
6
+ require 'test/file_creation'
7
7
  require 'test/rake_test_setup'
8
8
 
9
9
  ######################################################################
@@ -3,7 +3,7 @@
3
3
  require 'test/unit'
4
4
  require 'fileutils'
5
5
  require 'rake'
6
- require 'test/filecreation'
6
+ require 'test/file_creation'
7
7
 
8
8
  ######################################################################
9
9
  class TestFileCreationTask < Test::Unit::TestCase
@@ -3,7 +3,7 @@
3
3
  require 'test/unit'
4
4
  require 'fileutils'
5
5
  require 'rake'
6
- require 'test/filecreation'
6
+ require 'test/file_creation'
7
7
  require 'test/rake_test_setup'
8
8
 
9
9
  ######################################################################
@@ -347,6 +347,16 @@ class TestFileList < Test::Unit::TestCase
347
347
  assert_match(/files\.egrep/, found[2])
348
348
  end
349
349
 
350
+ def test_egrep_with_error
351
+ files = FileList['test/lib/*_test.rb']
352
+ error_messages = capture_stderr do
353
+ files.egrep(/ANYTHING/) do |fn, ln, line |
354
+ fail "_EGREP_FAILURE_"
355
+ end
356
+ end
357
+ assert_match(/_EGREP_FAILURE_/, error_messages)
358
+ end
359
+
350
360
  def test_existing
351
361
  fl = FileList['testdata/abc.c', 'testdata/notthere.c']
352
362
  assert_equal ["testdata/abc.c"], fl.existing
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'rake'
4
4
  require 'test/unit'
5
- require 'test/filecreation'
5
+ require 'test/file_creation'
6
6
  require 'fileutils'
7
7
  require 'stringio'
8
8
  require 'test/rake_test_setup'
@@ -3,7 +3,7 @@
3
3
  require 'test/unit'
4
4
  require 'fileutils'
5
5
  require 'rake'
6
- require 'test/filecreation'
6
+ require 'test/file_creation'
7
7
  require 'test/rake_test_setup'
8
8
 
9
9
  ######################################################################
@@ -41,6 +41,12 @@ class TestTopLevelFunctions < Test::Unit::TestCase
41
41
  Rake.import('x', 'y', 'z')
42
42
  end
43
43
 
44
+ def test_deprecated_import
45
+ Rake.application.should_receive(:add_import).with("x").once.ordered
46
+ error_messages = capture_stderr { import('x') }
47
+ assert_match(/deprecated/, error_messages)
48
+ end
49
+
44
50
  def test_when_writing
45
51
  out = capture_stdout do
46
52
  when_writing("NOTWRITING") do
@@ -8,7 +8,7 @@ rescue LoadError
8
8
  end
9
9
 
10
10
  require 'flexmock/test_unit'
11
- require 'test/filecreation'
11
+ require 'test/file_creation'
12
12
  require 'test/capture_stdout'
13
13
  require 'test/test_helper'
14
14
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rake
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 0.9.0.beta.4
5
+ version: 0.9.0.beta.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jim Weirich
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-06 00:00:00 -05:00
13
+ date: 2011-03-12 23:00:00 -05:00
14
14
  default_executable: rake
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -92,7 +92,6 @@ files:
92
92
  - lib/rake/dsl.rb
93
93
  - lib/rake/dsl_definition.rb
94
94
  - lib/rake/early_time.rb
95
- - lib/rake/environment.rb
96
95
  - lib/rake/ext/core.rb
97
96
  - lib/rake/ext/module.rb
98
97
  - lib/rake/ext/string.rb
@@ -132,7 +131,7 @@ files:
132
131
  - test/contrib/test_sys.rb
133
132
  - test/data/rakelib/test1.rb
134
133
  - test/data/rbext/rakefile.rb
135
- - test/filecreation.rb
134
+ - test/file_creation.rb
136
135
  - test/functional/functional_test.rb
137
136
  - test/functional/session_based_tests.rb
138
137
  - test/in_environment.rb
@@ -141,7 +140,6 @@ files:
141
140
  - test/lib/definitions_test.rb
142
141
  - test/lib/dsl_test.rb
143
142
  - test/lib/earlytime_test.rb
144
- - test/lib/environment_test.rb
145
143
  - test/lib/extension_test.rb
146
144
  - test/lib/file_creation_task_test.rb
147
145
  - test/lib/file_task_test.rb
@@ -1,40 +0,0 @@
1
- require 'rake/dsl_definition'
2
-
3
- module Rake
4
-
5
- # Rakefile are evaluated in the Rake::Environment module space. Top
6
- # level rake functions (e.g. :task, :file) are available in this
7
- # environment.
8
- module Environment
9
- extend Rake::DSL
10
-
11
- class << self
12
- # Load a rakefile from the given path. The Rakefile is loaded
13
- # in an environment that includes the Rake DSL methods.
14
- def load_rakefile(rakefile_path)
15
- rakefile = open(rakefile_path) { |f| f.read }
16
- load_string(rakefile, rakefile_path)
17
- end
18
-
19
- # Run a block of code in the Rake DSL environment.
20
- def run(&block)
21
- block.call
22
- end
23
-
24
- # Load a string of code in the Rake DSL environment. If the
25
- # string comes from a file, include the file path so that proper
26
- # line numbers references may be retained.
27
- def load_string(code, file_name=nil)
28
- eval(code, binding, file_name)
29
- end
30
- end
31
- end
32
-
33
- # Run the code block in an environment including the Rake DSL
34
- # commands.
35
- def DSL.environment(&block)
36
- Rake::Environment.run(&block)
37
- end
38
- end
39
-
40
-
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/test_helper'
4
- require 'rake/environment'
5
-
6
- class TestEnvironment < Test::Unit::TestCase
7
- def test_load_rakefile
8
- Rake::Task.clear
9
- Rake::Environment.load_rakefile("test/data/default/Rakefile")
10
- assert Rake::Task[:default], "Should have a default task"
11
- end
12
-
13
- def test_run
14
- Rake::Task.clear
15
- Rake::Environment.run do
16
- desc "demo comment"
17
- task :default
18
- end
19
- assert Rake::Task[:default], "Should have a default task"
20
- end
21
-
22
- def test_environment
23
- Rake::Task.clear
24
- Rake::DSL.environment do
25
- desc "demo comment"
26
- task :default
27
- end
28
- assert Rake::Task[:default], "Should have a default task"
29
- end
30
- end