aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-26 23:47:35 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-26 23:47:35 +0000
commit94597d578c33b18de74fdf103055a4940534ae98 (patch)
tree8b2067e76dc01c8cc016bf85596246f5ba460bee
parente83389a18c879e1d66eceff76cc307aca3f21863 (diff)
downloadpaludis-94597d578c33b18de74fdf103055a4940534ae98.tar.gz
paludis-94597d578c33b18de74fdf103055a4940534ae98.tar.xz
gtest more
-rw-r--r--paludis/repositories/e/Makefile.am4
-rw-r--r--paludis/repositories/e/e_repository_TEST_2.cc247
2 files changed, 116 insertions, 135 deletions
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index f269d9f..51607ac 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -256,13 +256,15 @@ e_repository_TEST_4_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
e_repository_TEST_2_SOURCES = e_repository_TEST_2.cc
e_repository_TEST_2_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)
e_repository_TEST_2_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+e_repository_TEST_2_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
e_repository_TEST_1_SOURCES = e_repository_TEST_1.cc
e_repository_TEST_1_LDADD = \
diff --git a/paludis/repositories/e/e_repository_TEST_2.cc b/paludis/repositories/e/e_repository_TEST_2.cc
index 16d5fdb..f8ed583 100644
--- a/paludis/repositories/e/e_repository_TEST_2.cc
+++ b/paludis/repositories/e/e_repository_TEST_2.cc
@@ -22,17 +22,22 @@
#include <paludis/repositories/e/e_repository_id.hh>
#include <paludis/repositories/e/vdb_repository.hh>
#include <paludis/repositories/e/eapi.hh>
+
#include <paludis/repositories/fake/fake_installed_repository.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
+
#include <paludis/environments/test/test_environment.hh>
+
#include <paludis/util/system.hh>
#include <paludis/util/visitor_cast.hh>
#include <paludis/util/map.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/set.hh>
#include <paludis/util/make_null_shared_ptr.hh>
-#include <paludis/standard_output_manager.hh>
#include <paludis/util/safe_ifstream.hh>
+#include <paludis/util/stringify.hh>
+
+#include <paludis/standard_output_manager.hh>
#include <paludis/package_id.hh>
#include <paludis/metadata_key.hh>
#include <paludis/action.hh>
@@ -43,15 +48,15 @@
#include <paludis/selection.hh>
#include <paludis/repository_factory.hh>
#include <paludis/choice.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
+
#include <functional>
#include <set>
#include <string>
#include "config.h"
-using namespace test;
+#include <gtest/gtest.h>
+
using namespace paludis;
namespace
@@ -83,137 +88,111 @@ namespace
}
}
-namespace test_cases
+TEST(ERepository, InstallEAPI2)
{
- struct ERepositoryInstallEAPI2Test : TestCase
+ TestEnvironment env;
+ 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() / "e_repository_TEST_2_dir" / "repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "e_repository_TEST_2_dir" / "repo/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() / "e_repository_TEST_2_dir" / "distdir"));
+ keys->insert("builddir", stringify(FSPath::cwd() / "e_repository_TEST_2_dir" / "build"));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ std::shared_ptr<FakeInstalledRepository> installed_repo(std::make_shared<FakeInstalledRepository>(
+ make_named_values<FakeInstalledRepositoryParams>(
+ n::environment() = &env,
+ n::name() = RepositoryName("installed"),
+ n::suitable_destination() = true,
+ n::supports_uninstall() = true
+ )));
+ env.add_repository(2, installed_repo);
+
+ InstallAction action(make_named_values<InstallActionOptions>(
+ n::destination() = installed_repo,
+ n::make_output_manager() = &make_standard_output_manager,
+ n::perform_uninstall() = &cannot_uninstall,
+ n::replacing() = std::make_shared<PackageIDSequence>(),
+ n::want_phase() = &want_all_phases
+ ));
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/econf-source-2",
+ &env, { })), make_null_shared_ptr(), { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("2", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value());
+ id->perform_action(action);
+ }
+
{
- ERepositoryInstallEAPI2Test() : TestCase("install_eapi_2") { }
-
- unsigned max_run_time() const
- {
- return 3000;
- }
-
- bool repeatable() const
- {
- return false;
- }
-
- void run()
- {
- TestEnvironment env;
- 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() / "e_repository_TEST_2_dir" / "repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "e_repository_TEST_2_dir" / "repo/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() / "e_repository_TEST_2_dir" / "distdir"));
- keys->insert("builddir", stringify(FSPath::cwd() / "e_repository_TEST_2_dir" / "build"));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- std::shared_ptr<FakeInstalledRepository> installed_repo(std::make_shared<FakeInstalledRepository>(
- make_named_values<FakeInstalledRepositoryParams>(
- n::environment() = &env,
- n::name() = RepositoryName("installed"),
- n::suitable_destination() = true,
- n::supports_uninstall() = true
- )));
- env.add_repository(2, installed_repo);
-
- InstallAction action(make_named_values<InstallActionOptions>(
- n::destination() = installed_repo,
- n::make_output_manager() = &make_standard_output_manager,
- n::perform_uninstall() = &cannot_uninstall,
- n::replacing() = std::make_shared<PackageIDSequence>(),
- n::want_phase() = &want_all_phases
- ));
-
- {
- TestMessageSuffix suffix("econf source 2", true);
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/econf-source-2",
- &env, { })), make_null_shared_ptr(), { }))]->last());
- TEST_CHECK(bool(id));
- TEST_CHECK_EQUAL(visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value(), "2");
- id->perform_action(action);
- }
-
- {
- TestMessageSuffix suffix("doman 2", true);
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/doman-2",
- &env, { })), make_null_shared_ptr(), { }))]->last());
- TEST_CHECK(bool(id));
- TEST_CHECK_EQUAL(visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value(), "2");
- id->perform_action(action);
- }
-
- {
- TestMessageSuffix suffix("src_prepare 2", true);
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/src_prepare-2",
- &env, { })), make_null_shared_ptr(), { }))]->last());
- TEST_CHECK(bool(id));
- TEST_CHECK_EQUAL(visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value(), "2");
- TEST_CHECK_THROWS(id->perform_action(action), ActionFailedError);
- }
-
- {
- TestMessageSuffix suffix("src_configure 2", true);
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/src_configure-2",
- &env, { })), make_null_shared_ptr(), { }))]->last());
- TEST_CHECK(bool(id));
- TEST_CHECK_EQUAL(visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value(), "2");
- TEST_CHECK_THROWS(id->perform_action(action), ActionFailedError);
- }
-
- {
- TestMessageSuffix suffix("default src_configure 2", true);
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/default-src_configure-2",
- &env, { })), make_null_shared_ptr(), { }))]->last());
- TEST_CHECK(bool(id));
- TEST_CHECK_EQUAL(visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value(), "2");
- id->perform_action(action);
- }
-
- {
- TestMessageSuffix suffix("default src_compile 2", true);
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/default-src_compile-2",
- &env, { })), make_null_shared_ptr(), { }))]->last());
- TEST_CHECK(bool(id));
- TEST_CHECK_EQUAL(visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value(), "2");
- id->perform_action(action);
- }
-
- {
- TestMessageSuffix suffix("default_src_compile 2", true);
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/default_src_compile-2",
- &env, { })), make_null_shared_ptr(), { }))]->last());
- TEST_CHECK(bool(id));
- TEST_CHECK_EQUAL(visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value(), "2");
- id->perform_action(action);
- }
-
- {
- TestMessageSuffix suffix("src_compile via default function 2", true);
- const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
- PackageDepSpec(parse_user_package_dep_spec("=cat/src_compile-via-default-func-2",
- &env, { })), make_null_shared_ptr(), { }))]->last());
- TEST_CHECK(bool(id));
- TEST_CHECK_EQUAL(visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value(), "2");
- id->perform_action(action);
- }
- }
- } test_e_repository_install_eapi_2;
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/doman-2",
+ &env, { })), make_null_shared_ptr(), { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("2", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value());
+ id->perform_action(action);
+ }
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/src_prepare-2",
+ &env, { })), make_null_shared_ptr(), { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("2", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value());
+ ASSERT_THROW(id->perform_action(action), ActionFailedError);
+ }
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/src_configure-2",
+ &env, { })), make_null_shared_ptr(), { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("2", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value());
+ ASSERT_THROW(id->perform_action(action), ActionFailedError);
+ }
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/default-src_configure-2",
+ &env, { })), make_null_shared_ptr(), { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("2", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value());
+ id->perform_action(action);
+ }
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/default-src_compile-2",
+ &env, { })), make_null_shared_ptr(), { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("2", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value());
+ id->perform_action(action);
+ }
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/default_src_compile-2",
+ &env, { })), make_null_shared_ptr(), { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("2", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value());
+ id->perform_action(action);
+ }
+
+ {
+ const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches(
+ PackageDepSpec(parse_user_package_dep_spec("=cat/src_compile-via-default-func-2",
+ &env, { })), make_null_shared_ptr(), { }))]->last());
+ ASSERT_TRUE(bool(id));
+ EXPECT_EQ("2", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value());
+ id->perform_action(action);
+ }
}