aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2006-11-01 19:09:54 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2006-11-01 19:09:54 +0000
commit9d84c9eb7e7bfc3845cf8fb58b5045d88bb01b09 (patch)
treebb4477b345af1db9b1440c93ed8884aa279db31b
parent3fdcb291347583564d72efb40f6af5c2914a6c66 (diff)
downloadpaludis-9d84c9eb7e7bfc3845cf8fb58b5045d88bb01b09.tar.gz
paludis-9d84c9eb7e7bfc3845cf8fb58b5045d88bb01b09.tar.xz
Add AmbiguousPackageNameError and test for NoSuchPackage to ruby bindings
-rw-r--r--ruby/package_database_TEST.rb9
-rwxr-xr-xruby/package_database_TEST_setup.sh23
-rw-r--r--ruby/paludis_ruby.cc4
3 files changed, 35 insertions, 1 deletions
diff --git a/ruby/package_database_TEST.rb b/ruby/package_database_TEST.rb
index df472da..3304549 100644
--- a/ruby/package_database_TEST.rb
+++ b/ruby/package_database_TEST.rb
@@ -48,6 +48,15 @@ module Paludis
def test_package_database_fetch_unique_qualified_package_name
assert_equal "foo/bar", db.fetch_unique_qualified_package_name("bar")
end
+
+ def test_error
+ assert_raise AmbiguousPackageNameError do
+ db.fetch_unique_qualified_package_name('baz')
+ end
+ assert_raise NoSuchPackageError do
+ db.fetch_unique_qualified_package_name('foobarbaz')
+ end
+ end
end
class TestCase_PackageDatabaseQuery < Test::Unit::TestCase
diff --git a/ruby/package_database_TEST_setup.sh b/ruby/package_database_TEST_setup.sh
index 7ca1693..03bd00c 100755
--- a/ruby/package_database_TEST_setup.sh
+++ b/ruby/package_database_TEST_setup.sh
@@ -27,11 +27,12 @@ cat <<END > home/.paludis/licenses.conf
* *
END
-mkdir -p testrepo/{eclass,distfiles,profiles/testprofile,foo/bar/files} || exit 1
+mkdir -p testrepo/{eclass,distfiles,profiles/testprofile,foo/bar/files,foo/baz/files,quux/baz/files} || exit 1
cd testrepo || exit 1
echo "testrepo" > profiles/repo_name || exit 1
cat <<END > profiles/categories || exit 1
foo
+quux
END
cat <<END > profiles/testprofile/make.defaults
ARCH=test
@@ -58,6 +59,26 @@ IUSE=""
LICENSE="GPL-2"
KEYWORDS="~test"
END
+
+cat <<"END" > foo/baz/baz-1.0.ebuild || exit 1
+DESCRIPTION="Test package"
+HOMEPAGE="http://paludis.berlios.de/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+END
+
+cat <<"END" > quux/baz/baz-2.0.ebuild || exit 1
+DESCRIPTION="Test package"
+HOMEPAGE="http://paludis.berlios.de/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+END
cd ..
diff --git a/ruby/paludis_ruby.cc b/ruby/paludis_ruby.cc
index 9e3b6a4..4e5dd92 100644
--- a/ruby/paludis_ruby.cc
+++ b/ruby/paludis_ruby.cc
@@ -46,6 +46,7 @@ namespace
static VALUE c_package_dep_atom_error;
static VALUE c_package_database_error;
static VALUE c_package_database_lookup_error;
+ static VALUE c_ambiguous_package_name_error;
static VALUE c_no_such_package_error;
static VALUE c_no_such_repository_error;
static VALUE c_dep_string_error;
@@ -106,6 +107,8 @@ void paludis::ruby::exception_to_ruby_exception(const std::exception & ee)
rb_raise(c_package_dep_atom_error, dynamic_cast<const paludis::PackageDepAtomError *>(&ee)->message().c_str());
else if (0 != dynamic_cast<const paludis::NoSuchRepositoryError *>(&ee))
rb_raise(c_no_such_repository_error, dynamic_cast<const paludis::NoSuchRepositoryError *>(&ee)->message().c_str());
+ else if (0 != dynamic_cast<const paludis::AmbiguousPackageNameError *>(&ee))
+ rb_raise(c_ambiguous_package_name_error, dynamic_cast<const paludis::AmbiguousPackageNameError *>(&ee)->message().c_str());
else if (0 != dynamic_cast<const paludis::NoSuchPackageError *>(&ee))
rb_raise(c_no_such_package_error, dynamic_cast<const paludis::NoSuchPackageError *>(&ee)->message().c_str());
else if (0 != dynamic_cast<const paludis::PackageDatabaseLookupError *>(&ee))
@@ -166,6 +169,7 @@ extern "C"
c_package_dep_atom_error = rb_define_class_under(c_paludis_module, "PackageDepAtomError", rb_eRuntimeError);
c_package_database_error = rb_define_class_under(c_paludis_module, "PackageDatabaseError", rb_eRuntimeError);
c_package_database_lookup_error = rb_define_class_under(c_paludis_module, "PackageDatabaseLookupError", c_package_database_error);
+ c_ambiguous_package_name_error = rb_define_class_under(c_paludis_module, "AmbiguousPackageNameError", c_package_database_lookup_error);
c_no_such_package_error = rb_define_class_under(c_paludis_module, "NoSuchPackageError", c_package_database_lookup_error);
c_no_such_repository_error = rb_define_class_under(c_paludis_module, "NoSuchRepositoryError", c_package_database_lookup_error);
c_dep_string_error = rb_define_class_under(c_paludis_module, "DepStringError", rb_eRuntimeError);