mirror of
https://github.com/moparisthebest/pacman
synced 2024-10-31 15:45:03 -04:00
add hook tests
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
b76409609c
commit
a5759cb0d7
@ -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
|
||||
|
25
test/pacman/tests/hook-abortonfail.py
Normal file
25
test/pacman/tests/hook-abortonfail.py
Normal file
@ -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")
|
32
test/pacman/tests/hook-file-change-packages.py
Normal file
32
test/pacman/tests/hook-file-change-packages.py
Normal file
@ -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")
|
24
test/pacman/tests/hook-file-remove-trigger-match.py
Normal file
24
test/pacman/tests/hook-file-remove-trigger-match.py
Normal file
@ -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")
|
27
test/pacman/tests/hook-file-upgrade-nomatch.py
Normal file
27
test/pacman/tests/hook-file-upgrade-nomatch.py
Normal file
@ -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")
|
25
test/pacman/tests/hook-invalid-trigger.py
Normal file
25
test/pacman/tests/hook-invalid-trigger.py
Normal file
@ -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")
|
23
test/pacman/tests/hook-pkg-install-trigger-match.py
Normal file
23
test/pacman/tests/hook-pkg-install-trigger-match.py
Normal file
@ -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")
|
23
test/pacman/tests/hook-pkg-remove-trigger-match.py
Normal file
23
test/pacman/tests/hook-pkg-remove-trigger-match.py
Normal file
@ -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")
|
26
test/pacman/tests/hook-pkg-upgrade-trigger-match.py
Normal file
26
test/pacman/tests/hook-pkg-upgrade-trigger-match.py
Normal file
@ -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")
|
23
test/pacman/tests/hook-upgrade-trigger-no-match.py
Normal file
23
test/pacman/tests/hook-upgrade-trigger-no-match.py
Normal file
@ -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")
|
Loading…
Reference in New Issue
Block a user