summaryrefslogtreecommitdiff
path: root/test/rake
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-06 09:31:37 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-06 09:31:37 +0000
commitf6d2b4858891376dec83e43dccfa028d4b32b184 (patch)
tree053f00bd120e730616a371793eb579edddba29e4 /test/rake
parent6057695c87cf8281f3ff9aa37cfdf1c317e1f9c1 (diff)
* lib/rake.rb, lib/rake/*, test/rake/*: Update latest rake master(e47d023)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rake')
-rw-r--r--test/rake/helper.rb10
-rw-r--r--test/rake/test_rake_directory_task.rb13
-rw-r--r--test/rake/test_rake_file_list.rb28
-rw-r--r--test/rake/test_rake_file_task.rb15
-rw-r--r--test/rake/test_rake_pathname_extensions.rb15
-rw-r--r--test/rake/test_rake_task_argument_parsing.rb10
6 files changed, 87 insertions, 4 deletions
diff --git a/test/rake/helper.rb b/test/rake/helper.rb
index 74cab7559f..992c6bffae 100644
--- a/test/rake/helper.rb
+++ b/test/rake/helper.rb
@@ -2,7 +2,7 @@ require 'rubygems'
$:.unshift File.expand_path('../../lib', __FILE__)
begin
- gem 'minitest'
+ gem 'minitest', '~> 4'
rescue Gem::LoadError
end
@@ -11,13 +11,15 @@ require 'rake'
require 'tmpdir'
require File.expand_path('../file_creation', __FILE__)
-require_relative 'support/ruby_runner'
-require_relative 'support/rakefile_definitions'
begin
require_relative '../ruby/envutil'
+ require_relative 'support/ruby_runner'
+ require_relative 'support/rakefile_definitions'
rescue NoMethodError, LoadError
- # for ruby trunk
+ # ruby 1.8
+ require 'test/support/ruby_runner'
+ require 'test/support/rakefile_definitions'
end
class Rake::TestCase < MiniTest::Unit::TestCase
diff --git a/test/rake/test_rake_directory_task.rb b/test/rake/test_rake_directory_task.rb
index c8275e6d10..0014d1c158 100644
--- a/test/rake/test_rake_directory_task.rb
+++ b/test/rake/test_rake_directory_task.rb
@@ -1,5 +1,6 @@
require File.expand_path('../helper', __FILE__)
require 'fileutils'
+require 'pathname'
class TestRakeDirectoryTask < Rake::TestCase
include Rake
@@ -60,4 +61,16 @@ class TestRakeDirectoryTask < Rake::TestCase
assert_equal ["t2", "a/b/c"], runlist
assert File.directory?("a/b/c")
end
+
+ def test_can_use_pathname
+ directory Pathname.new "a/b/c"
+
+ assert_equal FileCreationTask, Task["a/b/c"].class
+
+ verbose(false) {
+ Task['a/b/c'].invoke
+ }
+
+ assert File.directory?("a/b/c")
+ end
end
diff --git a/test/rake/test_rake_file_list.rb b/test/rake/test_rake_file_list.rb
index 899f3bc509..c1b4c92086 100644
--- a/test/rake/test_rake_file_list.rb
+++ b/test/rake/test_rake_file_list.rb
@@ -1,4 +1,5 @@
require File.expand_path('../helper', __FILE__)
+require 'pathname'
class TestRakeFileList < Rake::TestCase
FileList = Rake::FileList
@@ -46,6 +47,12 @@ class TestRakeFileList < Rake::TestCase
fl.sort
end
+ def test_create_with_pathname
+ fl = FileList.new(Pathname.new("*.c"))
+ assert_equal ["abc.c", "x.c", "xyz.c"].sort,
+ fl.sort
+ end
+
def test_create_with_block
fl = FileList.new { |f| f.include("x") }
assert_equal ["x"], fl.resolve
@@ -74,12 +81,24 @@ class TestRakeFileList < Rake::TestCase
fl.sort
end
+ def test_include_with_pathname
+ fl = FileList.new.include(Pathname.new("*.c"))
+ assert_equal ["abc.c", "x.c", "xyz.c"].sort,
+ fl.sort
+ end
+
def test_append
fl = FileList.new
fl << "a.rb" << "b.rb"
assert_equal ['a.rb', 'b.rb'], fl
end
+ def test_append_pathname
+ fl = FileList.new
+ fl << Pathname.new("a.rb")
+ assert_equal ['a.rb'], fl
+ end
+
def test_add_many
fl = FileList.new
fl.include %w(a d c)
@@ -163,6 +182,15 @@ class TestRakeFileList < Rake::TestCase
assert_equal [], fl
end
+ def test_exclude_pathname
+ fl = FileList['x.c', 'abc.c', 'other']
+ fl.each { |fn| touch fn, :verbose => false }
+
+ fl.exclude(Pathname.new('*.c'))
+
+ assert_equal ['other'], fl
+ end
+
def test_excluding_via_block
fl = FileList['a.c', 'b.c', 'xyz.c']
fl.exclude { |fn| fn.pathmap('%n') == 'xyz' }
diff --git a/test/rake/test_rake_file_task.rb b/test/rake/test_rake_file_task.rb
index ae828c9ba1..a6a9fa2c51 100644
--- a/test/rake/test_rake_file_task.rb
+++ b/test/rake/test_rake_file_task.rb
@@ -1,5 +1,6 @@
require File.expand_path('../helper', __FILE__)
require 'fileutils'
+require 'pathname'
class TestRakeFileTask < Rake::TestCase
include Rake
@@ -162,6 +163,20 @@ class TestRakeFileTask < Rake::TestCase
assert_equal ["preqA", "preqB"], t.sources
end
+ def test_task_can_be_pathname
+ name = "dummy"
+ file Pathname.new name
+
+ ftask = Task[name]
+
+ assert_equal name.to_s, ftask.name
+ end
+
+ def test_prerequisite_can_be_pathname
+ t = file :f => Pathname.new("preq")
+ assert_equal "preq", t.source
+ end
+
# I have currently disabled this test. I'm not convinced that
# deleting the file target on failure is always the proper thing to
# do. I'm willing to hear input on this topic.
diff --git a/test/rake/test_rake_pathname_extensions.rb b/test/rake/test_rake_pathname_extensions.rb
new file mode 100644
index 0000000000..7da702d0c7
--- /dev/null
+++ b/test/rake/test_rake_pathname_extensions.rb
@@ -0,0 +1,15 @@
+require File.expand_path('../helper', __FILE__)
+require 'rake/ext/pathname'
+
+class TestRakePathnameExtensions < Rake::TestCase
+ def test_ext_works_on_pathnames
+ pathname = Pathname.new("abc.foo")
+ assert_equal Pathname.new("abc.bar"), pathname.ext("bar")
+ end
+
+ def test_path_map_works_on_pathnames
+ pathname = Pathname.new("this/is/a/dir/abc.rb")
+ assert_equal Pathname.new("abc.rb"), pathname.pathmap("%f")
+ assert_equal Pathname.new("this/is/a/dir"), pathname.pathmap("%d")
+ end
+end
diff --git a/test/rake/test_rake_task_argument_parsing.rb b/test/rake/test_rake_task_argument_parsing.rb
index 0294a9fb2c..3cb5d9cfe3 100644
--- a/test/rake/test_rake_task_argument_parsing.rb
+++ b/test/rake/test_rake_task_argument_parsing.rb
@@ -49,6 +49,16 @@ class TestRakeTaskArgumentParsing < Rake::TestCase
assert_equal ["one", "two", "three_a, three_b", "four"], args
end
+ def test_treat_blank_arg_as_empty_string
+ name, args = @app.parse_task_string("name[one,]")
+ assert_equal "name", name
+ assert_equal ["one", ""], args
+
+ name, args = @app.parse_task_string("name[one,,two]")
+ assert_equal "name", name
+ assert_equal ["one", "", "two"], args
+ end
+
def test_terminal_width_using_env
app = Rake::Application.new
app.terminal_columns = 1234