aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-01-28 12:15:40 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-01-28 12:15:40 +0000
commitaed97a6ac3da32fa395a3187d058445071a39bc8 (patch)
tree45a6e2f69780f93e657b1e92a3a7b5f31b5720d6
parent7d482d4e6b69b9b5576618616ede5044487f8cd1 (diff)
downloadpaludis-aed97a6ac3da32fa395a3187d058445071a39bc8.tar.gz
paludis-aed97a6ac3da32fa395a3187d058445071a39bc8.tar.xz
Add some more tests. Fix bug on || ( a b ) where a depends upon a non-available package.
-rw-r--r--paludis/dep_list.cc8
-rw-r--r--paludis/dep_list_TEST.cc125
2 files changed, 124 insertions, 9 deletions
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index ff95841..bdc5fce 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.cc
@@ -208,9 +208,12 @@ DepList::_add_raw(const DepAtom * const atom)
/* we need to make sure that merge_list doesn't get h0rked in the
* event of a failure. */
bool merge_list_was_empty(_implementation->merge_list.empty());
- std::list<DepListEntry>::iterator save_end;
+ std::list<DepListEntry>::iterator save_end, save_first;
if (! merge_list_was_empty)
+ {
+ save_first = _implementation->merge_list.begin();
save_end = previous(_implementation->merge_list.end());
+ }
try
{
@@ -221,7 +224,10 @@ DepList::_add_raw(const DepAtom * const atom)
if (merge_list_was_empty)
_implementation->merge_list.clear();
else
+ {
_implementation->merge_list.erase(next(save_end), _implementation->merge_list.end());
+ _implementation->merge_list.erase(_implementation->merge_list.begin(), save_first);
+ }
throw;
}
}
diff --git a/paludis/dep_list_TEST.cc b/paludis/dep_list_TEST.cc
index fc602b2..2627d7d 100644
--- a/paludis/dep_list_TEST.cc
+++ b/paludis/dep_list_TEST.cc
@@ -34,28 +34,29 @@ namespace test_cases
FakeRepository::Pointer repo;
std::deque<std::string> expected;
std::string merge_target;
+ bool done_populate;
DepListTestCaseBase(const char c) :
TestCase("dep list " + std::string(1, c)),
env(),
- repo(new FakeRepository(RepositoryName("repo")))
+ repo(new FakeRepository(RepositoryName("repo"))),
+ done_populate(false)
{
env.package_database()->add_repository(repo);
}
- bool repeatable() const
- {
- return false;
- }
-
virtual void populate_repo() = 0;
virtual void populate_expected() = 0;
void run()
{
- populate_repo();
- populate_expected();
+ if (! done_populate)
+ {
+ populate_repo();
+ populate_expected();
+ done_populate = true;
+ }
check_lists();
}
@@ -254,6 +255,114 @@ namespace test_cases
}
} test_dep_list_i;
+ struct DepListTestCaseJ : DepListTestCase<'j'>
+ {
+ void populate_repo()
+ {
+ repo->add_version("j", "one", "1")->set(vmk_depend, "|| ( j/two j/three )");
+ repo->add_version("j", "two", "1");
+ repo->add_version("j", "three", "1");
+ }
+
+ void populate_expected()
+ {
+ merge_target = "j/one";
+ expected.push_back("j/two-1:0::repo");
+ expected.push_back("j/one-1:0::repo");
+ }
+ } test_dep_list_j;
+
+ struct DepListTestCaseK : DepListTestCase<'k'>
+ {
+ void populate_repo()
+ {
+ repo->add_version("k", "one", "1")->set(vmk_depend, "k/two k/three");
+ repo->add_version("k", "two", "1");
+ repo->add_version("k", "three", "1")->set(vmk_depend, "|| ( k/two k/four )");
+ repo->add_version("k", "four", "1");
+ }
+
+ void populate_expected()
+ {
+ merge_target = "k/one";
+ expected.push_back("k/two-1:0::repo");
+ expected.push_back("k/three-1:0::repo");
+ expected.push_back("k/one-1:0::repo");
+ }
+ } test_dep_list_k;
+
+ struct DepListTestCaseL : DepListTestCase<'l'>
+ {
+ void populate_repo()
+ {
+ repo->add_version("l", "one", "1")->set(vmk_depend, "|| ( ( l/two l/three ) l/four )");
+ repo->add_version("l", "two", "1");
+ repo->add_version("l", "three", "1");
+ repo->add_version("l", "four", "1");
+ }
+
+ void populate_expected()
+ {
+ merge_target = "l/one";
+ expected.push_back("l/two-1:0::repo");
+ expected.push_back("l/three-1:0::repo");
+ expected.push_back("l/one-1:0::repo");
+ }
+ } test_dep_list_l;
+
+ struct DepListTestCaseM : DepListTestCase<'m'>
+ {
+ void populate_repo()
+ {
+ repo->add_version("m", "one", "1")->set(vmk_depend, "m/two m/three m/four");
+ repo->add_version("m", "two", "1");
+ repo->add_version("m", "three", "1");
+ repo->add_version("m", "four", "1")->set(vmk_depend, "|| ( ( m/two m/three ) m/five )");
+ }
+
+ void populate_expected()
+ {
+ merge_target = "m/one";
+ expected.push_back("m/two-1:0::repo");
+ expected.push_back("m/three-1:0::repo");
+ expected.push_back("m/four-1:0::repo");
+ expected.push_back("m/one-1:0::repo");
+ }
+ } test_dep_list_m;
+
+ struct DepListTestCaseN : DepListTestCase<'n'>
+ {
+ void populate_repo()
+ {
+ repo->add_version("n", "one", "1")->set(vmk_depend, "|| ( n/two n/three )");
+ repo->add_version("n", "three", "1");
+ }
+
+ void populate_expected()
+ {
+ merge_target = "n/one";
+ expected.push_back("n/three-1:0::repo");
+ expected.push_back("n/one-1:0::repo");
+ }
+ } test_dep_list_n;
+
+ struct DepListTestCaseO : DepListTestCase<'o'>
+ {
+ void populate_repo()
+ {
+ repo->add_version("o", "one", "1")->set(vmk_depend, "|| ( o/two o/three )");
+ repo->add_version("o", "two", "1")->set(vmk_depend, "o/four");
+ repo->add_version("o", "three", "1");
+ }
+
+ void populate_expected()
+ {
+ merge_target = "o/one";
+ expected.push_back("o/three-1:0::repo");
+ expected.push_back("o/one-1:0::repo");
+ }
+ } test_dep_list_o;
+
struct DepListTestCaseTransactionalAdd : TestCase
{
DepListTestCaseTransactionalAdd() : TestCase("dep list transactional add") { }