aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-12 12:11:04 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-12 12:12:01 +0100
commit2d0feb6ef4b6b39f6322cf446d358c808b52f596 (patch)
tree8067e7d279ce9a3c93cff68cef17208a9957c523
parent34969fdda92f5a5ea28ee980c5fe76e59039dbdf (diff)
downloadpaludis-2d0feb6ef4b6b39f6322cf446d358c808b52f596.tar.gz
paludis-2d0feb6ef4b6b39f6322cf446d358c808b52f596.tar.xz
Test that stale files get removed
-rw-r--r--paludis/repositories/e/vdb_repository_TEST.cc60
-rwxr-xr-xpaludis/repositories/e/vdb_repository_TEST_setup.sh27
2 files changed, 87 insertions, 0 deletions
diff --git a/paludis/repositories/e/vdb_repository_TEST.cc b/paludis/repositories/e/vdb_repository_TEST.cc
index f58b7dd..1c077d1 100644
--- a/paludis/repositories/e/vdb_repository_TEST.cc
+++ b/paludis/repositories/e/vdb_repository_TEST.cc
@@ -456,3 +456,63 @@ TEST(VDBRepository, PhaseOrdering)
}
}
+TEST(VDBRepository, RemoveStaleFiles)
+{
+ TestEnvironment env(FSPath(stringify(FSPath::cwd() / "vdb_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() / "vdb_repository_TEST_dir" / "removestalefiles"));
+ keys->insert("profiles", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "removestalefiles/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() / "vdb_repository_TEST_dir" / "distdir"));
+ keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "build"));
+ keys->insert("root", stringify(FSPath("vdb_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", "vdb");
+ keys->insert("names_cache", "/var/empty");
+ keys->insert("provides_cache", "/var/empty");
+ keys->insert("location", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "removestalefilesvdb"));
+ keys->insert("builddir", stringify(FSPath::cwd() / "vdb_repository_TEST_dir" / "build"));
+ keys->insert("root", stringify(FSPath("vdb_repository_TEST_dir/root").realpath()));
+ std::shared_ptr<Repository> vdb_repo(VDBRepository::VDBRepository::repository_factory_create(&env,
+ std::bind(from_keys, keys, std::placeholders::_1)));
+ env.add_repository(0, vdb_repo);
+
+ EXPECT_TRUE(vdb_repo->package_ids(QualifiedPackageName("cat/pkg"), { })->empty());
+
+ EXPECT_FALSE((FSPath("vdb_repository_TEST_dir/root") / "stale-first").stat().exists());
+ EXPECT_FALSE((FSPath("vdb_repository_TEST_dir/root") / "stale-both").stat().exists());
+
+ {
+ ::setenv("VDB_REPOSITORY_TEST_STALE", "true", 1);
+ install(env, vdb_repo, "=cat/pkg-0::removestalefiles", "");
+ vdb_repo->invalidate();
+
+ std::shared_ptr<const PackageIDSequence> ids(vdb_repo->package_ids(QualifiedPackageName("cat/pkg"), { }));
+ EXPECT_EQ("cat/pkg-0::installed", join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "));
+ }
+
+ EXPECT_TRUE((FSPath("vdb_repository_TEST_dir/root") / "stale-first").stat().exists());
+ EXPECT_TRUE((FSPath("vdb_repository_TEST_dir/root") / "stale-both").stat().exists());
+
+ {
+ ::setenv("VDB_REPOSITORY_TEST_STALE", "false", 1);
+ install(env, vdb_repo, "=cat/pkg-0::removestalefiles", "=cat/pkg-0::installed");
+ vdb_repo->invalidate();
+
+ std::shared_ptr<const PackageIDSequence> ids(vdb_repo->package_ids(QualifiedPackageName("cat/pkg"), { }));
+ EXPECT_EQ("cat/pkg-0::installed", join(indirect_iterator(ids->begin()), indirect_iterator(ids->end()), " "));
+ }
+
+ EXPECT_FALSE((FSPath("vdb_repository_TEST_dir/root") / "stale-first").stat().exists());
+ EXPECT_TRUE((FSPath("vdb_repository_TEST_dir/root") / "stale-both").stat().exists());
+}
+
diff --git a/paludis/repositories/e/vdb_repository_TEST_setup.sh b/paludis/repositories/e/vdb_repository_TEST_setup.sh
index e5eabbe..022b6b2 100755
--- a/paludis/repositories/e/vdb_repository_TEST_setup.sh
+++ b/paludis/repositories/e/vdb_repository_TEST_setup.sh
@@ -152,3 +152,30 @@ cp postinsttest_src1/cat/pkg/pkg-{0,1}.ebuild
cp postinsttest_src1/cat/pkg/pkg-{0,1.1}.ebuild
cp postinsttest_src1/cat/pkg/pkg-{0,2}.ebuild
+mkdir -p removestalefilesvdb removestalefiles/{eclass,profiles/profile,cat/pkg} || exit 1
+
+cat <<END > removestalefiles/profiles/profile/make.defaults
+ARCH=test
+USERLAND="GNU"
+KERNEL="linux"
+CHOST="i286-badger-linux-gnu"
+END
+echo removestalefiles >removestalefiles/profiles/repo_name
+echo cat >removestalefiles/profiles/categories
+
+cat <<'END' >removestalefiles/cat/pkg/pkg-0.ebuild
+SLOT="0"
+KEYWORDS="test"
+S="${WORKDIR}"
+
+src_unpack() {
+ touch stale-both
+ $VDB_REPOSITORY_TEST_STALE && touch stale-first
+}
+
+src_install() {
+ insinto /
+ doins stale-*
+}
+END
+