aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-07 15:26:27 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-07 15:26:27 +0000
commit0c7427af5d5f654612d7d4b0e44af572a4d6803e (patch)
tree52de7fbc930ed43d34b0002aebcd3d3b8ea511da
parent77028fc1db2d97f4e93f7458e3acce492f034c8c (diff)
downloadpaludis-0c7427af5d5f654612d7d4b0e44af572a4d6803e.tar.gz
paludis-0c7427af5d5f654612d7d4b0e44af572a4d6803e.tar.xz
Extend portage repository test coverage. Don't explode when paludis_command is requested from a test environment, so that we can check metadata generation in a test.
-rw-r--r--paludis/portage_repository_TEST.cc57
-rwxr-xr-xpaludis/portage_repository_TEST_setup.sh56
-rw-r--r--paludis/test_environment.hh4
3 files changed, 114 insertions, 3 deletions
diff --git a/paludis/portage_repository_TEST.cc b/paludis/portage_repository_TEST.cc
index eb1f50f..a3c10c8 100644
--- a/paludis/portage_repository_TEST.cc
+++ b/paludis/portage_repository_TEST.cc
@@ -325,7 +325,6 @@ namespace test_cases
}
} test_portage_repository_has_version;
-
struct PortageRepositoryVersionsTest : TestCase
{
PortageRepositoryVersionsTest() : TestCase("versions") { }
@@ -362,5 +361,61 @@ namespace test_cases
}
}
} test_portage_repository_versions;
+
+ struct PortageRepositoryMetadataCachedTest : TestCase
+ {
+ PortageRepositoryMetadataCachedTest() : TestCase("metadata cached") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ std::map<std::string, std::string> keys;
+ keys.insert(std::make_pair("format", "portage"));
+ keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo6"));
+ keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo6/profiles/profile"));
+ PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
+ &env, env.package_database().raw_pointer(), keys));
+
+ for (int pass = 1 ; pass <= 2 ; ++pass)
+ {
+ TestMessageSuffix pass_suffix(stringify(pass), true);
+ VersionMetadata::ConstPointer m(0);
+
+ m = repo->version_metadata(QualifiedPackageName("cat-one/pkg-one"), VersionSpec("1"));
+ TEST_CHECK_EQUAL(m->get(vmk_description), "the-description");
+
+ m = repo->version_metadata(QualifiedPackageName("cat-one/pkg-one"), VersionSpec("2"));
+ TEST_CHECK_EQUAL(m->get(vmk_description), "");
+
+ m = repo->version_metadata(QualifiedPackageName("cat-two/pkg-one"), VersionSpec("1"));
+ TEST_CHECK_EQUAL(m->get(vmk_description), "");
+ }
+ }
+ } test_portage_repository_metadata_cached;
+
+ struct PortageRepositoryMetadataUncachedTest : TestCase
+ {
+ PortageRepositoryMetadataUncachedTest() : TestCase("metadata uncached") { }
+
+ void run()
+ {
+ TestEnvironment env;
+ std::map<std::string, std::string> keys;
+ keys.insert(std::make_pair("format", "portage"));
+ keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo7"));
+ keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo7/profiles/profile"));
+ PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
+ &env, env.package_database().raw_pointer(), keys));
+
+ for (int pass = 1 ; pass <= 2 ; ++pass)
+ {
+ TestMessageSuffix pass_suffix(stringify(pass), true);
+ VersionMetadata::ConstPointer m(0);
+
+ m = repo->version_metadata(QualifiedPackageName("cat-one/pkg-one"), VersionSpec("1"));
+ TEST_CHECK_EQUAL(m->get(vmk_description), "The Description");
+ }
+ }
+ } test_portage_repository_metadata_uncached;
}
diff --git a/paludis/portage_repository_TEST_setup.sh b/paludis/portage_repository_TEST_setup.sh
index 6b25a41..07f8542 100755
--- a/paludis/portage_repository_TEST_setup.sh
+++ b/paludis/portage_repository_TEST_setup.sh
@@ -81,3 +81,59 @@ END
cd ..
+mkdir -p repo6/{eclass,distfiles,profiles/profile} || exit 1
+mkdir -p repo6/cat-one/pkg-one || exit 1
+mkdir -p repo6/metadata/cache/cat-one
+cd repo6 || exit 1
+echo "test-repo-6" > profiles/repo_name || exit 1
+cat <<END > profiles/categories || exit 1
+cat-one
+END
+cat <<END > profiles/profile/make.defaults
+ARCH=test
+END
+cat <<END > cat-one/pkg-one/pkg-one-1.ebuild || exit 1
+END
+cat <<END > metadata/cache/cat-one/pkg-one-1
+the/depend
+the/rdepend
+the-slot
+the-src-uri
+the-restrict
+the-homepage
+the-license
+the-description
+the-keywords
+the-inherited
+the-iuse
+unused
+the/pdepend
+the/provide
+0
+END
+cd ..
+
+
+mkdir -p repo7/{eclass,distfiles,profiles/profile} || exit 1
+mkdir -p repo7/cat-one/pkg-one || exit 1
+mkdir -p repo7/metadata/cache/cat-one
+cd repo7 || exit 1
+echo "test-repo-7" > profiles/repo_name || exit 1
+cat <<END > profiles/categories || exit 1
+cat-one
+END
+cat <<END > profiles/profile/make.defaults
+ARCH=test
+END
+cat <<END > cat-one/pkg-one/pkg-one-1.ebuild || exit 1
+DESCRIPTION="The Description"
+HOMEPAGE="http://example.com/"
+SRC_URI=""
+SLOT="0"
+IUSE=""
+LICENSE="GPL-2"
+KEYWORDS="test"
+END
+cd ..
+
+
diff --git a/paludis/test_environment.hh b/paludis/test_environment.hh
index 50a97f3..24616bc 100644
--- a/paludis/test_environment.hh
+++ b/paludis/test_environment.hh
@@ -51,9 +51,9 @@ namespace paludis
return "";
}
- virtual std::string paludis_command() const PALUDIS_ATTRIBUTE((noreturn))
+ virtual std::string paludis_command() const
{
- throw InternalError(PALUDIS_HERE, "Cannot use paludis_command in a test environment");
+ return "false";
}
};
}