[PATCH 2 of 2] run-tests: explicitly flush test runner output for Windows stability

Matt Harbison mharbison72 at gmail.com
Mon Jun 19 00:58:30 EDT 2017


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1497838794 14400
#      Sun Jun 18 22:19:54 2017 -0400
# Node ID 5a86b565abe65d4aca9d290a627736804215a8fa
# Parent  8fd2d66049d936d2cc501ad9a466fb5e67ed8ac2
run-tests: explicitly flush test runner output for Windows stability

When hghave testing goes awry, the output order was changing on Windows.

  diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
  --- a/tests/test-run-tests.t
  +++ b/tests/test-run-tests.t
  @@ -920,10 +920,10 @@
      > EOF
      > done
      $ rt -j 2
  -  ....
  +  ....skipped: unknown feature: notarealhghavefeature\r (esc)
  +
  +
      # Ran 5 tests, 0 skipped, 0 warned, 0 failed.
  -  skipped: unknown feature: notarealhghavefeature
  -
      $ cd ..
      $ rm -rf broken

Since 'skipped: unknown feature: notarealhghavefeature\n\n' is printed to stdout
and the rest to stderr, it seems like maybe stdio isn't line buffered on
Windows.  When a program exits, stdout is flushed before stderr[1].

[1] https://blogs.msdn.microsoft.com/oldnewthing/20060519-09/?p=31133

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -2010,6 +2010,7 @@
                     os.environ['PYTHONHASHSEED'])
             if self._runner.options.time:
                 self.printtimes(result.times)
+            self.stream.flush()
 
         return result
 


More information about the Mercurial-devel mailing list