2010-03-31 11:05:24 +04:00
|
|
|
require 'tmpdir'
|
|
|
|
require 'fileutils'
|
2009-10-02 23:07:55 +04:00
|
|
|
require 'test/unit'
|
|
|
|
require 'rake/packagetask'
|
|
|
|
|
2009-10-03 17:37:52 +04:00
|
|
|
class Rake::TestPackageTask < Test::Unit::TestCase
|
2009-10-02 23:07:55 +04:00
|
|
|
include Rake
|
|
|
|
|
|
|
|
def test_create
|
2010-03-31 11:05:24 +04:00
|
|
|
pwd = Dir.pwd
|
|
|
|
tmpdir = Dir.mktmpdir("rake")
|
|
|
|
Dir.chdir(tmpdir)
|
|
|
|
Dir.mkdir("bin")
|
|
|
|
open("bin/rake", "wb") {}
|
2009-10-02 23:07:55 +04:00
|
|
|
pkg = Rake::PackageTask.new("pkgr", "1.2.3") { |p|
|
|
|
|
p.package_files << "install.rb"
|
|
|
|
p.package_files.include(
|
|
|
|
'[A-Z]*',
|
|
|
|
'bin/**/*',
|
|
|
|
'lib/**/*.rb',
|
|
|
|
'test/**/*.rb',
|
|
|
|
'doc/**/*',
|
|
|
|
'build/rubyapp.rb',
|
|
|
|
'*.blurb')
|
|
|
|
p.package_files.exclude(/\bCVS\b/)
|
|
|
|
p.package_files.exclude(/~$/)
|
|
|
|
p.package_dir = 'pkg'
|
|
|
|
p.need_tar = true
|
|
|
|
p.need_tar_gz = true
|
|
|
|
p.need_tar_bz2 = true
|
|
|
|
p.need_zip = true
|
|
|
|
}
|
|
|
|
assert_equal "pkg", pkg.package_dir
|
|
|
|
assert pkg.package_files.include?("bin/rake")
|
|
|
|
assert "pkgr", pkg.name
|
|
|
|
assert "1.2.3", pkg.version
|
|
|
|
assert Task[:package]
|
|
|
|
assert Task['pkg/pkgr-1.2.3.tgz']
|
|
|
|
assert Task['pkg/pkgr-1.2.3.tar.gz']
|
|
|
|
assert Task['pkg/pkgr-1.2.3.tar.bz2']
|
|
|
|
assert Task['pkg/pkgr-1.2.3.zip']
|
|
|
|
assert Task["pkg/pkgr-1.2.3"]
|
|
|
|
assert Task[:clobber_package]
|
|
|
|
assert Task[:repackage]
|
2010-03-31 11:05:24 +04:00
|
|
|
ensure
|
|
|
|
Dir.chdir(pwd)
|
|
|
|
FileUtils.rm_rf(tmpdir)
|
2009-10-02 23:07:55 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_missing_version
|
|
|
|
assert_raise(RuntimeError) {
|
|
|
|
pkg = Rake::PackageTask.new("pkgr") { |p| }
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_no_version
|
|
|
|
pkg = Rake::PackageTask.new("pkgr", :noversion) { |p| }
|
|
|
|
assert "pkgr", pkg.send(:package_name)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_clone
|
|
|
|
pkg = Rake::PackageTask.new("x", :noversion)
|
|
|
|
p2 = pkg.clone
|
|
|
|
pkg.package_files << "y"
|
|
|
|
p2.package_files << "x"
|
|
|
|
assert_equal ["y"], pkg.package_files
|
|
|
|
assert_equal ["x"], p2.package_files
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
require 'rake/gempackagetask'
|
|
|
|
|
2009-10-03 17:37:52 +04:00
|
|
|
class Rake::TestGemPackageTask < Test::Unit::TestCase
|
2009-10-02 23:07:55 +04:00
|
|
|
def test_gem_package
|
|
|
|
gem = Gem::Specification.new do |g|
|
|
|
|
g.name = "pkgr"
|
|
|
|
g.version = "1.2.3"
|
|
|
|
g.files = FileList["x"].resolve
|
|
|
|
end
|
|
|
|
pkg = Rake::GemPackageTask.new(gem) do |p|
|
|
|
|
p.package_files << "y"
|
|
|
|
end
|
|
|
|
assert_equal ["x", "y"], pkg.package_files
|
|
|
|
assert_equal "pkgr-1.2.3.gem", pkg.gem_file
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_gem_package_with_current_platform
|
|
|
|
gem = Gem::Specification.new do |g|
|
|
|
|
g.name = "pkgr"
|
|
|
|
g.version = "1.2.3"
|
|
|
|
g.files = FileList["x"].resolve
|
|
|
|
g.platform = Gem::Platform::CURRENT
|
|
|
|
end
|
|
|
|
pkg = Rake::GemPackageTask.new(gem) do |p|
|
|
|
|
p.package_files << "y"
|
|
|
|
end
|
|
|
|
assert_equal ["x", "y"], pkg.package_files
|
|
|
|
assert_match(/^pkgr-1\.2\.3-(\S+)\.gem$/, pkg.gem_file)
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_gem_package_with_ruby_platform
|
|
|
|
gem = Gem::Specification.new do |g|
|
|
|
|
g.name = "pkgr"
|
|
|
|
g.version = "1.2.3"
|
|
|
|
g.files = FileList["x"].resolve
|
|
|
|
g.platform = Gem::Platform::RUBY
|
|
|
|
end
|
|
|
|
pkg = Rake::GemPackageTask.new(gem) do |p|
|
|
|
|
p.package_files << "y"
|
|
|
|
end
|
|
|
|
assert_equal ["x", "y"], pkg.package_files
|
|
|
|
assert_equal "pkgr-1.2.3.gem", pkg.gem_file
|
|
|
|
end
|
|
|
|
end
|