1 |
commit: 10e744b9f4bd7caad60c323fd23ba71fceb4e2a1 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue May 17 19:09:42 2011 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue May 31 18:00:21 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=10e744b9 |
7 |
|
8 |
Add a Python library format example. |
9 |
|
10 |
--- |
11 |
basic/phase-function-order.py | 73 +++++++++++++++++++++++++++++++++++++++++ |
12 |
1 files changed, 73 insertions(+), 0 deletions(-) |
13 |
|
14 |
diff --git a/basic/phase-function-order.py b/basic/phase-function-order.py |
15 |
new file mode 100644 |
16 |
index 0000000..59307f9 |
17 |
--- /dev/null |
18 |
+++ b/basic/phase-function-order.py |
19 |
@@ -0,0 +1,73 @@ |
20 |
+# Example Python implementation |
21 |
+ |
22 |
+# XXX: will be implemented in core suite and imported here |
23 |
+class EbuildTest(object): |
24 |
+ phase_funcs = dict([(func, []) for func in ( |
25 |
+ 'pkg_pretend', 'pkg_setup', 'src_unpack', 'src_prepare', |
26 |
+ 'src_configure', 'src_compile', 'src_install', |
27 |
+ 'pkg_preinst', 'pkg_postinst' |
28 |
+ )]) |
29 |
+ |
30 |
+class PhaseFunctionOrderTest(EbuildTest): |
31 |
+ relevant_eapis = (0, 2, 4) |
32 |
+ |
33 |
+ DESCRIPTION = 'Phase function execution order test' |
34 |
+ |
35 |
+ def __init__(self): |
36 |
+ for func in self.phase_funcs.keys(): |
37 |
+ self.phase_funcs[func].append("pms-test_append_result %s" % func) |
38 |
+ |
39 |
+ def check_output(self, output): |
40 |
+ if self.EAPI < 2: |
41 |
+ expect = """pkg_setup |
42 |
+src_unpack |
43 |
+src_compile |
44 |
+src_install |
45 |
+pkg_preinst |
46 |
+pkg_postinst""" |
47 |
+ elif self.EAPI < 4: |
48 |
+ expect = """pkg_setup |
49 |
+src_unpack |
50 |
+src_prepare |
51 |
+src_compile |
52 |
+src_configure |
53 |
+src_install |
54 |
+pkg_preinst |
55 |
+pkg_postinst""" |
56 |
+ else: |
57 |
+ expect = """pkg_pretend |
58 |
+pkg_setup |
59 |
+src_unpack |
60 |
+src_prepare |
61 |
+src_compile |
62 |
+src_configure |
63 |
+src_install |
64 |
+pkg_preinst |
65 |
+pkg_postinst""" |
66 |
+ |
67 |
+ return (output == expect) |
68 |
+ |
69 |
+# (test code) |
70 |
+test = PhaseFunctionOrderTest() |
71 |
+ |
72 |
+test.EAPI=1 |
73 |
+real_output="""pkg_setup |
74 |
+src_unpack |
75 |
+src_compile |
76 |
+src_install |
77 |
+pkg_preinst |
78 |
+pkg_postinst""" |
79 |
+print(test.check_output(real_output)) # expect True |
80 |
+ |
81 |
+test.EAPI=2 |
82 |
+print(test.check_output(real_output)) # expect False |
83 |
+ |
84 |
+real_output="""pkg_setup |
85 |
+src_unpack |
86 |
+src_prepare |
87 |
+src_compile |
88 |
+src_configure |
89 |
+src_install |
90 |
+pkg_preinst |
91 |
+pkg_postinst""" |
92 |
+print(test.check_output(real_output)) # expect True |