diff options
| author | holger krekel <holger@merlinux.eu> | 2015-05-11 12:08:59 +0200 |
|---|---|---|
| committer | holger krekel <holger@merlinux.eu> | 2015-05-11 12:08:59 +0200 |
| commit | de6c67d63370996cd8722e0a6de7d6db27feec17 (patch) | |
| tree | 064a193b292d043b2b518f312acde1ab6ab516a8 | |
| parent | 820b005c923aabf9c8724aa6ef5aea6ad4a1ac6b (diff) | |
| parent | 294d91209ee5766e1ec23434c3b8efe25767cad1 (diff) | |
| download | tox-de6c67d63370996cd8722e0a6de7d6db27feec17.tar.gz | |
Merged in msabramo/tox/abort_by_default_when_a_command_fails (pull request #151)
Abort command execution when a command fails by default
| -rw-r--r-- | CHANGELOG | 6 | ||||
| -rw-r--r-- | doc/config.txt | 20 | ||||
| -rw-r--r-- | tests/test_config.py | 10 | ||||
| -rw-r--r-- | tox/_cmdline.py | 2 | ||||
| -rw-r--r-- | tox/_config.py | 1 | ||||
| -rw-r--r-- | tox/_venv.py | 8 |
6 files changed, 46 insertions, 1 deletions
@@ -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 79c98bd..e4e7bf6 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -587,6 +587,7 @@ class TestConfigTestEnv: assert envconfig.changedir == config.setupdir assert envconfig.sitepackages is False assert envconfig.develop 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'] @@ -647,6 +648,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 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) |
