Bug 1411462 - Abort when I/O error seen; r?glandium draft
authorGregory Szorc <gps@mozilla.com>
Thu, 09 Nov 2017 20:44:10 -0800
changeset 696036 5dead291436ff211037507e96fe71e091279aed1
parent 696035 461c9b31684c4cf935c339cb7ccb95872d4fe343
child 739770 7964e4342bec0200deb3d4c9b601ac48fe61342f
push id88618
push userbmo:gps@mozilla.com
push dateFri, 10 Nov 2017 04:44:25 +0000
reviewersglandium
bugs1411462
milestone58.0a1
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
build/tests/cram/test_configure_help.t
python/mozbuild/mozbuild/configure/util.py
--- 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