aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-06-16 19:32:06 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-06-16 19:32:06 +0100
commita405f88556998958fb01f2eb5c202b8fccb84b59 (patch)
tree2df3df59dce8c3350911b27845cf033781e0c414
parent0d7936544c872dd0d462f55fbd83deb06ea8bcc1 (diff)
downloadpaludis-a405f88556998958fb01f2eb5c202b8fccb84b59.tar.gz
paludis-a405f88556998958fb01f2eb5c202b8fccb84b59.tar.xz
Don't use NoConfigEnvironment for tests
-rw-r--r--ruby/choice_TEST.rb4
-rwxr-xr-xruby/choice_TEST_setup.sh31
-rwxr-xr-xruby/demos/latest_stable.rb2
-rwxr-xr-xruby/demos/version_spec_distributions.rb20
-rw-r--r--ruby/environment_TEST.rb96
-rw-r--r--ruby/package_id_TEST.rb13
-rwxr-xr-xruby/package_id_TEST_setup.sh31
-rw-r--r--ruby/repository_TEST.rb11
8 files changed, 72 insertions, 136 deletions
diff --git a/ruby/choice_TEST.rb b/ruby/choice_TEST.rb
index 0432b06..782f367 100644
--- a/ruby/choice_TEST.rb
+++ b/ruby/choice_TEST.rb
@@ -18,6 +18,8 @@
# Place, Suite 330, Boston, MA 02111-1307 USA
#
+ENV["PALUDIS_HOME"] = Dir.getwd().to_s + "/choice_TEST_dir/home";
+
require 'test/unit'
require 'Paludis'
@@ -27,7 +29,7 @@ module Paludis
module TestStuff
def env
unless @env
- @env = NoConfigEnvironment.new("choice_TEST_dir/testrepo/", '/var/empty')
+ @env = EnvironmentFactory.instance.create("")
end
@env
end
diff --git a/ruby/choice_TEST_setup.sh b/ruby/choice_TEST_setup.sh
index 91886d3..e1ef9dd 100755
--- a/ruby/choice_TEST_setup.sh
+++ b/ruby/choice_TEST_setup.sh
@@ -4,6 +4,37 @@
mkdir choice_TEST_dir || exit 1
cd choice_TEST_dir || exit 1
+mkdir -p home/.paludis/repositories
+
+cat <<END > home/.paludis/repositories/testrepo.conf
+location = `pwd`/testrepo
+format = e
+names_cache = /var/empty
+cache = /var/empty
+profiles = \${location}/profiles/testprofile
+builddir = `pwd`
+END
+
+cat <<END > home/.paludis/repositories/installed.conf
+location = `pwd`/installed
+format = vdb
+names_cache = /var/empty
+cache = /var/empty
+builddir = `pwd`
+name = installed
+END
+
+cat <<END > home/.paludis/keywords.conf
+*/* test
+END
+cat <<END > home/.paludis/licenses.conf
+*/* *
+END
+
+cat <<END > home/.paludis/general.conf
+world = /dev/null
+END
+
mkdir -p testrepo/{eclass,distfiles,profiles/testprofile,foo/bar/files} || exit 1
cd testrepo || exit 1
echo "testrepo" > profiles/repo_name || exit 1
diff --git a/ruby/demos/latest_stable.rb b/ruby/demos/latest_stable.rb
index 1e7ab29..efcbe10 100755
--- a/ruby/demos/latest_stable.rb
+++ b/ruby/demos/latest_stable.rb
@@ -73,7 +73,7 @@ if ARGV.empty?
end
keywords = ARGV;
-env = NoConfigEnvironment.new(repository_dir, write_cache_dir, master_repository_dir)
+env = EnvironmentFactory.instance.create("")
def check_one_package(env, search_keywords, repo, pkg)
results = {}
diff --git a/ruby/demos/version_spec_distributions.rb b/ruby/demos/version_spec_distributions.rb
index 582a63a..3d3229f 100755
--- a/ruby/demos/version_spec_distributions.rb
+++ b/ruby/demos/version_spec_distributions.rb
@@ -67,15 +67,9 @@ opts = GetoptLong.new(
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
[ '--version', '-V', GetoptLong::NO_ARGUMENT ],
[ '--log-level', GetoptLong::REQUIRED_ARGUMENT ],
- [ '--repository-dir', '-D', GetoptLong::REQUIRED_ARGUMENT ],
- [ '--image', GetoptLong::REQUIRED_ARGUMENT ],
- [ '--write-cache-dir', GetoptLong::REQUIRED_ARGUMENT ],
[ '--master-repository-dir', GetoptLong::REQUIRED_ARGUMENT ])
output_image = nil
-repository_dir = Dir.getwd
-write_cache_dir = '/var/empty'
-master_repository_dir = ''
opts.each do | opt, arg |
case opt
@@ -87,9 +81,6 @@ opts.each do | opt, arg |
puts " --version Display program version"
puts
puts " --log-level level Set log level (debug, qa, warning, silent)"
- puts " --repository-dir dir Set repository directory (default: cwd)"
- puts " --write-cache-dir dir Use a subdirectory named for the repository name under the specified directory for repository write cache"
- puts " --master-repository-dir dir Use a subdirectory named for the repository name under the specified directory for repository write cache"
puts
puts " --image foo.png Output as the specified image rather than as text"
exit 0
@@ -113,15 +104,6 @@ opts.each do | opt, arg |
exit 1
end
- when '--repository-dir'
- repository_dir = arg
-
- when '--write-cache-dir'
- write_cache_dir = arg
-
- when '--master-repository-dir'
- master_repository_dir = arg
-
when '--image'
output_image = arg
@@ -129,7 +111,7 @@ opts.each do | opt, arg |
end
distribution = Distribution.new
-env = Paludis::NoConfigEnvironment.new repository_dir, write_cache_dir, master_repository_dir
+env = EnvironmentFactory.instance.create("")
env.repositories.each do | repo |
distribution.add_repository repo
end
diff --git a/ruby/environment_TEST.rb b/ruby/environment_TEST.rb
index a67dc3d..244c093 100644
--- a/ruby/environment_TEST.rb
+++ b/ruby/environment_TEST.rb
@@ -35,44 +35,6 @@ module Paludis
end
end
- class TestCase_NoConfigEnvironment < Test::Unit::TestCase
- def test_create
- assert_nothing_raised do
- e = NoConfigEnvironment.new(Dir.getwd().to_s + "/environment_TEST_dir/testrepo")
- assert_kind_of Environment, e
- assert_kind_of NoConfigEnvironment, e
- end
-
- assert_nothing_raised do
- e = NoConfigEnvironment.new(Dir.new(Dir.getwd().to_s + "/environment_TEST_dir/testrepo"))
- assert_kind_of Environment, e
- assert_kind_of NoConfigEnvironment, e
- end
-
- assert_nothing_raised do
- e = NoConfigEnvironment.new(Dir.getwd().to_s + "/environment_TEST_dir/testrepo", '/var/empty')
- assert_kind_of Environment, e
- assert_kind_of NoConfigEnvironment, e
- end
-
- assert_raise TypeError do
- e = NoConfigEnvironment.new(Dir.getwd().to_s + "/environment_TEST_dir/testrepo", 7)
- end
-
- assert_raise TypeError do
- e = NoConfigEnvironment.new(7, '/var/empty')
- end
-
- assert_raise ArgumentError do
- e = NoConfigEnvironment.new
- end
-
- assert_raise ArgumentError do
- e = NoConfigEnvironment.new(1,2,3,4,5)
- end
- end
- end
-
class TestCase_EnvironmentAcceptLicense < Test::Unit::TestCase
def env
@env or @env = EnvironmentFactory.instance.create("")
@@ -145,53 +107,9 @@ module Paludis
end
end
- class TestCase_NoConfigEnvironmentPackageSet < Test::Unit::TestCase
- def env
- NoConfigEnvironment.new(Dir.getwd().to_s + "/environment_TEST_dir/testrepo")
- end
-
- def test_package_set
- assert_kind_of DepSpec, env.set('everything')
- end
-
- def test_package_set_error
- assert_raise SetNameError do
- env.set('broken#')
- end
- end
- end
-
- class TestCase_NoConfigEnvirontmentPortageRepository < Test::Unit::TestCase
- def env
- NoConfigEnvironment.new(Dir.getwd().to_s + "/environment_TEST_dir/testrepo")
- end
-
- def test_portage_repository
- assert_kind_of Repository, env.main_repository
- end
- end
-
- class TestCase_NoConfigEnvirontmentMasterRepository < Test::Unit::TestCase
- def env
- NoConfigEnvironment.new(Dir.getwd().to_s + "/environment_TEST_dir/testrepo")
- end
-
- def env_master
- NoConfigEnvironment.new(Dir.getwd().to_s + "/environment_TEST_dir/testrepo",
- "/var/empty",
- "slaverepo",
- [Dir.getwd().to_s + "/environment_TEST_dir/slaverepo"])
- end
-
- def test_master_repository
- assert_nil env.master_repository
- assert_kind_of Repository, env_master.master_repository
- end
- end
-
class TestCase_EnvironmentDistribution < Test::Unit::TestCase
def env
- NoConfigEnvironment.new(Dir.getwd().to_s + "/environment_TEST_dir/testrepo")
+ @env or @env = EnvironmentFactory.instance.create("")
end
def test_distribution
@@ -317,20 +235,11 @@ module Paludis
@env or @env = EnvironmentFactory.instance.create("")
end
- def ncenv
- @ncenv or @ncenv = NoConfigEnvironment.new(Dir.getwd().to_s + "/environment_TEST_dir/testrepo")
- end
-
def test_format_key
assert_respond_to env, :format_key
assert_not_nil env.format_key
assert_kind_of MetadataStringKey, env.format_key
assert_equal 'paludis', env.format_key.parse_value
-
- assert_respond_to ncenv, :format_key
- assert_not_nil ncenv.format_key
- assert_kind_of MetadataStringKey, ncenv.format_key
- assert_equal 'no_config', ncenv.format_key.parse_value
end
def test_config_location_key
@@ -338,9 +247,6 @@ module Paludis
assert_not_nil env.config_location_key
assert_kind_of MetadataFSPathKey, env.config_location_key
assert_equal Dir.getwd().to_s + "/environment_TEST_dir/home/.paludis", env.config_location_key.parse_value
-
- assert_respond_to ncenv, :config_location_key
- assert_nil ncenv.config_location_key
end
end
diff --git a/ruby/package_id_TEST.rb b/ruby/package_id_TEST.rb
index d30348d..4466654 100644
--- a/ruby/package_id_TEST.rb
+++ b/ruby/package_id_TEST.rb
@@ -18,6 +18,8 @@
# Place, Suite 330, Boston, MA 02111-1307 USA
#
+ENV["PALUDIS_HOME"] = Dir.getwd().to_s + "/package_id_TEST_dir/home";
+
require 'test/unit'
require 'Paludis'
@@ -27,18 +29,11 @@ module Paludis
module TestStuff
def env
unless @env
- @env = EnvironmentFactory.instance.create("no-config:repository-dir=package_id_TEST_dir/testrepo/:write-cache=/var/empty:accept-unstable=true")
+ @env = EnvironmentFactory.instance.create("")
end
@env
end
- def env_vdb
- unless @env_vdb
- @env_vdb = NoConfigEnvironment.new("package_id_TEST_dir/installed/")
- end
- @env_vdb
- end
-
def pid_testrepo
env.fetch_repository("testrepo").package_ids("foo/bar").first
end
@@ -48,7 +43,7 @@ module Paludis
end
def pid_installed
- env_vdb.fetch_repository("installed").package_ids("cat-one/pkg-one").first
+ env.fetch_repository("installed").package_ids("cat-one/pkg-one").first
end
end
diff --git a/ruby/package_id_TEST_setup.sh b/ruby/package_id_TEST_setup.sh
index 745e0df..e71cda8 100755
--- a/ruby/package_id_TEST_setup.sh
+++ b/ruby/package_id_TEST_setup.sh
@@ -4,6 +4,37 @@
mkdir package_id_TEST_dir || exit 1
cd package_id_TEST_dir || exit 1
+mkdir -p home/.paludis/repositories
+
+cat <<END > home/.paludis/repositories/testrepo.conf
+location = `pwd`/testrepo
+format = e
+names_cache = /var/empty
+cache = /var/empty
+profiles = \${location}/profiles/testprofile
+builddir = `pwd`
+END
+
+cat <<END > home/.paludis/repositories/installed.conf
+location = `pwd`/installed
+format = vdb
+names_cache = /var/empty
+cache = /var/empty
+builddir = `pwd`
+name = installed
+END
+
+cat <<END > home/.paludis/keywords.conf
+*/* test ~test
+END
+cat <<END > home/.paludis/licenses.conf
+*/* *
+END
+
+cat <<END > home/.paludis/general.conf
+world = /dev/null
+END
+
mkdir -p testrepo/{eclass,distfiles,profiles/testprofile,foo/bar/files,bad/pkg/files} || exit 1
cd testrepo || exit 1
echo "testrepo" > profiles/repo_name || exit 1
diff --git a/ruby/repository_TEST.rb b/ruby/repository_TEST.rb
index dfb2a3b..25fa4a2 100644
--- a/ruby/repository_TEST.rb
+++ b/ruby/repository_TEST.rb
@@ -49,10 +49,6 @@ module Paludis
@env or @env = EnvironmentFactory.instance.create("")
end
- def no_config_testrepo
- NoConfigEnvironment.new Dir.getwd().to_s + "/repository_TEST_dir/testrepo"
- end
-
def p
env[Selection::RequireExactlyOne.new(Generator::Matches.new(
Paludis::parse_user_package_dep_spec('=foo/bar-2.0::testrepo', env, []), nil, []))].first
@@ -165,13 +161,6 @@ module Paludis
class TestCase_RepositoryInterfaces < Test::Unit::TestCase
include RepositoryTestCase
- def test_responds
- repo = no_config_testrepo.main_repository
- [ :environment_variable_interface ].each do |sym|
- assert_respond_to repo, sym
- end
- end
-
def test_interfaces
assert_equal installed_repo.name, installed_repo.environment_variable_interface.name
end