summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2013-01-30 19:53:23 +0100
committerholger krekel <holger@merlinux.eu>2013-01-30 19:53:23 +0100
commitbf350ab5a804e486023b7047e7dc940e739289b4 (patch)
tree84038ea6bf686207986299a7aaa6598c799f5927
parent16e444752165f09e651d92e4bcea25db92bfb87b (diff)
downloadtox-bf350ab5a804e486023b7047e7dc940e739289b4.tar.gz
- new --installpkg option
- move venv status to VirtualEnv instance.
-rwxr-xr-xCHANGELOG5
-rw-r--r--setup.py2
-rw-r--r--tests/test_config.py7
-rw-r--r--tests/test_venv.py20
-rw-r--r--tests/test_z_cmdline.py8
-rw-r--r--tox/__init__.py2
-rw-r--r--tox/_cmdline.py42
-rw-r--r--tox/_config.py3
-rw-r--r--tox/_venv.py16
-rw-r--r--toxbootstrap.py2
10 files changed, 66 insertions, 41 deletions
diff --git a/CHANGELOG b/CHANGELOG
index e7e4e97..d73a57b 100755
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,11 @@
1.4.3.dev
-----------------
+- experimentally introduce --installpkg=PATH option to install a package rather than
+ create/install an sdist package. This will still require and use
+ tox.ini and tests from the current working dir (and not from the remote
+ package).
+
- substitute {envsitepackagesdir} with the package installation directory (closes #72)
(thanks g2p)
diff --git a/setup.py b/setup.py
index 4df020f..49c2b54 100644
--- a/setup.py
+++ b/setup.py
@@ -49,7 +49,7 @@ def main():
description='virtualenv-based automation of test activities',
long_description=long_description,
url='http://tox.testrun.org/',
- version='1.4.3.dev3',
+ version='1.4.3.dev5',
license='GPLv2 or later',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
author='holger krekel',
diff --git a/tests/test_config.py b/tests/test_config.py
index 687794a..2ab65a7 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -714,6 +714,12 @@ class TestGlobalOptions:
assert env.basepython == "python2.4"
assert env.commands == [['xyz']]
+ def test_reportserver(self, tmpdir, newconfig):
+ assert not newconfig([], "").option.post
+ config = newconfig(["--post=http://xyz.net/"], "")
+ assert config.option.post == "http://xyz.net/"
+
+
class TestIndexServer:
def test_indexserver(self, tmpdir, newconfig):
config = newconfig("""
@@ -748,7 +754,6 @@ class TestIndexServer:
assert config.indexserver["default"].url == "xzy"
assert config.indexserver["name1"].url == "xzy"
-
class TestParseEnv:
def test_parse_recreate(self, newconfig):
diff --git a/tests/test_venv.py b/tests/test_venv.py
index 4fa0ad0..7984b00 100644
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -226,7 +226,7 @@ def test_install_deps_indexserver(newmocksession):
assert "-i ABC" in args
assert "dep3" in args
-def test_install_sdist_indexserver(newmocksession, tmpdir):
+def test_installpkg_indexserver(newmocksession, tmpdir):
mocksession = newmocksession([], """
[tox]
indexserver =
@@ -235,7 +235,7 @@ def test_install_sdist_indexserver(newmocksession, tmpdir):
venv = mocksession.getenv('python')
l = mocksession._pcalls
p = tmpdir.ensure("distfile.tar.gz")
- mocksession.installsdist(venv, p)
+ mocksession.installpkg(venv, p)
# two different index servers, two calls
assert len(l) == 1
args = " ".join(l[0].args)
@@ -248,7 +248,7 @@ def test_install_recreate(newmocksession):
""")
venv = mocksession.getenv('python')
venv.update()
- mocksession.installsdist(venv, "xz")
+ mocksession.installpkg(venv, "xz")
mocksession.report.expect("verbosity0", "*create*")
venv.update()
mocksession.report.expect("verbosity0", "*recreate*")
@@ -263,6 +263,7 @@ def test_install_error(newmocksession, monkeypatch):
venv = mocksession.getenv('python')
venv.test()
mocksession.report.expect("error", "*not find*qwelkqw*")
+ assert venv.status == "commands failed"
def test_install_command_not_installed(newmocksession, monkeypatch):
mocksession = newmocksession(['--recreate'], """
@@ -273,6 +274,7 @@ def test_install_command_not_installed(newmocksession, monkeypatch):
venv = mocksession.getenv('python')
venv.test()
mocksession.report.expect("warning", "*test command found but not*")
+ assert venv.status == "commands failed"
@pytest.mark.skipif("not sys.platform.startswith('linux')")
def test_install_command_not_installed(newmocksession):
@@ -383,7 +385,7 @@ class TestCreationConfig:
cconfig = venv._getliveconfig()
venv.update()
assert not venv.path_config.check()
- mocksession.installsdist(venv, "sdist.zip")
+ mocksession.installpkg(venv, "sdist.zip")
assert venv.path_config.check()
assert mocksession._pcalls
args1 = map(str, mocksession._pcalls[0].args)
@@ -468,7 +470,7 @@ def test_setenv_added_to_pcall(mocksession, newconfig):
venv = VirtualEnv(config.envconfigs['python'], session=mocksession)
# import pdb; pdb.set_trace()
- mocksession.installsdist(venv, "xyz")
+ mocksession.installpkg(venv, "xyz")
venv.test()
l = mocksession._pcalls
@@ -483,21 +485,21 @@ def test_setenv_added_to_pcall(mocksession, newconfig):
for e in os.environ:
assert e in env
-def test_install_sdist_no_upgrade(newmocksession):
+def test_installpkg_no_upgrade(newmocksession):
mocksession = newmocksession([], "")
venv = mocksession.getenv('python')
venv.just_created = True
venv.envconfig.envdir.ensure(dir=1)
- mocksession.installsdist(venv, "whatever")
+ mocksession.installpkg(venv, "whatever")
l = mocksession._pcalls
assert len(l) == 1
assert '-U' not in l[0].args
-def test_install_sdist_upgrade(newmocksession):
+def test_installpkg_upgrade(newmocksession):
mocksession = newmocksession([], "")
venv = mocksession.getenv('python')
assert not hasattr(venv, 'just_created')
- mocksession.installsdist(venv, "whatever")
+ mocksession.installpkg(venv, "whatever")
l = mocksession._pcalls
assert len(l) == 1
assert '-U' in l[0].args
diff --git a/tests/test_z_cmdline.py b/tests/test_z_cmdline.py
index 74e7fe8..5a33667 100644
--- a/tests/test_z_cmdline.py
+++ b/tests/test_z_cmdline.py
@@ -64,6 +64,8 @@ def test__resolve_pkg_doubledash(tmpdir, mocksession):
res = mocksession._resolve_pkg(distshare.join("pkg-mine*"))
assert res == p
+
+
class TestSession:
def test_make_sdist(self, initproj):
initproj("example123-0.5", filedefs={
@@ -127,9 +129,9 @@ class TestSession:
envs = session.venvlist
assert len(envs) == 2
env1, env2 = envs
- session.setenvstatus(env1, "FAIL XYZ")
+ env1.status = "FAIL XYZ"
assert env1.status
- session.setenvstatus(env2, 0)
+ env2.status = 0
assert not env2.status
session._summary()
out, err = capfd.readouterr()
@@ -421,7 +423,7 @@ def test_separate_sdist(cmd, initproj):
result = cmd.run("tox", "-v", "--notest")
assert not result.ret
result.stdout.fnmatch_lines([
- "*sdist-inst*%s*" % sdistfile,
+ "*inst*%s*" % sdistfile,
])
diff --git a/tox/__init__.py b/tox/__init__.py
index 629f153..b57d4d6 100644
--- a/tox/__init__.py
+++ b/tox/__init__.py
@@ -1,5 +1,5 @@
#
-__version__ = '1.4.3.dev3'
+__version__ = '1.4.3.dev5'
class exception:
class Error(Exception):
diff --git a/tox/_cmdline.py b/tox/_cmdline.py
index 2692330..52ff1b6 100644
--- a/tox/_cmdline.py
+++ b/tox/_cmdline.py
@@ -81,7 +81,7 @@ class Action(object):
f.write("actionid=%s\nmsg=%s\ncmdargs=%r\nenv=%s\n" %(
self.id, self.msg, args, env))
f.flush()
- outpath = py.path.local(f.name)
+ self.popen_outpath = outpath = py.path.local(f.name)
if cwd is None:
# XXX cwd = self.session.config.cwd
cwd = py.path.local()
@@ -92,7 +92,7 @@ class Action(object):
popen.action = self
self._popenlist.append(popen)
try:
- self.report.logpopen(popen)
+ self.report.logpopen(popen, env=env)
try:
out, err = popen.communicate()
except KeyboardInterrupt:
@@ -109,7 +109,7 @@ class Action(object):
outpath)
self.report.error(outpath.read())
raise tox.exception.InvocationError(
- "%s (see %s)" %(invoked, outpath))
+ "%s (see %s)" %(invoked, outpath), ret)
else:
raise tox.exception.InvocationError("%r" %(invoked, ))
return out
@@ -129,14 +129,17 @@ class Action(object):
return self.session.popen(args, shell=False, cwd=str(cwd),
stdout=stdout, stderr=stderr, env=env)
+
+
class Reporter(object):
actionchar = "-"
def __init__(self, session):
self.tw = py.io.TerminalWriter()
self.session = session
+ self._reportedlines = []
#self.cumulated_time = 0.0
- def logpopen(self, popen):
+ def logpopen(self, popen, env):
""" log information about the action.popen() created process. """
cmd = " ".join(map(str, popen.args))
if popen.outpath:
@@ -171,7 +174,7 @@ class Reporter(object):
def keyboard_interrupt(self):
- self.tw.line("KEYBOARDINTERRUPT", red=True)
+ self.error("KEYBOARDINTERRUPT")
# def venv_installproject(self, venv, pkg):
# self.logline("installing to %s: %s" % (venv.envconfig.envname, pkg))
@@ -196,19 +199,20 @@ class Reporter(object):
self.logline("ERROR: " + msg, red=True)
def logline(self, msg, **opts):
+ self._reportedlines.append(msg)
self.tw.line("%s" % msg, **opts)
def verbosity0(self, msg, **opts):
if self.session.config.option.verbosity >= 0:
- self.tw.line("%s" % msg, **opts)
+ self.logline("%s" % msg, **opts)
def verbosity1(self, msg, **opts):
if self.session.config.option.verbosity >= 1:
- self.tw.line("%s" % msg, **opts)
+ self.logline("%s" % msg, **opts)
def verbosity2(self, msg, **opts):
if self.session.config.option.verbosity >= 2:
- self.tw.line("%s" % msg, **opts)
+ self.logline("%s" % msg, **opts)
#def log(self, msg):
# py.builtin.print_(msg, file=sys.stderr)
@@ -280,9 +284,6 @@ class Session:
target.dirpath().ensure(dir=1)
src.copy(target)
- def setenvstatus(self, venv, msg):
- venv.status = msg
-
def _makesdist(self):
setup = self.config.setupdir.join("setup.py")
if not setup.check():
@@ -311,19 +312,19 @@ class Session:
except tox.exception.InvocationError:
status = sys.exc_info()[1]
if status:
- self.setenvstatus(venv, status)
+ venv.status = status
self.report.error(str(status))
return False
return True
- def installsdist(self, venv, sdist_path):
- action = self.newaction(venv, "sdist-install", sdist_path)
+ def installpkg(self, venv, sdist_path):
+ action = self.newaction(venv, "installpkg", sdist_path)
with action:
try:
- venv.install_sdist(sdist_path, action)
+ venv.installpkg(sdist_path, action)
return True
except tox.exception.InvocationError:
- self.setenvstatus(venv, sys.exc_info()[1])
+ venv.status = sys.exc_info()[1]
return False
def sdist(self):
@@ -358,7 +359,7 @@ class Session:
return
for venv in self.venvlist:
if self.setupenv(venv):
- self.installsdist(venv, sdist_path)
+ self.installpkg(venv, sdist_path)
self.runtestenv(venv, sdist_path)
retcode = self._summary()
return retcode
@@ -367,10 +368,11 @@ class Session:
if not self.config.option.notest:
if venv.status:
return
- if venv.test(redirect=redirect):
- self.setenvstatus(venv, "commands failed")
+ if not redirect and self.config.option.post:
+ redirect = True
+ venv.test(redirect=redirect)
else:
- self.setenvstatus(venv, "skipped tests")
+ venv.status = "skipped tests"
def _summary(self):
self.report.startsummary()
diff --git a/tox/_config.py b/tox/_config.py
index 171e20b..8b53a1f 100644
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -96,6 +96,9 @@ def prepare_parse(pkgname):
parser.add_argument("-r", "--recreate", action="store_true",
dest="recreate",
help="force recreation of virtual environments")
+ parser.add_argument("--post", metavar="URL", action="store",
+ default = "",
+ help="post each environment test run to specified post URL"),
parser.add_argument("args", nargs="*",
help="additional arguments available to command positional substition")
return parser
diff --git a/tox/_venv.py b/tox/_venv.py
index 2faa087..5a752eb 100644
--- a/tox/_venv.py
+++ b/tox/_venv.py
@@ -178,14 +178,14 @@ class VirtualEnv(object):
self._pcall(args, venv=False, action=action, cwd=basepath)
self.just_created = True
- def install_sdist(self, sdistpath, action):
+ def installpkg(self, sdistpath, action):
assert action is not None
if getattr(self, 'just_created', False):
- action.setactivity("sdist-inst", sdistpath)
+ action.setactivity("inst", sdistpath)
self._getliveconfig().writeconfig(self.path_config)
extraopts = []
else:
- action.setactivity("sdist-reinst", sdistpath)
+ action.setactivity("inst-nodeps", sdistpath)
extraopts = ['-U', '--no-deps']
self._install([sdistpath], extraopts=extraopts, action=action)
@@ -260,6 +260,7 @@ class VirtualEnv(object):
def test(self, redirect=False):
action = self.session.newaction(self, "runtests")
with action:
+ self.status = 0
self.session.make_emptydir(self.envconfig.envtmpdir)
cwd = self.envconfig.changedir
for i, argv in enumerate(self.envconfig.commands):
@@ -267,8 +268,13 @@ class VirtualEnv(object):
try:
self._pcall(argv, cwd=cwd, action=action, redirect=redirect)
except tox.exception.InvocationError:
- self.session.report.error(str(sys.exc_info()[1]))
- return True
+ val = sys.exc_info()[1]
+ self.session.report.error(str(val))
+ self.status = "commands failed"
+ except KeyboardInterrupt:
+ self.status = "keyboardinterrupt"
+ self.session.report.error(self.status)
+ raise
def _pcall(self, args, venv=True, cwd=None, extraenv={},
action=None, redirect=True):
diff --git a/toxbootstrap.py b/toxbootstrap.py
index a7d44cd..c3fea7d 100644
--- a/toxbootstrap.py
+++ b/toxbootstrap.py
@@ -58,7 +58,7 @@ ToDo
"""
-__version__ = '1.4.3.dev3'
+__version__ = '1.4.3.dev5'
import sys
import os