diff options
author | 2011-03-26 23:39:03 +0000 | |
---|---|---|
committer | 2011-03-26 23:39:03 +0000 | |
commit | d55a26b2b93b0908b948e4d1ff8a4ace8e4a415a (patch) | |
tree | 1aab3ce068fff118bf08d345fbef9d4d8827c4b5 | |
parent | a7fa098b7348e9b564f4a1f3c32b55efb3adbd65 (diff) | |
download | paludis-d55a26b2b93b0908b948e4d1ff8a4ace8e4a415a.tar.gz paludis-d55a26b2b93b0908b948e4d1ff8a4ace8e4a415a.tar.xz |
gtest more
-rw-r--r-- | paludis/repositories/e/Makefile.am | 4 | ||||
-rw-r--r-- | paludis/repositories/e/e_repository_TEST_3.cc | 114 |
2 files changed, 53 insertions, 65 deletions
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am index 97e98cc8d..5ab1b9169 100644 --- a/paludis/repositories/e/Makefile.am +++ b/paludis/repositories/e/Makefile.am @@ -232,13 +232,15 @@ e_repository_TEST_exheres_0_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@ e_repository_TEST_3_SOURCES = e_repository_TEST_3.cc e_repository_TEST_3_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_3_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@ +e_repository_TEST_3_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@ + e_repository_TEST_4_SOURCES = e_repository_TEST_4.cc e_repository_TEST_4_LDADD = \ diff --git a/paludis/repositories/e/e_repository_TEST_3.cc b/paludis/repositories/e/e_repository_TEST_3.cc index 79c0e02d5..ff1008719 100644 --- a/paludis/repositories/e/e_repository_TEST_3.cc +++ b/paludis/repositories/e/e_repository_TEST_3.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,67 +88,48 @@ namespace } } -namespace test_cases +TEST(ERepository, InstallEAPI3) { - struct ERepositoryInstallEAPI3Test : 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_3_dir" / "repo")); + keys->insert("profiles", stringify(FSPath::cwd() / "e_repository_TEST_3_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_3_dir" / "distdir")); + keys->insert("builddir", stringify(FSPath::cwd() / "e_repository_TEST_3_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 + )); + { - ERepositoryInstallEAPI3Test() : TestCase("install_eapi_3") { } - - 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_3_dir" / "repo")); - keys->insert("profiles", stringify(FSPath::cwd() / "e_repository_TEST_3_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_3_dir" / "distdir")); - keys->insert("builddir", stringify(FSPath::cwd() / "e_repository_TEST_3_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("prefix", true); - const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches( - PackageDepSpec(parse_user_package_dep_spec("=cat/prefix-3", - &env, { })), make_null_shared_ptr(), { }))]->last()); - TEST_CHECK(bool(id)); - TEST_CHECK_EQUAL(visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value(), "3"); - id->perform_action(action); - } - } - } test_e_repository_install_eapi_3; + const std::shared_ptr<const PackageID> id(*env[selection::RequireExactlyOne(generator::Matches( + PackageDepSpec(parse_user_package_dep_spec("=cat/prefix-3", + &env, { })), make_null_shared_ptr(), { }))]->last()); + ASSERT_TRUE(bool(id)); + EXPECT_EQ("3", visitor_cast<const MetadataValueKey<std::string> >(**id->find_metadata("EAPI"))->value()); + id->perform_action(action); + } } |