* [gentoo-commits] portage r14445 - main/trunk/pym/portage/tests/bin
@ 2009-09-27 18:01 Zac Medico (zmedico)
0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2009-09-27 18:01 UTC (permalink / raw
To: gentoo-commits
Author: zmedico
Date: 2009-09-27 18:01:30 +0000 (Sun, 27 Sep 2009)
New Revision: 14445
Modified:
main/trunk/pym/portage/tests/bin/setup_env.py
Log:
Use mkdtemp() instead of hardcoded pym/portage/tests/bin/root directory.
Modified: main/trunk/pym/portage/tests/bin/setup_env.py
===================================================================
--- main/trunk/pym/portage/tests/bin/setup_env.py 2009-09-27 09:17:01 UTC (rev 14444)
+++ main/trunk/pym/portage/tests/bin/setup_env.py 2009-09-27 18:01:30 UTC (rev 14445)
@@ -3,6 +3,8 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
+import tempfile
+
from portage import os
from portage import shutil
from portage.tests import TestCase
@@ -12,25 +14,32 @@
bindir = os.path.join(os.path.dirname(os.path.dirname(
os.path.abspath(__file__))),
"..", "..", "..", "bin", "ebuild-helpers")
-basedir = os.path.join(os.path.dirname(os.path.dirname(
- os.path.abspath(__file__))), "bin", "root")
-os.environ["D"] = os.path.join(basedir, "image")
-os.environ["T"] = os.path.join(basedir, "temp")
-os.environ["S"] = os.path.join(basedir, "workdir")
-os.environ["PF"] = "portage-tests-0.09-r1"
-os.environ["PATH"] = bindir + ":" + os.environ["PATH"]
-os.environ["PORTAGE_BIN_PATH"] = PORTAGE_BIN_PATH
+basedir = None
+env = None
def binTestsCleanup():
+ global basedir
+ if basedir is None:
+ return
if os.access(basedir, os.W_OK):
shutil.rmtree(basedir)
+ basedir = None
+
def binTestsInit():
binTestsCleanup()
- os.mkdir(basedir)
- os.mkdir(os.environ["D"])
- os.mkdir(os.environ["T"])
- os.mkdir(os.environ["S"])
- os.chdir(os.environ["S"])
+ global basedir, env
+ basedir = tempfile.mkdtemp()
+ env = os.environ.copy()
+ env["D"] = os.path.join(basedir, "image")
+ env["T"] = os.path.join(basedir, "temp")
+ env["S"] = os.path.join(basedir, "workdir")
+ env["PF"] = "portage-tests-0.09-r1"
+ env["PATH"] = bindir + ":" + env["PATH"]
+ env["PORTAGE_BIN_PATH"] = PORTAGE_BIN_PATH
+ os.mkdir(env["D"])
+ os.mkdir(env["T"])
+ os.mkdir(env["S"])
+ os.chdir(env["S"])
class BinTestCase(TestCase):
def __init__(self, methodName):
@@ -43,7 +52,7 @@
def _exists_in_D(path):
# Note: do not use os.path.join() here, we assume D to end in /
- return os.access(os.environ["D"] + path, os.W_OK)
+ return os.access(env["D"] + path, os.W_OK)
def exists_in_D(path):
if not _exists_in_D(path):
raise TestCase.failureException
@@ -54,9 +63,10 @@
def portage_func(func, args, exit_status=0):
# we don't care about the output of the programs,
# just their exit value and the state of $D
+ global env
f = open('/dev/null', 'wb')
fd_pipes = {0:0,1:f.fileno(),2:f.fileno()}
- spawn(func+" "+args, env=os.environ, fd_pipes=fd_pipes)
+ spawn([func] + args.split(), env=env, fd_pipes=fd_pipes)
f.close()
def create_portage_wrapper(bin):
@@ -71,4 +81,4 @@
bin.startswith("new") or \
bin.startswith("prep") or \
bin in ["ecompress","ecompressdir","fowners","fperms"]:
- globals()[bin] = create_portage_wrapper(bin)
+ globals()[bin] = create_portage_wrapper(os.path.join(bindir, bin))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-09-27 18:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-27 18:01 [gentoo-commits] portage r14445 - main/trunk/pym/portage/tests/bin Zac Medico (zmedico)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox