aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-03 16:12:09 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-04 08:33:00 +0100
commitde5f08b35621fd4a790885b2707468203b2df379 (patch)
treee7f98a614dfdcb0c4070fbc573ef9e453eeabfc1
parent1a8319191a0c4a585fab173199a2c898c76f30c3 (diff)
downloadpaludis-de5f08b35621fd4a790885b2707468203b2df379.tar.gz
paludis-de5f08b35621fd4a790885b2707468203b2df379.tar.xz
Normalise cat/pkg parts
-rw-r--r--.gitignore1
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/partially_made_package_dep_spec.cc22
-rw-r--r--paludis/partially_made_package_dep_spec_TEST.cc62
4 files changed, 84 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index 5a22b83..341c279 100644
--- a/.gitignore
+++ b/.gitignore
@@ -265,6 +265,7 @@ paludis-*.*.*.tar.bz2
/paludis/ihateautomake.cc
/paludis/name_TEST
/paludis/paludis.hh
+/paludis/partially_made_package_dep_spec_TEST
/paludis/repositories/accounts/accounts_repository_TEST
/paludis/repositories/e/aa_visitor_TEST
/paludis/repositories/e/dep_parser_TEST
diff --git a/paludis/files.m4 b/paludis/files.m4
index 6c45c22..ab86ca3 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -80,7 +80,7 @@ add(`package_dep_spec_properties', `hh', `cc', `fwd')
add(`package_id', `hh', `cc', `fwd', `se')
add(`paludis', `hh')
add(`paludislike_options_conf', `hh', `cc', `fwd')
-add(`partially_made_package_dep_spec', `hh', `cc', `fwd', `se')
+add(`partially_made_package_dep_spec', `hh', `cc', `fwd', `se', `gtest')
add(`permitted_choice_value_parameter_values', `hh', `cc', `fwd')
add(`pretty_print_options', `hh', `cc', `fwd', `se')
add(`pretty_printer', `hh', `cc', `fwd')
diff --git a/paludis/partially_made_package_dep_spec.cc b/paludis/partially_made_package_dep_spec.cc
index 9d67d9c..2624564 100644
--- a/paludis/partially_made_package_dep_spec.cc
+++ b/paludis/partially_made_package_dep_spec.cc
@@ -440,6 +440,8 @@ PartiallyMadePackageDepSpec::~PartiallyMadePackageDepSpec()
PartiallyMadePackageDepSpec &
PartiallyMadePackageDepSpec::package(const QualifiedPackageName & name)
{
+ _imp->data->package_name_part.reset();
+ _imp->data->category_name_part.reset();
_imp->data->package = NameConstraintPool::get_instance()->create(name);
return *this;
}
@@ -552,7 +554,15 @@ PartiallyMadePackageDepSpec::clear_installable_to_path()
PartiallyMadePackageDepSpec &
PartiallyMadePackageDepSpec::package_name_part(const PackageNamePart & part)
{
- _imp->data->package_name_part = PackageNamePartConstraintPool::get_instance()->create(part);
+ _imp->data->package.reset();
+ if (_imp->data->category_name_part)
+ {
+ _imp->data->package = NameConstraintPool::get_instance()->create(_imp->data->category_name_part->name_part() + part);
+ _imp->data->category_name_part.reset();
+ }
+ else
+ _imp->data->package_name_part = PackageNamePartConstraintPool::get_instance()->create(part);
+
return *this;
}
@@ -566,7 +576,15 @@ PartiallyMadePackageDepSpec::clear_package_name_part()
PartiallyMadePackageDepSpec &
PartiallyMadePackageDepSpec::category_name_part(const CategoryNamePart & part)
{
- _imp->data->category_name_part = CategoryNamePartConstraintPool::get_instance()->create(part);
+ _imp->data->category_name_part.reset();
+ if (_imp->data->package_name_part)
+ {
+ _imp->data->package = NameConstraintPool::get_instance()->create(part + _imp->data->package_name_part->name_part());
+ _imp->data->package_name_part.reset();
+ }
+ else
+ _imp->data->category_name_part = CategoryNamePartConstraintPool::get_instance()->create(part);
+
return *this;
}
diff --git a/paludis/partially_made_package_dep_spec_TEST.cc b/paludis/partially_made_package_dep_spec_TEST.cc
new file mode 100644
index 0000000..0685b38
--- /dev/null
+++ b/paludis/partially_made_package_dep_spec_TEST.cc
@@ -0,0 +1,62 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2011 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/partially_made_package_dep_spec.hh>
+#include <paludis/package_dep_spec_constraint.hh>
+
+#include <paludis/util/stringify.hh>
+#include <paludis/util/options.hh>
+
+#include <gtest/gtest.h>
+
+using namespace paludis;
+
+TEST(PartiallyMadePackageDepSpec, CatAndPkgBecomesQPN)
+{
+ PackageDepSpec p(make_package_dep_spec({ })
+ .category_name_part(CategoryNamePart("cat"))
+ .package_name_part(PackageNamePart("pkg"))
+ );
+
+ EXPECT_EQ("cat/pkg", stringify(p));
+
+ ASSERT_TRUE(bool(p.package_name_constraint()));
+ EXPECT_EQ("cat/pkg", stringify(p.package_name_constraint()->name()));
+
+ EXPECT_FALSE(bool(p.category_name_part_constraint()));
+ EXPECT_FALSE(bool(p.package_name_part_constraint()));
+}
+
+TEST(PartiallyMadePackageDepSpec, QPNClearsCatPkg)
+{
+ PackageDepSpec p(make_package_dep_spec({ })
+ .category_name_part(CategoryNamePart("cat"))
+ .package_name_part(PackageNamePart("pkg"))
+ .package(QualifiedPackageName("other/name"))
+ );
+
+ EXPECT_EQ("other/name", stringify(p));
+
+ ASSERT_TRUE(bool(p.package_name_constraint()));
+ EXPECT_EQ("other/name", stringify(p.package_name_constraint()->name()));
+
+ EXPECT_FALSE(bool(p.category_name_part_constraint()));
+ EXPECT_FALSE(bool(p.package_name_part_constraint()));
+}
+