Skip to content

Commit 46ed287

Browse files
committed
tests: add very basic hooks test
1 parent 9071e28 commit 46ed287

3 files changed

Lines changed: 47 additions & 0 deletions

File tree

tests/xbps/libxbps/shell/Kyuafile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ atf_test_program{name="orphans_test"}
3030
atf_test_program{name="noextract_files_test"}
3131
atf_test_program{name="transaction_check_revdeps_test"}
3232
atf_test_program{name="repo_test"}
33+
atf_test_program{name="hooks_test"}

tests/xbps/libxbps/shell/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ TESTSHELL+= update_shlibs_test update_hold_test update_repolock_test
1010
TESTSHELL+= cyclic_deps_test conflicts_test update_itself_test
1111
TESTSHELL+= hold_test ignore_test preserve_test repo_test
1212
TESTSHELL+= noextract_files_test orphans_test transaction_check_revdeps_test
13+
TESTSHELL+= hooks_test
1314
EXTRA_FILES = Kyuafile
1415

1516
include $(TOPDIR)/mk/test.mk
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env atf-sh
2+
3+
atf_test_case hooks_basic
4+
5+
hooks_basic_head() {
6+
atf_set "descr" "Tests for basic hooks"
7+
}
8+
9+
hooks_basic_body() {
10+
mkdir -p repo pkg_A root/etc/xbps.d/hooks
11+
12+
cat <<-EOF > root/etc/xbps.d/hooks/00-pre-hook.hook
13+
[Hook]
14+
When = PreTransaction
15+
Exec = sh -c echo\ pre-hook\ >&2
16+
17+
[Match]
18+
Action = Install
19+
Package = A
20+
EOF
21+
22+
cat <<-EOF > root/etc/xbps.d/hooks/00-post-hook.hook
23+
[Hook]
24+
When = PostTransaction
25+
Exec = sh -c echo\ post-hook\ >&2
26+
27+
[Match]
28+
Action = Install
29+
Package = A
30+
EOF
31+
32+
cd repo
33+
atf_check -o ignore -- xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A
34+
atf_check -o ignore -- xbps-rindex -a $PWD/*.xbps
35+
cd ..
36+
atf_check \
37+
-o ignore \
38+
-e match:pre-hook \
39+
-e match:post-hook \
40+
-- xbps-install -r root --repository=repo -y A
41+
}
42+
43+
atf_init_test_cases() {
44+
atf_add_test_case hooks_basic
45+
}

0 commit comments

Comments
 (0)