diff options
| author | holger krekel <holger@merlinux.eu> | 2015-02-21 20:18:16 +0100 |
|---|---|---|
| committer | holger krekel <holger@merlinux.eu> | 2015-02-21 20:18:16 +0100 |
| commit | b53f337d5176a6ff24bfd43346f57fc6e937cdbe (patch) | |
| tree | 15da7207990aa1b6ba3b3621e4c2877db2329f93 | |
| parent | d4f1f3bbcb6d976c17bac1d271690941503df913 (diff) | |
| parent | e191187e70273f77b3df8f8e36ef657b843721ed (diff) | |
| download | tox-b53f337d5176a6ff24bfd43346f57fc6e937cdbe.tar.gz | |
Merged in mhirota/tox (pull request #133)
Fix issue #124
| -rw-r--r-- | CHANGELOG | 3 | ||||
| -rw-r--r-- | CONTRIBUTORS | 1 | ||||
| -rw-r--r-- | doc/config.txt | 2 | ||||
| -rw-r--r-- | doc/example/basic.txt | 16 | ||||
| -rw-r--r-- | tox/_cmdline.py | 4 | ||||
| -rw-r--r-- | tox/_venv.py | 17 |
6 files changed, 38 insertions, 5 deletions
@@ -15,6 +15,9 @@ - fix issue11: add a ``skip_install`` per-testenv setting which prevents the installation of a package. Thanks Julian Krause. +- fix issue124: ignore command exit codes; when a command has a "-" prefix, + tox will ignore the exit code of that command + 1.8.1 ----------- diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 09cd835..b3e523e 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -30,3 +30,4 @@ Morgan Fainberg Marc Schlaich Clark Boylan Eugene Yunak +Mark Hirota diff --git a/doc/config.txt b/doc/config.txt index a29c5fd..d743e1b 100644 --- a/doc/config.txt +++ b/doc/config.txt @@ -86,6 +86,8 @@ Complete list of settings that you can put into ``testenv*`` sections: will be appended (and may contain another ``\`` character ...). For eventually performing a call to ``subprocess.Popen(args, ...)`` ``args`` are determined by splitting the whole command by whitespace. + Similar to ``make`` recipe lines, any command with a leading ``-`` + will ignore the exit code. .. confval:: install_command=ARGV diff --git a/doc/example/basic.txt b/doc/example/basic.txt index 49baeee..916990e 100644 --- a/doc/example/basic.txt +++ b/doc/example/basic.txt @@ -244,3 +244,19 @@ using the ``--tox-args`` or ``-a`` command-line options. For example:: python setup.py test -a "-epy27" is equivalent to running ``tox -epy27``. + +Ignoring a command exit code +---------------------------- + +In some cases, you may want to ignore a command exit code. For example:: + + [testenv:py27] + commands = coverage erase + {envbindir}/python setup.py develop + coverage run -p setup.py test + coverage combine + - coverage html + {envbindir}/flake8 loads + +By using the ``-`` prefix, similar to a ``make`` recipe line, you can ignore +the exit code for that command. diff --git a/tox/_cmdline.py b/tox/_cmdline.py index 5faa043..9362d86 100644 --- a/tox/_cmdline.py +++ b/tox/_cmdline.py @@ -79,7 +79,7 @@ class Action(object): f.flush() return f - def popen(self, args, cwd=None, env=None, redirect=True, returnout=False): + def popen(self, args, cwd=None, env=None, redirect=True, returnout=False, ignore_ret=False): stdout = outpath = None resultjson = self.session.config.option.resultjson if resultjson or redirect: @@ -141,7 +141,7 @@ class Action(object): ret = popen.wait() finally: self._popenlist.remove(popen) - if ret: + if ret and not ignore_ret: invoked = " ".join(map(str, popen.args)) if outpath: self.report.error("invocation failed (exit code %d), logfile: %s" % diff --git a/tox/_venv.py b/tox/_venv.py index 937a881..6bcb88a 100644 --- a/tox/_venv.py +++ b/tox/_venv.py @@ -345,8 +345,19 @@ class VirtualEnv(object): message = "commands[%s] | %s" % (i, ' '.join( [str(x) for x in argv])) action.setactivity("runtests", message) + # check to see if we need to ignore the return code + # if so, we need to alter the command line arguments + if argv[0].startswith("-"): + ignore_ret = True + if argv[0] == "-": + del argv[0] + else: + argv[0] = argv[0].lstrip("-") + else: + ignore_ret = False + try: - self._pcall(argv, cwd=cwd, action=action, redirect=redirect) + self._pcall(argv, cwd=cwd, action=action, redirect=redirect, ignore_ret=ignore_ret) except tox.exception.InvocationError: val = sys.exc_info()[1] self.session.report.error(str(val)) @@ -357,7 +368,7 @@ class VirtualEnv(object): raise def _pcall(self, args, venv=True, cwd=None, extraenv={}, - action=None, redirect=True): + action=None, redirect=True, ignore_ret=False): for name in ("VIRTUALENV_PYTHON", "PYTHONDONTWRITEBYTECODE"): try: del os.environ[name] @@ -369,7 +380,7 @@ class VirtualEnv(object): try: args[0] = self.getcommandpath(args[0], venv, cwd) env = self._getenv(extraenv) - return action.popen(args, cwd=cwd, env=env, redirect=redirect) + return action.popen(args, cwd=cwd, env=env, redirect=redirect, ignore_ret=ignore_ret) finally: os.environ['PATH'] = old |
