summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2015-05-11 12:19:03 +0200
committerholger krekel <holger@merlinux.eu>2015-05-11 12:19:03 +0200
commit958470bafdba101a31b5c0b396267a3f1ae3fc93 (patch)
treec4dadba259d37f450cb6d206efa25cb70fa3d79e
parent097438b8a986bcba6820f930d875dc2b4b1e3bb1 (diff)
parentde6c67d63370996cd8722e0a6de7d6db27feec17 (diff)
downloadtox-958470bafdba101a31b5c0b396267a3f1ae3fc93.tar.gz
merge default
-rw-r--r--CHANGELOG6
-rw-r--r--doc/config.txt20
-rw-r--r--tests/test_config.py10
-rw-r--r--tox/_cmdline.py2
-rw-r--r--tox/_config.py14
-rw-r--r--tox/_venv.py8
6 files changed, 50 insertions, 10 deletions
diff --git a/CHANGELOG b/CHANGELOG
index b09e43c..720a48b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -17,6 +17,12 @@
If platform is set and doesn't match the platform spec in the test
environment the test environment is ignored, no setup or tests are attempted.
+.. (new) add per-venv "ignore_errors" setting, which defaults to False.
+ If ``True``, a non-zero exit code from one command will be ignored and
+ further commands will be executed (which was the default behavior in tox <
+ 2.0). If ``False`` (the default), then a non-zero exit code from one command
+ will abort execution of commands for that environment.
+
- remove the long-deprecated "distribute" option as it has no effect these days.
- fix issue233: avoid hanging with tox-setuptools integration example. Thanks simonb.
diff --git a/doc/config.txt b/doc/config.txt
index d2d2854..22b4de1 100644
--- a/doc/config.txt
+++ b/doc/config.txt
@@ -110,6 +110,26 @@ Complete list of settings that you can put into ``testenv*`` sections:
pip install {opts} {packages}
+.. confval:: ignore_errors=True|False(default)
+
+ .. versionadded:: 2.0
+
+ If ``True``, a non-zero exit code from one command will be ignored and
+ further commands will be executed (which was the default behavior in tox <
+ 2.0). If ``False`` (the default), then a non-zero exit code from one command
+ will abort execution of commands for that environment.
+
+ It may be helpful to note that this setting is analogous to the ``-i`` or
+ ``ignore-errors`` option of GNU Make. A similar name was chosen to reflect the
+ similarity in function.
+
+ Note that in tox 2.0, the default behavior of tox with respect to
+ treating errors from commands changed. Tox < 2.0 would ignore errors by
+ default. Tox >= 2.0 will abort on an error by default, which is safer and more
+ typical of CI and command execution tools, as it doesn't make sense to
+ run tests if installing some prerequisite failed and it doesn't make sense to
+ try to deploy if tests failed.
+
.. confval:: pip_pre=True|False(default)
.. versionadded:: 1.9
diff --git a/tests/test_config.py b/tests/test_config.py
index a963f44..87f7f6d 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -589,6 +589,7 @@ class TestConfigTestEnv:
assert envconfig.changedir == config.setupdir
assert envconfig.sitepackages is False
assert envconfig.usedevelop is False
+ assert envconfig.ignore_errors is False
assert envconfig.envlogdir == envconfig.envdir.join("log")
assert list(envconfig.setenv.keys()) == ['PYTHONHASHSEED']
hashseed = envconfig.setenv['PYTHONHASHSEED']
@@ -649,6 +650,15 @@ class TestConfigTestEnv:
assert envconfig.changedir.basename == "xyz"
assert envconfig.changedir == config.toxinidir.join("xyz")
+ def test_ignore_errors(self, tmpdir, newconfig):
+ config = newconfig("""
+ [testenv]
+ ignore_errors=True
+ """)
+ assert len(config.envconfigs) == 1
+ envconfig = config.envconfigs['python']
+ assert envconfig.ignore_errors is True
+
def test_envbindir(self, tmpdir, newconfig):
config = newconfig("""
[testenv]
diff --git a/tox/_cmdline.py b/tox/_cmdline.py
index 342c2ad..2a9f391 100644
--- a/tox/_cmdline.py
+++ b/tox/_cmdline.py
@@ -179,7 +179,7 @@ class Action(object):
raise tox.exception.InvocationError(
"%s (see %s)" % (invoked, outpath), ret)
else:
- raise tox.exception.InvocationError("%r" % (invoked, ))
+ raise tox.exception.InvocationError("%r" % (invoked, ), ret)
if not out and outpath:
out = outpath.read()
if hasattr(self, "commandlog"):
diff --git a/tox/_config.py b/tox/_config.py
index 9189808..cbbf5e9 100644
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -335,6 +335,11 @@ def tox_addoption(parser):
"you need the virtualenv management but do not want to install "
"the current package")
+ parser.add_testenv_attribute(
+ name="ignore_errors", type="bool", default=False,
+ help="if set to True all commands will be executed irrespective of their "
+ "result error status.")
+
def recreate(config, reader, section_val):
if config.option.recreate:
return True
@@ -644,15 +649,6 @@ class parseini:
if env_attr.name == "install_command":
reader.addsubstitutions(envbindir=vc.envbindir, envpython=vc.envpython,
envsitepackagesdir=vc.envsitepackagesdir)
-
- # XXX introduce some testenv verification like this:
- # try:
- # sec = self._cfg[section]
- # except KeyError:
- # sec = self._cfg["testenv"]
- # for name in sec:
- # if name not in names:
- # print ("unknown testenv attribute: %r" % (name,))
return vc
def _getenvdata(self, reader):
diff --git a/tox/_venv.py b/tox/_venv.py
index a6c6de5..3ba2056 100644
--- a/tox/_venv.py
+++ b/tox/_venv.py
@@ -363,6 +363,14 @@ class VirtualEnv(object):
val = sys.exc_info()[1]
self.session.report.error(str(val))
self.status = "commands failed"
+ if not self.envconfig.ignore_errors:
+ self.session.report.error(
+ 'Stopping processing of commands for env %s '
+ 'because `%s` failed with exit code %s'
+ % (self.name,
+ ' '.join([str(x) for x in argv]),
+ val.args[1]))
+ break # Don't process remaining commands
except KeyboardInterrupt:
self.status = "keyboardinterrupt"
self.session.report.error(self.status)