summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2015-11-12 01:20:01 +0100
committerAllan McRae <allan@archlinux.org>2015-11-28 13:53:24 +0100
commit5312e683fcc800e528c01d652aab30e862e44a0b (patch)
tree5890a6e607e4c9f7478c125ad09e07b700bfb324 /test
parent8ad893732d44960d04cb476c436b7ea045626f07 (diff)
downloadpacman-5312e683fcc800e528c01d652aab30e862e44a0b.tar.gz
pacman-5312e683fcc800e528c01d652aab30e862e44a0b.tar.xz
hooks: pass matched targets to hooks
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'test')
-rw-r--r--test/pacman/tests/TESTS1
-rw-r--r--test/pacman/tests/hook-target-list.py40
2 files changed, 41 insertions, 0 deletions
diff --git a/test/pacman/tests/TESTS b/test/pacman/tests/TESTS
index afd2e698..e330896b 100644
--- a/test/pacman/tests/TESTS
+++ b/test/pacman/tests/TESTS
@@ -59,6 +59,7 @@ TESTS += test/pacman/tests/hook-invalid-trigger.py
TESTS += test/pacman/tests/hook-pkg-install-trigger-match.py
TESTS += test/pacman/tests/hook-pkg-remove-trigger-match.py
TESTS += test/pacman/tests/hook-pkg-upgrade-trigger-match.py
+TESTS += test/pacman/tests/hook-target-list.py
TESTS += test/pacman/tests/hook-upgrade-trigger-no-match.py
TESTS += test/pacman/tests/ignore001.py
TESTS += test/pacman/tests/ignore002.py
diff --git a/test/pacman/tests/hook-target-list.py b/test/pacman/tests/hook-target-list.py
new file mode 100644
index 00000000..6dd6c4d8
--- /dev/null
+++ b/test/pacman/tests/hook-target-list.py
@@ -0,0 +1,40 @@
+self.description = "Hook with NeedsTargets"
+
+self.add_hook("hook",
+ """
+ [Trigger]
+ Type = Package
+ Operation = Install
+ Target = foo
+
+ # duplicate trigger to check that duplicate targets are removed
+ [Trigger]
+ Type = Package
+ Operation = Install
+ Target = foo
+
+ [Trigger]
+ Type = File
+ Operation = Install
+ # matches files in 'file/' but not 'file/' itself
+ Target = file/?*
+
+ [Action]
+ When = PreTransaction
+ Exec = bin/sh -c 'while read -r tgt; do printf "%s\\n" "$tgt"; done > var/log/hook-output'
+ NeedsTargets
+ """);
+
+p1 = pmpkg("foo")
+p1.files = ["file/foo"]
+self.addpkg(p1)
+
+p2 = pmpkg("bar")
+p2.files = ["file/bar"]
+self.addpkg(p2)
+
+self.args = "-U %s %s" % (p1.filename(), p2.filename())
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("PKG_EXIST=foo")
+self.addrule("FILE_CONTENTS=var/log/hook-output|file/bar\nfile/foo\nfoo\n")