summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2015-11-06 17:44:55 +0100
committerholger krekel <holger@merlinux.eu>2015-11-06 17:44:55 +0100
commitf410ba9039185ca914aebc673f4b6b587d1471b1 (patch)
treee4cbd539e19cde7ba1beee3a0ab4f55c0abe6c6e
parentc4c086a1747c0340f64dbb95bd58936f0e6c0676 (diff)
parenta48806c94fcb4548bb83eee500b8f0a8cf7ee891 (diff)
downloadtox-f410ba9039185ca914aebc673f4b6b587d1471b1.tar.gz
Merged in rebeckag/tox/174-voting-testenv (pull request #170)
#174 voting testenv
-rw-r--r--tests/test_config.py9
-rw-r--r--tests/test_venv.py15
-rw-r--r--tox/config.py5
-rw-r--r--tox/session.py3
-rw-r--r--tox/venv.py7
5 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_config.py b/tests/test_config.py
index 93cd8bf..16e1e57 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -640,6 +640,7 @@ class TestConfigTestEnv:
int_hashseed = int(hashseed)
# hashseed is random by default, so we can't assert a specific value.
assert int_hashseed > 0
+ assert envconfig.ignore_outcome is False
def test_sitepackages_switch(self, tmpdir, newconfig):
config = newconfig(["--sitepackages"], "")
@@ -1269,6 +1270,14 @@ class TestConfigTestEnv:
assert [d.name for d in configs["py27-django1.6"].deps] \
== ["Django==1.6"]
+ def test_ignore_outcome(self, newconfig):
+ inisource = """
+ [testenv]
+ ignore_outcome=True
+ """
+ config = newconfig([], inisource).envconfigs
+ assert config["python"].ignore_outcome is True
+
class TestGlobalOptions:
def test_notest(self, newconfig):
diff --git a/tests/test_venv.py b/tests/test_venv.py
index 7c6b05a..b454f5b 100644
--- a/tests/test_venv.py
+++ b/tests/test_venv.py
@@ -7,6 +7,7 @@ import tox.config
from tox.venv import * # noqa
from tox.interpreters import NoInterpreterInfo
+
# def test_global_virtualenv(capfd):
# v = VirtualEnv()
# l = v.list()
@@ -611,3 +612,17 @@ def test_command_relative_issue26(newmocksession, tmpdir, monkeypatch):
x4 = venv.getcommandpath("x", cwd=tmpdir)
assert x4.endswith(os.sep + 'x')
mocksession.report.expect("warning", "*test command found but not*")
+
+
+def test_ignore_outcome_failing_cmd(newmocksession):
+ mocksession = newmocksession([], """
+ [testenv]
+ commands=testenv_fail
+ ignore_outcome=True
+ """)
+
+ venv = mocksession.getenv('python')
+ venv.test()
+ assert venv.status == "ignored failed command"
+ mocksession.report.expect("warning", "*command failed but result from "
+ "testenv is ignored*")
diff --git a/tox/config.py b/tox/config.py
index 3f4c8af..40c6e0a 100644
--- a/tox/config.py
+++ b/tox/config.py
@@ -476,6 +476,11 @@ def tox_addoption(parser):
name="commands", type="argvlist", default="",
help="each line specifies a test command and can use substitution.")
+ parser.add_testenv_attribute(
+ "ignore_outcome", type="bool", default=False,
+ help="if set to True a failing result of this testenv will not make "
+ "tox fail, only a warning will be produced")
+
class Config(object):
""" Global Tox config object. """
diff --git a/tox/session.py b/tox/session.py
index fcdcf6c..b5176f9 100644
--- a/tox/session.py
+++ b/tox/session.py
@@ -570,6 +570,9 @@ class Session:
elif status == "platform mismatch":
msg = " %s: %s" % (venv.envconfig.envname, str(status))
self.report.skip(msg)
+ elif status and status == "ignored failed command":
+ msg = " %s: %s" % (venv.envconfig.envname, str(status))
+ self.report.good(msg)
elif status and status != "skipped tests":
msg = " %s: %s" % (venv.envconfig.envname, str(status))
self.report.error(msg)
diff --git a/tox/venv.py b/tox/venv.py
index 7990330..eaa555a 100644
--- a/tox/venv.py
+++ b/tox/venv.py
@@ -351,6 +351,13 @@ class VirtualEnv(object):
self._pcall(argv, cwd=cwd, action=action, redirect=redirect,
ignore_ret=ignore_ret, testcommand=True)
except tox.exception.InvocationError as err:
+ if self.envconfig.ignore_outcome:
+ self.session.report.warning(
+ "command failed but result from testenv is ignored\n"
+ " cmd: %s" % (str(err),))
+ self.status = "ignored failed command"
+ continue # keep processing commands
+
self.session.report.error(str(err))
self.status = "commands failed"
if not self.envconfig.ignore_errors: