[Pytest-commit] commit/tox: 2 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Mar 20 19:46:18 CET 2015
2 new commits in tox:
https://bitbucket.org/hpk42/tox/commits/e5a405a78986/
Changeset: e5a405a78986
Branch: file-instead-of-pipe
User: fschulze
Date: 2015-03-20 13:36:30+00:00
Summary: Use a file instead of a pipe for command output in "--result-json".
Affected #: 2 files
diff -r aa5b7ce560ca7cc27ed609fad8d2678a9e6836ac -r e5a405a7898622aee926055566f4848eb417d3e9 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
DEV
-----------
+- use a file instead of a pipe for command output in "--result-json".
+
- allow --force-deps to override dependencies in "-r" requirements
files. Thanks Sontek for the PR.
diff -r aa5b7ce560ca7cc27ed609fad8d2678a9e6836ac -r e5a405a7898622aee926055566f4848eb417d3e9 tox/_cmdline.py
--- a/tox/_cmdline.py
+++ b/tox/_cmdline.py
@@ -11,7 +11,6 @@
import os
import sys
import subprocess
-import time
from tox._verlib import NormalizedVersion, IrrationalVersionError
from tox._venv import VirtualEnv
from tox._config import parseconfig
@@ -83,15 +82,14 @@
stdout = outpath = None
resultjson = self.session.config.option.resultjson
if resultjson or redirect:
- f = self._initlogpath(self.id)
- f.write("actionid=%s\nmsg=%s\ncmdargs=%r\nenv=%s\n" %(
+ fout = self._initlogpath(self.id)
+ fout.write("actionid=%s\nmsg=%s\ncmdargs=%r\nenv=%s\n" %(
self.id, self.msg, args, env))
- f.flush()
- self.popen_outpath = outpath = py.path.local(f.name)
- if resultjson:
- stdout = subprocess.PIPE
- else:
- stdout = f
+ fout.flush()
+ self.popen_outpath = outpath = py.path.local(fout.name)
+ fin = outpath.open()
+ fin.read() # read the header, so it won't be written to stdout
+ stdout = fout
elif returnout:
stdout = subprocess.PIPE
if cwd is None:
@@ -115,23 +113,28 @@
if resultjson and not redirect:
assert popen.stderr is None # prevent deadlock
out = None
- last_time = time.time()
+ last_time = now()
while 1:
+ fin_pos = fin.tell()
# we have to read one byte at a time, otherwise there
# might be no output for a long time with slow tests
- data = popen.stdout.read(1)
+ data = fin.read(1)
if data:
sys.stdout.write(data)
- if '\n' in data or (time.time() - last_time) > 5:
- # we flush on newlines or after 5 seconds to
+ if '\n' in data or (now() - last_time) > 1:
+ # we flush on newlines or after 1 second to
# provide quick enough feedback to the user
# when printing a dot per test
sys.stdout.flush()
- last_time = time.time()
- f.write(data)
+ last_time = now()
elif popen.poll() is not None:
- popen.stdout.close()
+ if popen.stdout is not None:
+ popen.stdout.close()
break
+ else:
+ py.std.time.sleep(0.1)
+ fin.seek(fin_pos)
+ fin.close()
else:
out, err = popen.communicate()
except KeyboardInterrupt:
https://bitbucket.org/hpk42/tox/commits/9d3605e2389a/
Changeset: 9d3605e2389a
User: hpk42
Date: 2015-03-20 18:46:14+00:00
Summary: Merged in fschulze/tox/file-instead-of-pipe (pull request #138)
Use a file instead of a pipe for command output in "--result-json".
Affected #: 2 files
diff -r ce2979a973dc98ca803825a01d1a83b1b8cb5984 -r 9d3605e2389a042f246b8720bdf7fdcaa9ff0a17 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
DEV
-----------
+- use a file instead of a pipe for command output in "--result-json".
+
- allow --force-deps to override dependencies in "-r" requirements
files. Thanks Sontek for the PR.
diff -r ce2979a973dc98ca803825a01d1a83b1b8cb5984 -r 9d3605e2389a042f246b8720bdf7fdcaa9ff0a17 tox/_cmdline.py
--- a/tox/_cmdline.py
+++ b/tox/_cmdline.py
@@ -11,7 +11,6 @@
import os
import sys
import subprocess
-import time
from tox._verlib import NormalizedVersion, IrrationalVersionError
from tox._venv import VirtualEnv
from tox._config import parseconfig
@@ -83,15 +82,14 @@
stdout = outpath = None
resultjson = self.session.config.option.resultjson
if resultjson or redirect:
- f = self._initlogpath(self.id)
- f.write("actionid=%s\nmsg=%s\ncmdargs=%r\nenv=%s\n" %(
+ fout = self._initlogpath(self.id)
+ fout.write("actionid=%s\nmsg=%s\ncmdargs=%r\nenv=%s\n" %(
self.id, self.msg, args, env))
- f.flush()
- self.popen_outpath = outpath = py.path.local(f.name)
- if resultjson:
- stdout = subprocess.PIPE
- else:
- stdout = f
+ fout.flush()
+ self.popen_outpath = outpath = py.path.local(fout.name)
+ fin = outpath.open()
+ fin.read() # read the header, so it won't be written to stdout
+ stdout = fout
elif returnout:
stdout = subprocess.PIPE
if cwd is None:
@@ -115,23 +113,28 @@
if resultjson and not redirect:
assert popen.stderr is None # prevent deadlock
out = None
- last_time = time.time()
+ last_time = now()
while 1:
+ fin_pos = fin.tell()
# we have to read one byte at a time, otherwise there
# might be no output for a long time with slow tests
- data = popen.stdout.read(1)
+ data = fin.read(1)
if data:
sys.stdout.write(data)
- if '\n' in data or (time.time() - last_time) > 5:
- # we flush on newlines or after 5 seconds to
+ if '\n' in data or (now() - last_time) > 1:
+ # we flush on newlines or after 1 second to
# provide quick enough feedback to the user
# when printing a dot per test
sys.stdout.flush()
- last_time = time.time()
- f.write(data)
+ last_time = now()
elif popen.poll() is not None:
- popen.stdout.close()
+ if popen.stdout is not None:
+ popen.stdout.close()
break
+ else:
+ py.std.time.sleep(0.1)
+ fin.seek(fin_pos)
+ fin.close()
else:
out, err = popen.communicate()
except KeyboardInterrupt:
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.
More information about the pytest-commit
mailing list