]>
wolfpit.net Git - tool/Arch-pacman/.git/blob - test/pacman/pactest.py
e92864d772b4dc845fa902f9b980dc053db718d0
3 # pactest : run automated testing on the pacman binary
5 # Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
6 # Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 from optparse
import OptionParser
32 __author__
= "Aurelien FORET"
35 def resolve_binary_path(option
, opt_str
, value
, parser
):
36 setattr(parser
.values
, option
.dest
, os
.path
.abspath(value
))
39 usage
= "usage: %prog [options] <path/to/testfile.py>..."
40 description
= "Runs automated tests on the pacman binary. Tests are " \
41 "described using an easy python syntax, and several can be " \
43 parser
= OptionParser(usage
= usage
, description
= description
)
45 parser
.add_option("-v", "--verbose", action
= "count",
46 dest
= "verbose", default
= 0,
47 help = "print verbose output")
48 parser
.add_option("-d", "--debug", type = "int",
49 dest
= "debug", default
= 0,
50 help = "set debug level for pacman")
51 parser
.add_option("-p", "--pacman", action
= "callback",
52 callback
= resolve_binary_path
, type = "string",
53 dest
= "bin", default
= "pacman",
54 help = "specify location of the pacman binary")
55 parser
.add_option("--keep-root", action
= "store_true",
56 dest
= "keeproot", default
= False,
57 help = "don't remove the generated pacman root filesystem")
58 parser
.add_option("--nolog", action
= "store_true",
59 dest
= "nolog", default
= False,
60 help = "do not log pacman messages")
61 parser
.add_option("--gdb", action
= "store_true",
62 dest
= "gdb", default
= False,
63 help = "use gdb while calling pacman")
64 parser
.add_option("--valgrind", action
= "store_true",
65 dest
= "valgrind", default
= False,
66 help = "use valgrind while calling pacman")
67 parser
.add_option("--manual-confirm", action
= "store_true",
68 dest
= "manualconfirm", default
= False,
69 help = "do not use --noconfirm for pacman calls")
70 parser
.add_option("--scriptlet-shell", type = "string",
71 dest
= "scriptletshell", default
= "/bin/sh",
72 help = "specify path to shell used for install scriptlets")
73 parser
.add_option("--ldconfig", type = "string",
74 dest
= "ldconfig", default
= "/sbin/ldconfig",
75 help = "specify path to ldconfig")
79 if __name__
== "__main__":
80 # instantiate env and parser objects
81 root_path
= tempfile
.mkdtemp()
82 env
= pmenv
.pmenv(root
=root_path
)
83 opt_parser
= create_parser()
84 (opts
, args
) = opt_parser
.parse_args()
86 # add parsed options to env object
87 util
.verbose
= opts
.verbose
88 env
.pacman
["debug"] = opts
.debug
89 env
.pacman
["bin"] = opts
.bin
90 env
.pacman
["nolog"] = opts
.nolog
91 env
.pacman
["gdb"] = opts
.gdb
92 env
.pacman
["valgrind"] = opts
.valgrind
93 env
.pacman
["manual-confirm"] = opts
.manualconfirm
94 env
.pacman
["scriptlet-shell"] = opts
.scriptletshell
95 env
.pacman
["ldconfig"] = opts
.ldconfig
99 opts
.testcases
+= glob
.glob(path
)
100 if opts
.testcases
is None or len(opts
.testcases
) == 0:
101 tap
.bail("no tests defined, nothing to do")
105 for i
in opts
.testcases
:
108 # run tests and print overall results
112 if not opts
.keeproot
:
113 shutil
.rmtree(root_path
)
115 tap
.diag("pacman testing root saved: %s" % root_path
)
120 # vim: set ts=4 sw=4 et: