summaryrefslogtreecommitdiffstats
path: root/test/pacman
diff options
context:
space:
mode:
Diffstat (limited to 'test/pacman')
-rw-r--r--test/pacman/tests/TESTS9
-rw-r--r--test/pacman/tests/hook-abortonfail.py25
-rw-r--r--test/pacman/tests/hook-file-change-packages.py32
-rw-r--r--test/pacman/tests/hook-file-remove-trigger-match.py24
-rw-r--r--test/pacman/tests/hook-file-upgrade-nomatch.py27
-rw-r--r--test/pacman/tests/hook-invalid-trigger.py25
-rw-r--r--test/pacman/tests/hook-pkg-install-trigger-match.py23
-rw-r--r--test/pacman/tests/hook-pkg-remove-trigger-match.py23
-rw-r--r--test/pacman/tests/hook-pkg-upgrade-trigger-match.py26
-rw-r--r--test/pacman/tests/hook-upgrade-trigger-no-match.py23
10 files changed, 237 insertions, 0 deletions
diff --git a/test/pacman/tests/TESTS b/test/pacman/tests/TESTS
index cce0d582..8ad1b9c0 100644
--- a/test/pacman/tests/TESTS
+++ b/test/pacman/tests/TESTS
@@ -50,6 +50,15 @@ TESTS += test/pacman/tests/fileconflict025.py
TESTS += test/pacman/tests/fileconflict030.py
TESTS += test/pacman/tests/fileconflict031.py
TESTS += test/pacman/tests/fileconflict032.py
+TESTS += test/pacman/tests/hook-abortonfail.py
+TESTS += test/pacman/tests/hook-file-change-packages.py
+TESTS += test/pacman/tests/hook-file-remove-trigger-match.py
+TESTS += test/pacman/tests/hook-file-upgrade-nomatch.py
+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-upgrade-trigger-no-match.py
TESTS += test/pacman/tests/ignore001.py
TESTS += test/pacman/tests/ignore002.py
TESTS += test/pacman/tests/ignore003.py
diff --git a/test/pacman/tests/hook-abortonfail.py b/test/pacman/tests/hook-abortonfail.py
new file mode 100644
index 00000000..e5044c08
--- /dev/null
+++ b/test/pacman/tests/hook-abortonfail.py
@@ -0,0 +1,25 @@
+self.description = "Abort transaction on hook failure with AbortOnFail"
+
+self.add_script("hook-script", ": > hook-output; exit 1")
+self.add_hook("hook",
+ """
+ [Trigger]
+ Type = Package
+ Operation = Install
+ Target = foo
+
+ [Action]
+ When = PreTransaction
+ Exec = bin/hook-script
+ AbortOnFail
+ """);
+
+sp = pmpkg("foo")
+self.addpkg2db("sync", sp)
+
+self.args = "-S foo"
+
+self.addrule("!PACMAN_RETCODE=0")
+self.addrule("!PKG_EXIST=foo")
+self.addrule("FILE_EXIST=hook-output")
+self.addrule("PACMAN_OUTPUT=failed to run transaction hooks")
diff --git a/test/pacman/tests/hook-file-change-packages.py b/test/pacman/tests/hook-file-change-packages.py
new file mode 100644
index 00000000..ad96fc14
--- /dev/null
+++ b/test/pacman/tests/hook-file-change-packages.py
@@ -0,0 +1,32 @@
+self.description = "Triggering file moves between packages"
+
+self.add_script("hook-script", ": > hook-output")
+self.add_hook("hook",
+ """
+ [Trigger]
+ Type = File
+ Operation = Upgrade
+ Target = bin/foo
+
+ [Action]
+ When = PreTransaction
+ Exec = bin/hook-script
+ """);
+
+lp = pmpkg("foo", "1-1")
+lp.files = ["bin/foo"]
+self.addpkg2db("local", lp)
+
+sp1 = pmpkg("foo", "1-2")
+self.addpkg2db("sync", sp1)
+
+sp2 = pmpkg("bar", "1-2")
+sp2.files = ["bin/foo"]
+self.addpkg2db("sync", sp2)
+
+self.args = "-S foo bar"
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("PKG_VERSION=foo|1-2")
+self.addrule("PKG_VERSION=bar|1-2")
+self.addrule("FILE_EXIST=hook-output")
diff --git a/test/pacman/tests/hook-file-remove-trigger-match.py b/test/pacman/tests/hook-file-remove-trigger-match.py
new file mode 100644
index 00000000..6c9375c0
--- /dev/null
+++ b/test/pacman/tests/hook-file-remove-trigger-match.py
@@ -0,0 +1,24 @@
+self.description = "Remove a package matching a file removal hook"
+
+self.add_script("hook-script", ": > hook-output")
+self.add_hook("hook",
+ """
+ [Trigger]
+ Type = File
+ Operation = Remove
+ Target = bin/foo
+
+ [Action]
+ When = PreTransaction
+ Exec = bin/hook-script
+ """);
+
+lp = pmpkg("foo")
+lp.files = ["bin/foo"]
+self.addpkg2db("local", lp)
+
+self.args = "-R foo"
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("!PKG_EXIST=foo")
+self.addrule("FILE_EXIST=hook-output")
diff --git a/test/pacman/tests/hook-file-upgrade-nomatch.py b/test/pacman/tests/hook-file-upgrade-nomatch.py
new file mode 100644
index 00000000..e984d376
--- /dev/null
+++ b/test/pacman/tests/hook-file-upgrade-nomatch.py
@@ -0,0 +1,27 @@
+self.description = "Add and remove separate files that match an upgrade hook"
+
+self.add_script("hook-script", ": > hook-output")
+self.add_hook("hook",
+ """
+ [Trigger]
+ Type = File
+ Operation = Upgrade
+ Target = bin/?*
+
+ [Action]
+ When = PreTransaction
+ Exec = bin/hook-script
+ """);
+
+lp = pmpkg("foo")
+lp.files = ["bin/foo"]
+self.addpkg2db("local", lp)
+
+sp = pmpkg("foo")
+sp.files = ["bin/bar"]
+self.addpkg2db("sync", sp)
+
+self.args = "-S foo"
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("!FILE_EXIST=hook-output")
diff --git a/test/pacman/tests/hook-invalid-trigger.py b/test/pacman/tests/hook-invalid-trigger.py
new file mode 100644
index 00000000..72ac6103
--- /dev/null
+++ b/test/pacman/tests/hook-invalid-trigger.py
@@ -0,0 +1,25 @@
+self.description = "Abort on invalid hook trigger"
+
+self.add_script("hook-script", ": > hook-output")
+self.add_hook("hook",
+ """
+ [Trigger]
+ InvalidTriggerOption
+ Type = Package
+ Operation = Install
+ Target = foo
+
+ [Action]
+ When = PreTransaction
+ Exec = bin/hook-script
+ """);
+
+sp = pmpkg("foo")
+self.addpkg2db("sync", sp)
+
+self.args = "-S foo"
+
+self.addrule("!PACMAN_RETCODE=0")
+self.addrule("!PKG_EXIST=foo")
+self.addrule("!FILE_EXIST=hook-output")
+self.addrule("PACMAN_OUTPUT=failed to run transaction hooks")
diff --git a/test/pacman/tests/hook-pkg-install-trigger-match.py b/test/pacman/tests/hook-pkg-install-trigger-match.py
new file mode 100644
index 00000000..00dfb32b
--- /dev/null
+++ b/test/pacman/tests/hook-pkg-install-trigger-match.py
@@ -0,0 +1,23 @@
+self.description = "Install a package matching a hook"
+
+self.add_script("hook-script", ": > hook-output")
+self.add_hook("hook",
+ """
+ [Trigger]
+ Type = Package
+ Operation = Install
+ Target = foo
+
+ [Action]
+ When = PreTransaction
+ Exec = bin/hook-script
+ """);
+
+sp = pmpkg("foo")
+self.addpkg2db("sync", sp)
+
+self.args = "-S foo"
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("PKG_EXIST=foo")
+self.addrule("FILE_EXIST=hook-output")
diff --git a/test/pacman/tests/hook-pkg-remove-trigger-match.py b/test/pacman/tests/hook-pkg-remove-trigger-match.py
new file mode 100644
index 00000000..887b2058
--- /dev/null
+++ b/test/pacman/tests/hook-pkg-remove-trigger-match.py
@@ -0,0 +1,23 @@
+self.description = "Remove a package matching a removal hook"
+
+self.add_script("hook-script", ": > hook-output")
+self.add_hook("hook",
+ """
+ [Trigger]
+ Type = Package
+ Operation = Remove
+ Target = foo
+
+ [Action]
+ When = PreTransaction
+ Exec = bin/hook-script
+ """);
+
+lp = pmpkg("foo")
+self.addpkg2db("local", lp)
+
+self.args = "-R foo"
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("!PKG_EXIST=foo")
+self.addrule("FILE_EXIST=hook-output")
diff --git a/test/pacman/tests/hook-pkg-upgrade-trigger-match.py b/test/pacman/tests/hook-pkg-upgrade-trigger-match.py
new file mode 100644
index 00000000..77c28309
--- /dev/null
+++ b/test/pacman/tests/hook-pkg-upgrade-trigger-match.py
@@ -0,0 +1,26 @@
+self.description = "Upgrade a package matching an Upgrade hook"
+
+self.add_script("hook-script", ": > hook-output")
+self.add_hook("hook",
+ """
+ [Trigger]
+ Type = Package
+ Operation = Upgrade
+ Target = foo
+
+ [Action]
+ When = PreTransaction
+ Exec = bin/hook-script
+ """);
+
+lp = pmpkg("foo", "1-1")
+self.addpkg2db("local", lp)
+
+sp = pmpkg("foo", "1-2")
+self.addpkg2db("sync", sp)
+
+self.args = "-S foo"
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("PKG_VERSION=foo|1-2")
+self.addrule("FILE_EXIST=hook-output")
diff --git a/test/pacman/tests/hook-upgrade-trigger-no-match.py b/test/pacman/tests/hook-upgrade-trigger-no-match.py
new file mode 100644
index 00000000..26f2743e
--- /dev/null
+++ b/test/pacman/tests/hook-upgrade-trigger-no-match.py
@@ -0,0 +1,23 @@
+self.description = "Install a package matching an Upgrade hook"
+
+self.add_script("hook-script", ": > hook-output")
+self.add_hook("hook",
+ """
+ [Trigger]
+ Type = Package
+ Operation = Upgrade
+ Target = foo
+
+ [Action]
+ When = PreTransaction
+ Exec = bin/hook-script
+ """);
+
+sp = pmpkg("foo")
+self.addpkg2db("sync", sp)
+
+self.args = "-S foo"
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("PKG_EXIST=foo")
+self.addrule("!FILE_EXIST=hook-output")