summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Abramowitz <marc@marc-abramowitz.com>2015-05-01 15:29:07 -0700
committerMarc Abramowitz <marc@marc-abramowitz.com>2015-05-01 15:29:07 -0700
commit29179b12783bbd4d3927914b8476dff69b07e119 (patch)
treeb50843dd685c7e8f076cd136c3dd8544957119b5
parentf2f06387a10c20ce0f657919540b137724c089f3 (diff)
downloadtox-29179b12783bbd4d3927914b8476dff69b07e119.tar.gz
Abort command execution when a command fails by default
It's pretty meaningless to keep executing commands when one command fails. So let's make it abort by default if any command returns a non-zero exit code. E.g.: $ tox py27 runtests: PYTHONHASHSEED='2154811636' py27 runtests: commands[0] | echo 1 1 py27 runtests: commands[1] | false ERROR: InvocationError: '/usr/bin/false' ERROR: Stopping processing of commands for env py27 because `/usr/bin/false` failed with exit code 1 _____________________________________________ summary ______________________________________________ ERROR: py27: commands failed Unless the `ignore_errors` setting is set to `True`, in which case, it keeps processing, like it did in older versions of tox.
-rw-r--r--tox/_cmdline.py2
-rw-r--r--tox/_config.py1
-rw-r--r--tox/_venv.py8
3 files changed, 10 insertions, 1 deletions
diff --git a/tox/_cmdline.py b/tox/_cmdline.py
index 0236d17..43fe5bc 100644
--- a/tox/_cmdline.py
+++ b/tox/_cmdline.py
@@ -157,7 +157,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 4468d86..afb6544 100644
--- a/tox/_config.py
+++ b/tox/_config.py
@@ -442,6 +442,7 @@ class parseini:
section, "pip_pre", False)
vc.skip_install = reader.getbool(section, "skip_install", False)
+ vc.ignore_errors = reader.getbool(section, "ignore_errors", False)
return vc
diff --git a/tox/_venv.py b/tox/_venv.py
index 9114e69..762e684 100644
--- a/tox/_venv.py
+++ b/tox/_venv.py
@@ -361,6 +361,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)