pactest: run with root in /tmp and clean up automatically
This moves the generated root/ directory into /tmp, or at least a path returned by tempfile.mkdtemp(), by default. This can make test runs significantly faster if done when /tmp is a tmpfs. If you are debugging a failed test, use the new --keep-root option to not clean up and pactest will print the location of the generated root/ test directory. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
47de7973fd
commit
d360153bc6
2 changed files with 25 additions and 12 deletions
|
@ -21,7 +21,6 @@ check-local: test/pacman test/util src/pacman src/util
|
||||||
$(PYTHON) $(top_srcdir)/test/pacman/pactest.py --debug=1 \
|
$(PYTHON) $(top_srcdir)/test/pacman/pactest.py --debug=1 \
|
||||||
--test $(top_srcdir)/test/pacman/tests/*.py \
|
--test $(top_srcdir)/test/pacman/tests/*.py \
|
||||||
-p $(top_builddir)/src/pacman/pacman
|
-p $(top_builddir)/src/pacman/pacman
|
||||||
rm -rf $(top_builddir)/root
|
|
||||||
$(SH) $(top_srcdir)/test/util/vercmptest.sh \
|
$(SH) $(top_srcdir)/test/util/vercmptest.sh \
|
||||||
$(top_builddir)/src/util/vercmp
|
$(top_builddir)/src/util/vercmp
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,12 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import os, sys, glob
|
import glob
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
|
||||||
import pmenv
|
import pmenv
|
||||||
import util
|
import util
|
||||||
|
@ -63,6 +67,9 @@ def createOptParser():
|
||||||
parser.add_option("-t", "--test", action = "callback",
|
parser.add_option("-t", "--test", action = "callback",
|
||||||
callback = globTests, dest = "testcases",
|
callback = globTests, dest = "testcases",
|
||||||
help = "specify test case(s)")
|
help = "specify test case(s)")
|
||||||
|
parser.add_option("--keep-root", action = "store_true",
|
||||||
|
dest = "keeproot", default = False,
|
||||||
|
help = "don't remove the generated pacman root filesystem")
|
||||||
parser.add_option("--nolog", action = "store_true",
|
parser.add_option("--nolog", action = "store_true",
|
||||||
dest = "nolog", default = False,
|
dest = "nolog", default = False,
|
||||||
help = "do not log pacman messages")
|
help = "do not log pacman messages")
|
||||||
|
@ -80,7 +87,8 @@ def createOptParser():
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# instantiate env and parser objects
|
# instantiate env and parser objects
|
||||||
env = pmenv.pmenv()
|
root_path = tempfile.mkdtemp()
|
||||||
|
env = pmenv.pmenv(root=root_path)
|
||||||
opt_parser = createOptParser()
|
opt_parser = createOptParser()
|
||||||
(opts, args) = opt_parser.parse_args()
|
(opts, args) = opt_parser.parse_args()
|
||||||
|
|
||||||
|
@ -95,8 +103,9 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
if opts.testcases is None or len(opts.testcases) == 0:
|
if opts.testcases is None or len(opts.testcases) == 0:
|
||||||
print "no tests defined, nothing to do"
|
print "no tests defined, nothing to do"
|
||||||
|
os.rmdir(root_path)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
else:
|
|
||||||
for i in opts.testcases:
|
for i in opts.testcases:
|
||||||
env.addtest(i)
|
env.addtest(i)
|
||||||
|
|
||||||
|
@ -107,4 +116,9 @@ if __name__ == "__main__":
|
||||||
if env.failed > 0:
|
if env.failed > 0:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
if not opts.keeproot:
|
||||||
|
shutil.rmtree(root_path)
|
||||||
|
else:
|
||||||
|
print "pacman testing root saved: %s" % root_path
|
||||||
|
|
||||||
# vim: set ts=4 sw=4 et:
|
# vim: set ts=4 sw=4 et:
|
||||||
|
|
Loading…
Add table
Reference in a new issue