aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-16 03:28:30 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-16 03:28:30 +0000
commit97f71bcdd71593fbf642341672c1db9fb72731c1 (patch)
treef8a5f1de54780f3d5fc4a01216df9c0e9d94a342
parent9c7c820168a836afaa256008be1883fbce630a1c (diff)
downloadpaludis-97f71bcdd71593fbf642341672c1db9fb72731c1.tar.gz
paludis-97f71bcdd71593fbf642341672c1db9fb72731c1.tar.xz
More hooker tests
-rw-r--r--paludis/hooker_TEST.cc22
-rwxr-xr-xpaludis/hooker_TEST_setup.sh57
2 files changed, 79 insertions, 0 deletions
diff --git a/paludis/hooker_TEST.cc b/paludis/hooker_TEST.cc
index abda16d..2576cf9 100644
--- a/paludis/hooker_TEST.cc
+++ b/paludis/hooker_TEST.cc
@@ -72,7 +72,18 @@ namespace test_cases
void run()
{
+ TestEnvironment env;
+ Hooker hooker(&env);
+
+ FSEntry("hooker_TEST_dir/bad_hooks.out").unlink();
+
+ hooker.add_dir(FSEntry("hooker_TEST_dir/"), false);
+ TEST_CHECK_EQUAL(hooker.perform_hook(Hook("bad_hooks")), 123);
+
+ std::ifstream f(stringify(FSEntry("hooker_TEST_dir/bad_hooks.out")).c_str());
+ std::string line((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
+ TEST_CHECK_EQUAL(line, "one\nthree\n");
}
} test_hooker_bad_hooks;
@@ -82,7 +93,18 @@ namespace test_cases
void run()
{
+ TestEnvironment env;
+ Hooker hooker(&env);
+
+ FSEntry("hooker_TEST_dir/cycles.out").unlink();
+
+ hooker.add_dir(FSEntry("hooker_TEST_dir/"), false);
+ TEST_CHECK_EQUAL(hooker.perform_hook(Hook("cycles")), 0);
+
+ std::ifstream f(stringify(FSEntry("hooker_TEST_dir/cycles.out")).c_str());
+ std::string line((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
+ TEST_CHECK_EQUAL(line, "b\na\ng\nf\ni\n");
}
} test_hooker_cycles;
}
diff --git a/paludis/hooker_TEST_setup.sh b/paludis/hooker_TEST_setup.sh
index 06c4ca5..b967c19 100755
--- a/paludis/hooker_TEST_setup.sh
+++ b/paludis/hooker_TEST_setup.sh
@@ -104,3 +104,60 @@ for a in a b c d e f g h i j k ; do
ln -s ../ordering.common ordering/${a}.hook
done
+mkdir bad_hooks
+cat <<"END" > bad_hooks.common
+hook_run_bad_hooks() {
+ basename ${HOOK_FILE} | sed -e 's,\.hook$,,' >> hooker_TEST_dir/bad_hooks.out
+}
+END
+chmod +x bad_hooks.common
+
+for a in one three ; do
+ ln -s ../bad_hooks.common bad_hooks/${a}.hook
+done
+
+cat <<"END" > bad_hooks/two.hook
+asdf
+END
+chmod +x bad_hooks/two.hook
+
+mkdir cycles
+cat <<"END" > cycles.common
+hook_run_cycles() {
+ basename ${HOOK_FILE} | sed -e 's,\.hook$,,' >> hooker_TEST_dir/cycles.out
+}
+
+hook_depend_cycles() {
+ case $(basename ${HOOK_FILE} | sed -e 's,\.hook$,,' ) in
+ c)
+ echo d;
+ ;;
+ d)
+ echo e;
+ ;;
+ e)
+ echo c;
+ ;;
+ f)
+ echo g;
+ ;;
+ h)
+ echo h;
+ ;;
+ esac
+}
+
+hook_after_cycles() {
+ case $(basename ${HOOK_FILE} | sed -e 's,\.hook$,,' ) in
+ a)
+ echo b
+ ;;
+ esac
+}
+END
+chmod +x cycles.common
+
+for a in a b c d e f g h i ; do
+ ln -s ../cycles.common cycles/${a}.hook
+done
+