aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-26 22:50:42 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-26 22:50:42 +0000
commit35a9f42174ccb4c50ecb74cf1d55c3564a76ed78 (patch)
tree248f119eeb130629157898ef4df6703447fcfde7
parent554b10b87698dfcc0269d262a268e2e093d080b1 (diff)
downloadpaludis-35a9f42174ccb4c50ecb74cf1d55c3564a76ed78.tar.gz
paludis-35a9f42174ccb4c50ecb74cf1d55c3564a76ed78.tar.xz
gtest more
-rw-r--r--paludis/repositories/e/Makefile.am4
-rw-r--r--paludis/repositories/e/e_repository_TEST_symlink_rewriting.cc121
2 files changed, 57 insertions, 68 deletions
diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am
index 1359a58..81436ec 100644
--- a/paludis/repositories/e/Makefile.am
+++ b/paludis/repositories/e/Makefile.am
@@ -316,13 +316,15 @@ e_repository_TEST_replacing_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
e_repository_TEST_symlink_rewriting_SOURCES = e_repository_TEST_symlink_rewriting.cc
e_repository_TEST_symlink_rewriting_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_symlink_rewriting_CXXFLAGS = $(AM_CXXFLAGS) -I$(top_srcdir) @PALUDIS_CXXFLAGS_NO_DEBUGGING@
+e_repository_TEST_symlink_rewriting_LDFLAGS = @GTESTDEPS_LDFLAGS@ @GTESTDEPS_LIBS@
+
vdb_repository_TEST_SOURCES = vdb_repository_TEST.cc
vdb_repository_TEST_LDADD = \
diff --git a/paludis/repositories/e/e_repository_TEST_symlink_rewriting.cc b/paludis/repositories/e/e_repository_TEST_symlink_rewriting.cc
index 366a752..007e9d3 100644
--- a/paludis/repositories/e/e_repository_TEST_symlink_rewriting.cc
+++ b/paludis/repositories/e/e_repository_TEST_symlink_rewriting.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/standard_output_manager.hh>
#include <paludis/util/safe_ifstream.hh>
#include <paludis/util/make_null_shared_ptr.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,69 +88,51 @@ namespace
}
}
-namespace test_cases
+TEST(ERepository, SymlinkRewriting)
{
- struct ERepositorySymlinkRewritingTest : TestCase
- {
- ERepositorySymlinkRewritingTest() : TestCase("symlink_rewriting") { }
-
- 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_symlink_rewriting_dir" / "repo"));
- keys->insert("profiles", stringify(FSPath::cwd() / "e_repository_TEST_symlink_rewriting_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_symlink_rewriting_dir" / "distdir"));
- keys->insert("builddir", stringify(FSPath::cwd() / "e_repository_TEST_symlink_rewriting_dir" / "symlinked_build"));
- keys->insert("root", stringify(FSPath(stringify(FSPath::cwd() / "e_repository_TEST_symlink_rewriting_dir" / "root")).realpath()));
- std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, repo);
-
- keys = std::make_shared<Map<std::string, std::string>>();
- keys->insert("format", "vdb");
- keys->insert("names_cache", "/var/empty");
- keys->insert("provides_cache", "/var/empty");
- keys->insert("location", stringify(FSPath::cwd() / "e_repository_TEST_symlink_rewriting_dir" / "vdb"));
- keys->insert("builddir", stringify(FSPath::cwd() / "e_repository_TEST_symlink_rewriting_dir" / "build"));
- keys->insert("root", stringify(FSPath(stringify(FSPath::cwd() / "e_repository_TEST_symlink_rewriting_dir" / "root")).realpath()));
- std::shared_ptr<Repository> installed_repo(VDBRepository::repository_factory_create(&env,
- std::bind(from_keys, keys, std::placeholders::_1)));
- env.add_repository(1, 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/pkg",
- &env, { })), make_null_shared_ptr(), { }))]->last());
- TEST_CHECK(bool(id));
-
- id->perform_action(action);
- TEST_CHECK_EQUAL(FSPath(stringify(FSPath::cwd() / "e_repository_TEST_symlink_rewriting_dir" / "root/bar")).readlink(), "/foo");
- }
- } test_e_repository_symlink_rewriting;
+ 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_symlink_rewriting_dir" / "repo"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "e_repository_TEST_symlink_rewriting_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_symlink_rewriting_dir" / "distdir"));
+ keys->insert("builddir", stringify(FSPath::cwd() / "e_repository_TEST_symlink_rewriting_dir" / "symlinked_build"));
+ keys->insert("root", stringify(FSPath(stringify(FSPath::cwd() / "e_repository_TEST_symlink_rewriting_dir" / "root")).realpath()));
+ std::shared_ptr<Repository> repo(ERepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, repo);
+
+ keys = std::make_shared<Map<std::string, std::string>>();
+ keys->insert("format", "vdb");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("provides_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "e_repository_TEST_symlink_rewriting_dir" / "vdb"));
+ keys->insert("builddir", stringify(FSPath::cwd() / "e_repository_TEST_symlink_rewriting_dir" / "build"));
+ keys->insert("root", stringify(FSPath(stringify(FSPath::cwd() / "e_repository_TEST_symlink_rewriting_dir" / "root")).realpath()));
+ std::shared_ptr<Repository> installed_repo(VDBRepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(1, 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/pkg",
+ &env, { })), make_null_shared_ptr(), { }))]->last());
+ ASSERT_TRUE(bool(id));
+
+ id->perform_action(action);
+ EXPECT_EQ("/foo", FSPath(stringify(FSPath::cwd() / "e_repository_TEST_symlink_rewriting_dir" / "root/bar")).readlink());
}