aboutsummaryrefslogtreecommitdiff
path: root/paludis/repositories/e/exndbam_repository_TEST.cc
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-08-05 21:39:12 +0100
committerAvatar David Leverton <levertond@googlemail.com> 2008-08-06 20:04:09 +0100
commit608c7abbd898be86371153195c883693cd7489d7 (patch)
treee1ab08a3adb02b726d1b9920d648a3ccd601002c /paludis/repositories/e/exndbam_repository_TEST.cc
parent9df9c709cca58917d2f32a1214b41d604ed81e25 (diff)
downloadpaludis-608c7abbd898be86371153195c883693cd7489d7.tar.gz
paludis-608c7abbd898be86371153195c883693cd7489d7.tar.xz
Support EAPI-dependent pkg_postinst phase ordering for up/downgrades.
This is currently determined by the EAPI of the version being installed, not the one being removed. The implementation is rather hackish; the new resolver will let us do better.
Diffstat (limited to 'paludis/repositories/e/exndbam_repository_TEST.cc')
-rw-r--r--paludis/repositories/e/exndbam_repository_TEST.cc193
1 files changed, 193 insertions, 0 deletions
diff --git a/paludis/repositories/e/exndbam_repository_TEST.cc b/paludis/repositories/e/exndbam_repository_TEST.cc
index b6072e0b3..09c01bb13 100644
--- a/paludis/repositories/e/exndbam_repository_TEST.cc
+++ b/paludis/repositories/e/exndbam_repository_TEST.cc
@@ -17,9 +17,20 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <paludis/repositories/e/e_repository.hh>
#include <paludis/repositories/e/exndbam_repository.hh>
+#include <paludis/repositories/e/make_ebuild_repository.hh>
#include <paludis/environments/test/test_environment.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/util/join.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/action.hh>
+#include <paludis/filtered_generator.hh>
+#include <paludis/generator.hh>
+#include <paludis/selection.hh>
+#include <paludis/user_dep_spec.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
@@ -56,5 +67,187 @@ namespace test_cases
TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "installed");
}
} test_exndbam_repository_repo_name;
+
+ struct PkgPostinstPhaseOrderingTest : TestCase
+ {
+ PkgPostinstPhaseOrderingTest() : TestCase("pkg_postinst phase ordering") { }
+
+ bool repeatable() const
+ {
+ return false;
+ }
+
+ unsigned max_run_time() const
+ {
+ return 3000;
+ }
+
+ void run()
+ {
+ TestEnvironment env(FSEntry("exndbam_repository_TEST_dir/root").realpath());
+ env.set_paludis_command("/bin/false");
+ std::tr1::shared_ptr<Map<std::string, std::string> > keys(new Map<std::string, std::string>);
+ keys->insert("format", "ebuild");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", "exndbam_repository_TEST_dir/postinsttest_src1");
+ keys->insert("profiles", "exndbam_repository_TEST_dir/postinsttest_src1/profiles/profile");
+ keys->insert("layout", "traditional");
+ keys->insert("eapi_when_unknown", "0");
+ keys->insert("eapi_when_unspecified", "0");
+ keys->insert("profile_eapi", "0");
+ keys->insert("distdir", stringify(FSEntry::cwd() / "exndbam_repository_TEST_dir" / "distdir"));
+ keys->insert("builddir", stringify(FSEntry::cwd() / "exndbam_repository_TEST_dir" / "build"));
+ keys->insert("root", stringify(FSEntry("exndbam_repository_TEST_dir/root").realpath()));
+ std::tr1::shared_ptr<ERepository> repo1(make_ebuild_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(1, repo1);
+
+ keys.reset(new Map<std::string, std::string>);
+ keys->insert("format", "exndbam");
+ keys->insert("location", "exndbam_repository_TEST_dir/postinsttest");
+ keys->insert("builddir", stringify(FSEntry::cwd() / "exndbam_repository_TEST_dir" / "build"));
+ keys->insert("root", stringify(FSEntry("exndbam_repository_TEST_dir/root").realpath()));
+ std::tr1::shared_ptr<Repository> exndbam_repo(ExndbamRepository::make_exndbam_repository(&env,
+ std::tr1::bind(from_keys, keys, std::tr1::placeholders::_1)));
+ env.package_database()->add_repository(0, exndbam_repo);
+
+ InstallAction install_action(make_named_values<InstallActionOptions>(
+ value_for<n::checks>(iaco_default),
+ value_for<n::debug_build>(iado_none),
+ value_for<n::destination>(exndbam_repo)
+ ));
+
+ UninstallAction uninstall_action;
+
+ TEST_CHECK(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg"))->empty());
+
+ {
+ TestMessageSuffix suffix("install eapi 1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-0::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg")));
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-0::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("reinstall eapi 1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-0::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg")));
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-0::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("upgrade eapi 1 -> 1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-0.1::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(env[selection::AllVersionsSorted(generator::Package(
+ QualifiedPackageName("cat/pkg")) & generator::InRepository(RepositoryName("installed")))]);
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-0::installed cat/pkg-0.1::installed");
+
+ const std::tr1::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-0::installed",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ inst_id->perform_action(uninstall_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids2(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg")));
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids2->begin()), indirect_iterator(ids2->end()), " "), "cat/pkg-0.1::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("upgrade eapi 1 -> paludis-1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-1::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(env[selection::AllVersionsSorted(generator::Package(
+ QualifiedPackageName("cat/pkg")) & generator::InRepository(RepositoryName("installed")))]);
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-1::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("reinstall eapi paludis-1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-1::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg")));
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-1::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("upgrade eapi paludis-1 -> paludis-1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-1.1::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg")));
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-1.1::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("new slot", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-2::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(env[selection::AllVersionsSorted(generator::Package(
+ QualifiedPackageName("cat/pkg")) & generator::InRepository(RepositoryName("installed")))]);
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-1.1::installed cat/pkg-2::installed");
+ }
+
+ {
+ TestMessageSuffix suffix("downgrade eapi paludis-1 -> 1", true);
+
+ const std::tr1::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-0::postinsttest",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ id->perform_action(install_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids(env[selection::AllVersionsSorted(generator::Package(
+ QualifiedPackageName("cat/pkg")) & generator::InRepository(RepositoryName("installed")))]);
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "), "cat/pkg-0::installed cat/pkg-1.1::installed cat/pkg-2::installed");
+
+ const std::tr1::shared_ptr<const PackageID> inst_id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/pkg-1.1::installed",
+ &env, UserPackageDepSpecOptions()))))]->begin());
+ inst_id->perform_action(uninstall_action);
+ exndbam_repo->invalidate();
+
+ std::tr1::shared_ptr<const PackageIDSequence> ids2(env[selection::AllVersionsSorted(generator::Package(
+ QualifiedPackageName("cat/pkg")) & generator::InRepository(RepositoryName("installed")))]);
+ TEST_CHECK_EQUAL(join(indirect_iterator(ids2->begin()), indirect_iterator(ids2->end()), " "), "cat/pkg-0::installed cat/pkg-2::installed");
+ }
+ }
+ } pkg_postinst_phase_ordering_test;
}