summaryrefslogtreecommitdiffstats
path: root/test/pacman
diff options
context:
space:
mode:
Diffstat (limited to 'test/pacman')
-rwxr-xr-xtest/pacman/pactest.py43
-rw-r--r--test/pacman/pmdb.py2
-rw-r--r--test/pacman/pmenv.py2
-rw-r--r--test/pacman/pmfile.py2
-rw-r--r--test/pacman/pmpkg.py2
-rw-r--r--test/pacman/pmrule.py2
-rw-r--r--test/pacman/pmtest.py2
-rw-r--r--test/pacman/tap.py2
-rw-r--r--test/pacman/tests/TESTS7
-rw-r--r--test/pacman/tests/dbonly-extracted-files.py16
-rw-r--r--test/pacman/tests/file-conflict-with-installed-pkg.py17
-rw-r--r--test/pacman/tests/overwrite-files-match-negated.py13
-rw-r--r--test/pacman/tests/overwrite-files-match.py13
-rw-r--r--test/pacman/tests/overwrite-files-nonmatch.py13
-rw-r--r--test/pacman/tests/remove-directory-replaced-with-symlink.py16
-rw-r--r--test/pacman/tests/symlink-replace-with-dir.py18
-rw-r--r--test/pacman/util.py2
17 files changed, 162 insertions, 10 deletions
diff --git a/test/pacman/pactest.py b/test/pacman/pactest.py
index 4d7c61e3..b5f6d4d7 100755
--- a/test/pacman/pactest.py
+++ b/test/pacman/pactest.py
@@ -3,7 +3,7 @@
# pactest : run automated testing on the pacman binary
#
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
-# Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -23,6 +23,8 @@ import os
import shutil
import sys
import tempfile
+import glob
+import subprocess
import pmenv
import tap
@@ -31,6 +33,30 @@ import util
__author__ = "Aurelien FORET"
__version__ = "0.4"
+# writer to send output to multiple destinations simultaneously
+class MultiWriter():
+ def __init__(self, *outputs):
+ self.outputs = outputs
+
+ def write(self, message):
+ for op in self.outputs:
+ op.write(message)
+
+# duplicate stdout/stderr to a temporary file
+class OutputSaver():
+ def __init__(self):
+ self.save_file = tempfile.NamedTemporaryFile(prefix='pactest-output-')
+
+ def __enter__(self):
+ sys.stdout = MultiWriter(sys.stdout, self.save_file)
+ sys.stderr = MultiWriter(sys.stderr, self.save_file)
+ return self.save_file
+
+ def __exit__(self, type, value, traceback):
+ sys.stdout = sys.__stdout__
+ sys.stderr = sys.__stderr__
+ self.save_file.flush()
+
def create_parser():
usage = "usage: %prog [options] <path/to/testfile.py>..."
description = "Runs automated tests on the pacman binary. Tests are " \
@@ -71,6 +97,12 @@ def create_parser():
parser.add_option("--ldconfig", type = "string",
dest = "ldconfig", default = "/sbin/ldconfig",
help = "specify path to ldconfig")
+ parser.add_option("--review", action = "store_true",
+ dest = "review", default = False,
+ help = "review test files, test output, and saved logs")
+ parser.add_option("--editor", action = "store",
+ dest = "editor", default = os.getenv('EDITOR', 'vim'),
+ help = "editor to use for viewing files")
return parser
@@ -114,7 +146,14 @@ if __name__ == "__main__":
sys.exit(2)
# run tests
- env.run()
+ if not opts.review:
+ env.run()
+ else:
+ # save output in tempfile for review
+ with OutputSaver() as save_file:
+ env.run()
+ files = [save_file.name] + args + glob.glob(root_path + "/var/log/*")
+ subprocess.call([opts.editor] + files)
if not opts.keeproot:
shutil.rmtree(root_path)
diff --git a/test/pacman/pmdb.py b/test/pacman/pmdb.py
index 1f20506d..5ada9270 100644
--- a/test/pacman/pmdb.py
+++ b/test/pacman/pmdb.py
@@ -1,5 +1,5 @@
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
-# Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/test/pacman/pmenv.py b/test/pacman/pmenv.py
index 14dea943..1b624124 100644
--- a/test/pacman/pmenv.py
+++ b/test/pacman/pmenv.py
@@ -1,5 +1,5 @@
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
-# Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/test/pacman/pmfile.py b/test/pacman/pmfile.py
index d7500f17..9e1f4d3a 100644
--- a/test/pacman/pmfile.py
+++ b/test/pacman/pmfile.py
@@ -1,5 +1,5 @@
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
-# Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/test/pacman/pmpkg.py b/test/pacman/pmpkg.py
index 8a88a356..a8bac307 100644
--- a/test/pacman/pmpkg.py
+++ b/test/pacman/pmpkg.py
@@ -1,5 +1,5 @@
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
-# Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/test/pacman/pmrule.py b/test/pacman/pmrule.py
index 61eded04..3c912c0d 100644
--- a/test/pacman/pmrule.py
+++ b/test/pacman/pmrule.py
@@ -1,5 +1,5 @@
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
-# Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py
index 9072b4d6..c5e629db 100644
--- a/test/pacman/pmtest.py
+++ b/test/pacman/pmtest.py
@@ -1,5 +1,5 @@
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
-# Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/test/pacman/tap.py b/test/pacman/tap.py
index d4886ce0..fd3239b2 100644
--- a/test/pacman/tap.py
+++ b/test/pacman/tap.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2013-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2013-2017 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/test/pacman/tests/TESTS b/test/pacman/tests/TESTS
index 2d877962..309eb17e 100644
--- a/test/pacman/tests/TESTS
+++ b/test/pacman/tests/TESTS
@@ -11,6 +11,7 @@ TESTS += test/pacman/tests/database002.py
TESTS += test/pacman/tests/database010.py
TESTS += test/pacman/tests/database011.py
TESTS += test/pacman/tests/database012.py
+TESTS += test/pacman/tests/dbonly-extracted-files.py
TESTS += test/pacman/tests/depconflict100.py
TESTS += test/pacman/tests/depconflict110.py
TESTS += test/pacman/tests/depconflict111.py
@@ -27,6 +28,7 @@ TESTS += test/pacman/tests/epoch005.py
TESTS += test/pacman/tests/epoch010.py
TESTS += test/pacman/tests/epoch011.py
TESTS += test/pacman/tests/epoch012.py
+TESTS += test/pacman/tests/file-conflict-with-installed-pkg.py
TESTS += test/pacman/tests/fileconflict001.py
TESTS += test/pacman/tests/fileconflict002.py
TESTS += test/pacman/tests/fileconflict003.py
@@ -79,6 +81,9 @@ TESTS += test/pacman/tests/mode001.py
TESTS += test/pacman/tests/mode002.py
TESTS += test/pacman/tests/mode003.py
TESTS += test/pacman/tests/noupgrade-inverted.py
+TESTS += test/pacman/tests/overwrite-files-match-negated.py
+TESTS += test/pacman/tests/overwrite-files-match.py
+TESTS += test/pacman/tests/overwrite-files-nonmatch.py
TESTS += test/pacman/tests/pacman001.py
TESTS += test/pacman/tests/pacman002.py
TESTS += test/pacman/tests/pacman003.py
@@ -109,6 +114,7 @@ TESTS += test/pacman/tests/querycheck002.py
TESTS += test/pacman/tests/querycheck_fast_file_type.py
TESTS += test/pacman/tests/reason001.py
TESTS += test/pacman/tests/remove-assumeinstalled.py
+TESTS += test/pacman/tests/remove-directory-replaced-with-symlink.py
TESTS += test/pacman/tests/remove-optdepend-of-installed-package.py
TESTS += test/pacman/tests/remove-recursive-cycle.py
TESTS += test/pacman/tests/remove001.py
@@ -149,6 +155,7 @@ TESTS += test/pacman/tests/smoke001.py
TESTS += test/pacman/tests/smoke002.py
TESTS += test/pacman/tests/smoke003.py
TESTS += test/pacman/tests/smoke004.py
+TESTS += test/pacman/tests/symlink-replace-with-dir.py
TESTS += test/pacman/tests/symlink001.py
TESTS += test/pacman/tests/symlink002.py
TESTS += test/pacman/tests/symlink010.py
diff --git a/test/pacman/tests/dbonly-extracted-files.py b/test/pacman/tests/dbonly-extracted-files.py
new file mode 100644
index 00000000..a1bc48df
--- /dev/null
+++ b/test/pacman/tests/dbonly-extracted-files.py
@@ -0,0 +1,16 @@
+import util
+import os.path
+
+self.description = "Install a package with dbonly"
+
+sp = pmpkg("foobar", "1-1")
+sp.files = ["bin/foobar"]
+sp.install['post_install'] = "echo foobar"
+self.addpkg2db("sync", sp)
+
+self.args = "-S --dbonly %s" % sp.name
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("PKG_EXIST=foobar")
+self.addrule("FILE_EXIST=%s" % os.path.join(util.PM_DBPATH, "local/foobar-1-1/install"))
+self.addrule("!FILE_EXIST=bin/foobar")
diff --git a/test/pacman/tests/file-conflict-with-installed-pkg.py b/test/pacman/tests/file-conflict-with-installed-pkg.py
new file mode 100644
index 00000000..cf88e8a9
--- /dev/null
+++ b/test/pacman/tests/file-conflict-with-installed-pkg.py
@@ -0,0 +1,17 @@
+self.description = "File conflict with an installed package"
+
+lp = pmpkg("foobar")
+lp.files = ["conflicting-file"]
+self.addpkg2db("local", lp)
+
+p1 = pmpkg("pkg1")
+p1.files = ["conflicting-file"]
+self.addpkg(p1)
+
+self.args = "-U %s" % (p1.filename())
+
+self.addrule("!PACMAN_RETCODE=0")
+self.addrule("PKG_EXIST=foobar")
+self.addrule("!PKG_EXIST=pkg1")
+self.addrule("FILE_EXIST=conflicting-file")
+self.addrule("PACMAN_OUTPUT=foobar")
diff --git a/test/pacman/tests/overwrite-files-match-negated.py b/test/pacman/tests/overwrite-files-match-negated.py
new file mode 100644
index 00000000..42b1be2d
--- /dev/null
+++ b/test/pacman/tests/overwrite-files-match-negated.py
@@ -0,0 +1,13 @@
+self.description = "Install a package with an existing file matching a negated --overwrite pattern"
+
+p = pmpkg("dummy")
+p.files = ["foobar"]
+self.addpkg(p)
+
+self.filesystem = ["foobar*"]
+
+self.args = "-U --overwrite=foobar --overwrite=!foo* %s" % p.filename()
+
+self.addrule("!PACMAN_RETCODE=0")
+self.addrule("!PKG_EXIST=dummy")
+self.addrule("!FILE_MODIFIED=foobar")
diff --git a/test/pacman/tests/overwrite-files-match.py b/test/pacman/tests/overwrite-files-match.py
new file mode 100644
index 00000000..004155c3
--- /dev/null
+++ b/test/pacman/tests/overwrite-files-match.py
@@ -0,0 +1,13 @@
+self.description = "Install a package with an existing file matching an --overwrite pattern"
+
+p = pmpkg("dummy")
+p.files = ["foobar"]
+self.addpkg(p)
+
+self.filesystem = ["foobar*"]
+
+self.args = "-U --overwrite=foobar %s" % p.filename()
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("PKG_EXIST=dummy")
+self.addrule("FILE_MODIFIED=foobar")
diff --git a/test/pacman/tests/overwrite-files-nonmatch.py b/test/pacman/tests/overwrite-files-nonmatch.py
new file mode 100644
index 00000000..38932d5f
--- /dev/null
+++ b/test/pacman/tests/overwrite-files-nonmatch.py
@@ -0,0 +1,13 @@
+self.description = "Install a package with an existing file not matching --overwrite patterns"
+
+p = pmpkg("dummy")
+p.files = ["foobar"]
+self.addpkg(p)
+
+self.filesystem = ["foobar*"]
+
+self.args = "-U --overwrite=foo %s" % p.filename()
+
+self.addrule("!PACMAN_RETCODE=0")
+self.addrule("!PKG_EXIST=dummy")
+self.addrule("!FILE_MODIFIED=foobar")
diff --git a/test/pacman/tests/remove-directory-replaced-with-symlink.py b/test/pacman/tests/remove-directory-replaced-with-symlink.py
new file mode 100644
index 00000000..37be7579
--- /dev/null
+++ b/test/pacman/tests/remove-directory-replaced-with-symlink.py
@@ -0,0 +1,16 @@
+self.description = "remove a package with a directory that has been replaced with a symlink"
+
+self.filesystem = [ "var/", "srv -> var/" ]
+
+lpkg = pmpkg("pkg1")
+lpkg.files = ["srv/"]
+self.addpkg2db("local", lpkg)
+
+self.args = "-R %s" % (lpkg.name)
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("DIR_EXIST=var/")
+self.addrule("!LINK_EXIST=srv")
+self.addrule("!FILE_EXIST=srv")
+self.addrule("!DIR_EXIST=srv")
+self.addrule("!PACMAN_OUTPUT=cannot remove")
diff --git a/test/pacman/tests/symlink-replace-with-dir.py b/test/pacman/tests/symlink-replace-with-dir.py
new file mode 100644
index 00000000..511d751b
--- /dev/null
+++ b/test/pacman/tests/symlink-replace-with-dir.py
@@ -0,0 +1,18 @@
+self.description = "incoming package replaces symlink with directory"
+
+lp = pmpkg("pkg1")
+lp.files = ["usr/lib/foo",
+ "lib -> usr/lib"]
+self.addpkg2db("local", lp)
+
+p1 = pmpkg("pkg2")
+p1.files = ["lib/foo"]
+p1.conflicts = ["pkg1"]
+self.addpkg2db("sync", p1)
+
+self.args = "-S pkg2 --ask=4"
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("!PKG_EXIST=pkg1")
+self.addrule("PKG_EXIST=pkg2")
+self.addrule("FILE_TYPE=lib|dir")
diff --git a/test/pacman/util.py b/test/pacman/util.py
index 208e2f4a..cad4fe13 100644
--- a/test/pacman/util.py
+++ b/test/pacman/util.py
@@ -1,5 +1,5 @@
# Copyright (c) 2006 by Aurelien Foret <orelien@chez.com>
-# Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
+# Copyright (c) 2006-2017 Pacman Development Team <pacman-dev@archlinux.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by