Write tests output to stdout

This allows to watch test progress, in color.

Change-Id: I7ceebddae420d7d942f70a6b74ee0a3d11cf105e
Refs: bug #1187912
This commit is contained in:
Ivan A. Melnikov 2013-06-19 19:41:08 +04:00 committed by Joshua Harlow
parent 2d96967101
commit cd1cee1455

View File

@ -14,7 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import os
import sys
from anvil import cfg
from anvil import colorizer
@ -132,13 +132,11 @@ class PythonTestingComponent(base.Component):
return
cmd = self._get_test_command()
env = self._get_env()
with open(os.devnull, 'wb') as null_fh:
if self.get_bool_option("verbose", default_value=False):
null_fh = None
try:
sh.execute(cmd, stdout_fh=None, stderr_fh=null_fh, cwd=app_dir, env_overrides=env)
except excp.ProcessExecutionError as e:
if self.get_bool_option("ignore-test-failures", default_value=False):
LOG.warn("Ignoring test failure of component %s: %s", colorizer.quote(self.name), e)
else:
raise e
try:
sh.execute(cmd, stdout_fh=sys.stdout, stderr_fh=sys.stdout,
cwd=app_dir, env_overrides=env)
except excp.ProcessExecutionError as e:
if self.get_bool_option("ignore-test-failures", default_value=False):
LOG.warn("Ignoring test failure of component %s: %s", colorizer.quote(self.name), e)
else:
raise e