1
0
mirror of https://github.com/moparisthebest/pacman synced 2025-03-01 01:41:52 -05:00

pactest: check for pacman binary before running

Using fakeroot or fakechroot as the command with subprocess.call
prevents the detection and reporting of a missing pacman binary.  Some
tests even pass when run with a non-existent binary.  Checking manually
allows us to provide a meaningful error message and prevent the false
positives.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
This commit is contained in:
Andrew Gregory 2014-07-04 16:49:52 -04:00 committed by Allan McRae
parent 0c5e80c3b4
commit 6650c43fca

View File

@ -49,7 +49,7 @@ def create_parser():
help = "set debug level for pacman") help = "set debug level for pacman")
parser.add_option("-p", "--pacman", action = "callback", parser.add_option("-p", "--pacman", action = "callback",
callback = resolve_binary_path, type = "string", callback = resolve_binary_path, type = "string",
dest = "bin", default = "pacman", dest = "bin", default = util.which("pacman"),
help = "specify location of the pacman binary") help = "specify location of the pacman binary")
parser.add_option("--keep-root", action = "store_true", parser.add_option("--keep-root", action = "store_true",
dest = "keeproot", default = False, dest = "keeproot", default = False,
@ -86,6 +86,10 @@ if __name__ == "__main__":
opt_parser = create_parser() opt_parser = create_parser()
(opts, args) = opt_parser.parse_args() (opts, args) = opt_parser.parse_args()
if opts.bin is None or not os.access(opts.bin, os.X_OK):
tap.bail("cannot locate pacman binary")
sys.exit(2)
# instantiate env # instantiate env
root_path = tempfile.mkdtemp(prefix='pactest-') root_path = tempfile.mkdtemp(prefix='pactest-')
env = pmenv.pmenv(root=root_path) env = pmenv.pmenv(root=root_path)