aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-26 21:57:16 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-26 21:57:16 +0000
commitc80bb6384b5a618cc49f97ac8f5c72341e786df8 (patch)
tree63f504046afa65e77266b77f56687a6a39bbc6c4
parent258d78df3c2bb8abea05496b2c4a7c54918b37a3 (diff)
downloadpaludis-c80bb6384b5a618cc49f97ac8f5c72341e786df8.tar.gz
paludis-c80bb6384b5a618cc49f97ac8f5c72341e786df8.tar.xz
gtest more
-rw-r--r--paludis/repositories/e/Makefile.am4
-rw-r--r--paludis/repositories/e/exndbam_repository_TEST.cc299
2 files changed, 134 insertions, 169 deletions
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 3c4814a..2ba7f5d 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -348,13 +348,15 @@ vdb_repository_TEST_cache_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXX
exndbam_repository_TEST_SOURCES = exndbam_repository_TEST.cc
exndbam_repository_TEST_LDADD = \
+ $(top_builddir)/paludis/util/gtest_runner.o \
$(top_builddir)/paludis/util/libpaludisutil_@PALUDIS_PC_SLOT@.la \
$(top_builddir)/paludis/libpaludis_@PALUDIS_PC_SLOT@.la \
- $(top_builddir)/test/libtest.a \
$(DYNAMIC_LD_LIBS)
exndbam_repository_TEST_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+exndbam_repository_TEST_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
vdb_merger_TEST_SOURCES = vdb_merger_TEST.cc
vdb_merger_TEST_LDADD = \
diff --git a/paludis/repositories/e/exndbam_repository_TEST.cc b/paludis/repositories/e/exndbam_repository_TEST.cc
index a965346..0776848 100644
--- a/paludis/repositories/e/exndbam_repository_TEST.cc
+++ b/paludis/repositories/e/exndbam_repository_TEST.cc
@@ -19,7 +19,9 @@
#include <paludis/repositories/e/e_repository.hh>
#include <paludis/repositories/e/exndbam_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>
@@ -27,16 +29,16 @@
#include <paludis/util/sequence.hh>
#include <paludis/util/fs_path.hh>
#include <paludis/util/make_null_shared_ptr.hh>
+
#include <paludis/standard_output_manager.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>
-using namespace test;
+#include <gtest/gtest.h>
+
using namespace paludis;
namespace
@@ -66,176 +68,137 @@ namespace
{
return wp_yes;
}
+
+ void install(const Environment & env,
+ const std::shared_ptr<Repository> & exndbam_repo,
+ const std::string & chosen_one,
+ const std::string & victim)
+ {
+ std::shared_ptr<PackageIDSequence> replacing(std::make_shared<PackageIDSequence>());
+ if (! victim.empty())
+ replacing->push_back(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec(victim,
+ &env, { })), make_null_shared_ptr(), { }))]->begin());
+ InstallAction install_action(make_named_values<InstallActionOptions>(
+ n::destination() = exndbam_repo,
+ n::make_output_manager() = &make_standard_output_manager,
+ n::perform_uninstall() = &do_uninstall,
+ n::replacing() = replacing,
+ n::want_phase() = &want_all_phases
+ ));
+ (*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec(chosen_one,
+ &env, { })), make_null_shared_ptr(), { }))]->begin())->perform_action(install_action);
+ }
+}
+
+TEST(ExndbamRepository, RepoName)
+{
+ TestEnvironment env;
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "exndbam");
+ keys->insert("location", stringify(FSPath::cwd() / "exndbam_repository_TEST_dir" / "repo1"));
+ keys->insert("builddir", stringify(FSPath::cwd() / "exndbam_repository_TEST_dir" / "build"));
+ std::shared_ptr<Repository> repo(ExndbamRepository::ExndbamRepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ EXPECT_EQ("installed", stringify(repo->name()));
}
-namespace test_cases
+TEST(ExndbamRepository, PhaseOrdering)
{
- struct ExndbamRepositoryRepoNameTest : TestCase
+ TestEnvironment env(FSPath("exndbam_repository_TEST_dir/root").realpath());
+ std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
+ keys->insert("format", "e");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "exndbam_repository_TEST_dir" / "postinsttest_src1"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "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(FSPath::cwd() / "exndbam_repository_TEST_dir" / "distdir"));
+ keys->insert("builddir", stringify(FSPath::cwd() / "exndbam_repository_TEST_dir" / "build"));
+ keys->insert("root", stringify(FSPath("exndbam_repository_TEST_dir/root").realpath()));
+ std::shared_ptr<Repository> repo1(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo1);
+
+ keys = std::make_shared<Map<std::string, std::string>>();
+ keys->insert("format", "exndbam");
+ keys->insert("location", stringify(FSPath::cwd() / "exndbam_repository_TEST_dir" / "postinsttest"));
+ keys->insert("builddir", stringify(FSPath::cwd() / "exndbam_repository_TEST_dir" / "build"));
+ keys->insert("root", stringify(FSPath("exndbam_repository_TEST_dir/root").realpath()));
+ std::shared_ptr<Repository> exndbam_repo(ExndbamRepository::ExndbamRepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(0, exndbam_repo);
+
+ EXPECT_TRUE(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg"), { })->empty());
+
+ {
+ install(env, exndbam_repo, "=cat/pkg-0::postinsttest", "");
+ exndbam_repo->invalidate();
+
+ std::shared_ptr<const PackageIDSequence> ids(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg"), { }));
+ EXPECT_EQ("cat/pkg-0::installed", join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "));
+ }
+
{
- ExndbamRepositoryRepoNameTest() : TestCase("repo name") { }
-
- void run()
- {
- TestEnvironment env;
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "exndbam");
- keys->insert("location", stringify(FSPath::cwd() / "exndbam_repository_TEST_dir" / "repo1"));
- keys->insert("builddir", stringify(FSPath::cwd() / "exndbam_repository_TEST_dir" / "build"));
- std::shared_ptr<Repository> repo(ExndbamRepository::ExndbamRepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "installed");
- }
- } test_exndbam_repository_repo_name;
-
- struct PkgPostinstPhaseOrderingTest : TestCase
+ install(env, exndbam_repo, "=cat/pkg-0::postinsttest", "");
+ exndbam_repo->invalidate();
+
+ std::shared_ptr<const PackageIDSequence> ids(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg"), { }));
+ EXPECT_EQ("cat/pkg-0::installed", join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "));
+ }
+
{
- PkgPostinstPhaseOrderingTest() : TestCase("pkg_postinst phase ordering") { }
-
- bool repeatable() const
- {
- return false;
- }
-
- unsigned max_run_time() const
- {
- return 3000;
- }
-
- void install(const Environment & env,
- const std::shared_ptr<Repository> & exndbam_repo,
- const std::string & chosen_one,
- const std::string & victim) const
- {
- std::shared_ptr<PackageIDSequence> replacing(std::make_shared<PackageIDSequence>());
- if (! victim.empty())
- replacing->push_back(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec(victim,
- &env, { })), make_null_shared_ptr(), { }))]->begin());
- InstallAction install_action(make_named_values<InstallActionOptions>(
- n::destination() = exndbam_repo,
- n::make_output_manager() = &make_standard_output_manager,
- n::perform_uninstall() = &do_uninstall,
- n::replacing() = replacing,
- n::want_phase() = &want_all_phases
- ));
- (*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec(chosen_one,
- &env, { })), make_null_shared_ptr(), { }))]->begin())->perform_action(install_action);
- }
-
- void run()
- {
- TestEnvironment env(FSPath("exndbam_repository_TEST_dir/root").realpath());
- std::shared_ptr<Map<std::string, std::string> > keys(std::make_shared<Map<std::string, std::string>>());
- keys->insert("format", "e");
- keys->insert("names_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "exndbam_repository_TEST_dir" / "postinsttest_src1"));
- keys->insert("profiles", stringify(FSPath::cwd() / "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(FSPath::cwd() / "exndbam_repository_TEST_dir" / "distdir"));
- keys->insert("builddir", stringify(FSPath::cwd() / "exndbam_repository_TEST_dir" / "build"));
- keys->insert("root", stringify(FSPath("exndbam_repository_TEST_dir/root").realpath()));
- std::shared_ptr<Repository> repo1(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo1);
-
- keys = std::make_shared<Map<std::string, std::string>>();
- keys->insert("format", "exndbam");
- keys->insert("location", stringify(FSPath::cwd() / "exndbam_repository_TEST_dir" / "postinsttest"));
- keys->insert("builddir", stringify(FSPath::cwd() / "exndbam_repository_TEST_dir" / "build"));
- keys->insert("root", stringify(FSPath("exndbam_repository_TEST_dir/root").realpath()));
- std::shared_ptr<Repository> exndbam_repo(ExndbamRepository::ExndbamRepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(0, exndbam_repo);
-
- TEST_CHECK(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg"), { })->empty());
-
- {
- TestMessageSuffix suffix("install eapi 1", true);
-
- install(env, exndbam_repo, "=cat/pkg-0::postinsttest", "");
- exndbam_repo->invalidate();
-
- std::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);
-
- install(env, exndbam_repo, "=cat/pkg-0::postinsttest", "");
- exndbam_repo->invalidate();
-
- std::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);
-
- install(env, exndbam_repo, "=cat/pkg-0.1::postinsttest", "=cat/pkg-0::installed");
- exndbam_repo->invalidate();
-
- std::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);
-
- install(env, exndbam_repo, "=cat/pkg-1::postinsttest", "=cat/pkg-0.1::installed");
- exndbam_repo->invalidate();
-
- std::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);
-
- install(env, exndbam_repo, "=cat/pkg-1::postinsttest", "");
- exndbam_repo->invalidate();
-
- std::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);
-
- install(env, exndbam_repo, "=cat/pkg-1.1::postinsttest", "=cat/pkg-1::installed");
- exndbam_repo->invalidate();
-
- std::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);
-
- install(env, exndbam_repo, "=cat/pkg-2::postinsttest", "");
- exndbam_repo->invalidate();
-
- std::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);
-
- install(env, exndbam_repo, "=cat/pkg-0::postinsttest", "=cat/pkg-1.1::installed");
- exndbam_repo->invalidate();
+ install(env, exndbam_repo, "=cat/pkg-0.1::postinsttest", "=cat/pkg-0::installed");
+ exndbam_repo->invalidate();
+
+ std::shared_ptr<const PackageIDSequence> ids2(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg"), { }));
+ EXPECT_EQ("cat/pkg-0.1::installed", join(indirect_iterator(ids2->begin()), indirect_iterator(ids2->end()), " "));
+ }
- std::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;
+ {
+ install(env, exndbam_repo, "=cat/pkg-1::postinsttest", "=cat/pkg-0.1::installed");
+ exndbam_repo->invalidate();
+
+ std::shared_ptr<const PackageIDSequence> ids(env[selection::AllVersionsSorted(generator::Package(
+ QualifiedPackageName("cat/pkg")) & generator::InRepository(RepositoryName("installed")))]);
+ EXPECT_EQ("cat/pkg-1::installed", join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "));
+ }
+
+ {
+ install(env, exndbam_repo, "=cat/pkg-1::postinsttest", "");
+ exndbam_repo->invalidate();
+
+ std::shared_ptr<const PackageIDSequence> ids(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg"), { }));
+ EXPECT_EQ("cat/pkg-1::installed", join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "));
+ }
+
+ {
+ install(env, exndbam_repo, "=cat/pkg-1.1::postinsttest", "=cat/pkg-1::installed");
+ exndbam_repo->invalidate();
+
+ std::shared_ptr<const PackageIDSequence> ids(exndbam_repo->package_ids(QualifiedPackageName("cat/pkg"), { }));
+ EXPECT_EQ("cat/pkg-1.1::installed", join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "));
+ }
+
+ {
+ install(env, exndbam_repo, "=cat/pkg-2::postinsttest", "");
+ exndbam_repo->invalidate();
+
+ std::shared_ptr<const PackageIDSequence> ids(env[selection::AllVersionsSorted(generator::Package(
+ QualifiedPackageName("cat/pkg")) & generator::InRepository(RepositoryName("installed")))]);
+ EXPECT_EQ("cat/pkg-1.1::installed cat/pkg-2::installed", join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "));
+ }
+
+ {
+ install(env, exndbam_repo, "=cat/pkg-0::postinsttest", "=cat/pkg-1.1::installed");
+ exndbam_repo->invalidate();
+
+ std::shared_ptr<const PackageIDSequence> ids2(env[selection::AllVersionsSorted(generator::Package(
+ QualifiedPackageName("cat/pkg")) & generator::InRepository(RepositoryName("installed")))]);
+ EXPECT_EQ("cat/pkg-0::installed cat/pkg-2::installed", join(indirect_iterator(ids2->begin()), indirect_iterator(ids2->end()), " "));
+ }
}