Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/pms-test-suite-library:master commit in: basic/
Date: Wed, 18 May 2011 16:56:59
Message-Id: 145851a384e3c667d2285802ac4311aaf7c07d76.mgorny@gentoo
1 commit: 145851a384e3c667d2285802ac4311aaf7c07d76
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Wed May 18 16:56:06 2011 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Wed May 18 16:56:06 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite-library.git;a=commit;h=145851a3
7
8 Add a bash example.
9
10 ---
11 basic/phase-function-order.bash | 83 +++++++++++++++++++++++++++++++++++++++
12 1 files changed, 83 insertions(+), 0 deletions(-)
13
14 diff --git a/basic/phase-function-order.bash b/basic/phase-function-order.bash
15 new file mode 100644
16 index 0000000..a7eb927
17 --- /dev/null
18 +++ b/basic/phase-function-order.bash
19 @@ -0,0 +1,83 @@
20 +# internal use vars
21 +relevant_eapis=( 0 2 4 )
22 +
23 +# XXX: this should be declared by caller
24 +PHASE_FUNCS=(
25 + pkg_pretend pkg_setup src_unpack src_prepare
26 + src_configure src_compile src_install
27 + pkg_preinst pkg_postinst
28 +)
29 +
30 +# ebuild vars
31 +DESCRIPTION="Phase function execution order test"
32 +
33 +# phase functions
34 +for func in ${PHASE_FUNCS[@]}; do
35 + eval "
36 +${func}() {
37 + pms-test_append_result ${func}
38 +}
39 + "
40 +done
41 +
42 +# output check
43 +check_output() {
44 + local output=${1}
45 + local expect
46 +
47 + if [[ ${EAPI} -lt 2 ]]; then
48 + expect='pkg_setup
49 +src_unpack
50 +src_compile
51 +src_install
52 +pkg_preinst
53 +pkg_postinst'
54 + elif [[ ${EAPI} -lt 4 ]]; then
55 + expect='pkg_setup
56 +src_unpack
57 +src_prepare
58 +src_compile
59 +src_configure
60 +src_install
61 +pkg_preinst
62 +pkg_postinst'
63 + else
64 + expect='pkg_pretend
65 +pkg_setup
66 +src_unpack
67 +src_prepare
68 +src_compile
69 +src_configure
70 +src_install
71 +pkg_preinst
72 +pkg_postinst'
73 + fi
74 +
75 + [[ ${output} = ${expect} ]]
76 +}
77 +
78 +# (test code)
79 +EAPI=1
80 +real_output='pkg_setup
81 +src_unpack
82 +src_compile
83 +src_install
84 +pkg_preinst
85 +pkg_postinst'
86 +check_output "${real_output}"
87 +echo "${?} ?= 0 expected"
88 +
89 +EAPI=2
90 +check_output "${real_output}"
91 +echo "${?} ?= 1 expected"
92 +
93 +real_output='pkg_setup
94 +src_unpack
95 +src_prepare
96 +src_compile
97 +src_configure
98 +src_install
99 +pkg_preinst
100 +pkg_postinst'
101 +check_output "${real_output}"
102 +echo "${?} ?= 0 expected"