Bug 1411462 - Abort when I/O error seen; r?glandium
Before, I/O errors writing to stdout/stderr (e.g. due to broken pipe)
would result in handleError() being called and execution would
keep running. This would potentially result in an error message for
every log/line failure being printed to stderr.
We change the behavior so I/O failures are fatal and abort
execution.
We test the new behavior by changing a test to pipe to `head`
directly. Since `head` exits once it has seen sufficient output,
this results in an EPIPE which now results in immediate program
termination.
MozReview-Commit-ID: 1UecZJ56h4r
--- a/build/tests/cram/test_configure_help.t
+++ b/build/tests/cram/test_configure_help.t
@@ -1,15 +1,14 @@
configure --help works
$ cd $TESTDIR/../../..
$ touch $TMP/mozconfig
$ export MOZCONFIG=$TMP/mozconfig
- $ ./configure --help > out
- $ head -n 7 out
+ $ ./configure --help 2>& 1 | head -n 7
Adding configure options from */tmp/mozconfig (glob)
checking for vcs source checkout... hg
checking for vcs source checkout... hg
Usage: configure.py [options]
Options: [defaults in brackets after descriptions]
--help print this message
--- a/python/mozbuild/mozbuild/configure/util.py
+++ b/python/mozbuild/mozbuild/configure/util.py
@@ -44,17 +44,16 @@ class Version(LooseVersion):
# Can't use super, LooseVersion's base class is not a new-style class.
LooseVersion.__init__(self, version)
# Take the first three integer components, stopping at the first
# non-integer and padding the rest with zeroes.
(self.major, self.minor, self.patch) = list(itertools.chain(
itertools.takewhile(lambda x:isinstance(x, int), self.version),
(0, 0, 0)))[:3]
-
def __cmp__(self, other):
# LooseVersion checks isinstance(StringType), so work around it.
if isinstance(other, unicode):
other = other.encode('ascii')
return LooseVersion.__cmp__(self, other)
class ConfigureOutputHandler(logging.Handler):
@@ -145,17 +144,17 @@ class ConfigureOutputHandler(logging.Han
if self._stdout_waiting == self.WAITING and self._same_output:
self._stdout_waiting = self.INTERRUPTED
self._stdout.write('\n')
self._stdout.flush()
stream = self._stderr
msg = '%s\n' % self.format(record)
stream.write(msg)
stream.flush()
- except (KeyboardInterrupt, SystemExit):
+ except (KeyboardInterrupt, SystemExit, IOError):
raise
except:
self.handleError(record)
@contextmanager
def queue_debug(self):
if self._queue_is_active:
yield