5 new commits in tox: https://bitbucket.org/hpk42/tox/commits/74ab147d9778/ Changeset: 74ab147d9778 Branch: abort_by_default_when_a_command_fails User: msabramo Date: 2015-05-01 22:29:07+00:00 Summary: 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. Affected #: 3 files diff -r 273d12589a2548f4a0603da9d82ade8a284d4196 -r 74ab147d9778f534c10c06cc60e58e07f0cd855b tox/_cmdline.py --- a/tox/_cmdline.py +++ b/tox/_cmdline.py @@ -157,7 +157,7 @@ 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 -r 273d12589a2548f4a0603da9d82ade8a284d4196 -r 74ab147d9778f534c10c06cc60e58e07f0cd855b tox/_config.py --- a/tox/_config.py +++ b/tox/_config.py @@ -442,6 +442,7 @@ 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 -r 273d12589a2548f4a0603da9d82ade8a284d4196 -r 74ab147d9778f534c10c06cc60e58e07f0cd855b tox/_venv.py --- a/tox/_venv.py +++ b/tox/_venv.py @@ -361,6 +361,14 @@ 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) https://bitbucket.org/hpk42/tox/commits/38485f31e6a6/ Changeset: 38485f31e6a6 Branch: abort_by_default_when_a_command_fails User: msabramo Date: 2015-05-05 15:33:13+00:00 Summary: test_config: Add some tests for new ignore_errors setting Affected #: 1 file diff -r 74ab147d9778f534c10c06cc60e58e07f0cd855b -r 38485f31e6a6a413fc9332274d4eafc68e1fa400 tests/test_config.py --- a/tests/test_config.py +++ b/tests/test_config.py @@ -587,6 +587,7 @@ 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 @@ 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] https://bitbucket.org/hpk42/tox/commits/7009b80c4bf6/ Changeset: 7009b80c4bf6 Branch: abort_by_default_when_a_command_fails User: msabramo Date: 2015-05-05 16:02:27+00:00 Summary: doc/config.txt: Document new ignore_errors setting Affected #: 1 file diff -r 38485f31e6a6a413fc9332274d4eafc68e1fa400 -r 7009b80c4bf62e44866cc484be110c56a1b13b83 doc/config.txt --- a/doc/config.txt +++ b/doc/config.txt @@ -110,6 +110,26 @@ 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 https://bitbucket.org/hpk42/tox/commits/376a0d33dc01/ Changeset: 376a0d33dc01 Branch: abort_by_default_when_a_command_fails User: msabramo Date: 2015-05-05 16:02:51+00:00 Summary: CHANGELOG: Document new "ignore_errors" setting Affected #: 1 file diff -r 7009b80c4bf62e44866cc484be110c56a1b13b83 -r 376a0d33dc016fdcf0ab12d94414b3a94369b0b3 CHANGELOG --- 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. https://bitbucket.org/hpk42/tox/commits/3d7925f2ef6c/ Changeset: 3d7925f2ef6c User: hpk42 Date: 2015-05-11 10:08:59+00:00 Summary: Merged in msabramo/tox/abort_by_default_when_a_command_fails (pull request #151) Abort command execution when a command fails by default Affected #: 6 files diff -r 850fb37c60625112b2bf5ad21373d2804be98336 -r 3d7925f2ef6c716de3bc3e84f649ce9b5f15b498 CHANGELOG --- 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 -r 850fb37c60625112b2bf5ad21373d2804be98336 -r 3d7925f2ef6c716de3bc3e84f649ce9b5f15b498 doc/config.txt --- a/doc/config.txt +++ b/doc/config.txt @@ -110,6 +110,26 @@ 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 -r 850fb37c60625112b2bf5ad21373d2804be98336 -r 3d7925f2ef6c716de3bc3e84f649ce9b5f15b498 tests/test_config.py --- a/tests/test_config.py +++ b/tests/test_config.py @@ -587,6 +587,7 @@ 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 @@ 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 -r 850fb37c60625112b2bf5ad21373d2804be98336 -r 3d7925f2ef6c716de3bc3e84f649ce9b5f15b498 tox/_cmdline.py --- a/tox/_cmdline.py +++ b/tox/_cmdline.py @@ -157,7 +157,7 @@ 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 -r 850fb37c60625112b2bf5ad21373d2804be98336 -r 3d7925f2ef6c716de3bc3e84f649ce9b5f15b498 tox/_config.py --- a/tox/_config.py +++ b/tox/_config.py @@ -442,6 +442,7 @@ 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 -r 850fb37c60625112b2bf5ad21373d2804be98336 -r 3d7925f2ef6c716de3bc3e84f649ce9b5f15b498 tox/_venv.py --- a/tox/_venv.py +++ b/tox/_venv.py @@ -361,6 +361,14 @@ 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) Repository URL: https://bitbucket.org/hpk42/tox/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email. _______________________________________________ pytest-commit mailing list pytest-commit@python.org https://mail.python.org/mailman/listinfo/pytest-commit