[PATCH 2 of 3] run-tests: update .t reference output after reading the test

Jun Wu quark at fb.com
Wed Jun 21 04:13:20 EDT 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1498032751 25200
#      Wed Jun 21 01:12:31 2017 -0700
# Node ID 11e29cedc0537e49effd2b5023b12fe6e327c037
# Parent  59730060864e3220227133cb9cd036720a329935
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 11e29cedc053
run-tests: update .t reference output after reading the test

The .t file is both test input and reference output. They should always
match. However we have different code paths to read reference output
(Test.__init__ -> Test.readrefout) and test input (TTest._run) so they might
be inconsistent if somethings change the file between those two functions.

This patch assigns "lines" read by "_run" back to "_refout" if "_refout" is
not None (with --debug, see Test.readrefout) so reference output and test
input will always match.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1091,4 +1091,10 @@ class TTest(Test):
         f.close()
 
+        # .t file is both reference output and the test input, keep reference
+        # output updated with the the test input. This avoids some race
+        # conditions where the reference output does not match the actual test.
+        if self._refout is not None:
+            self._refout = lines
+
         salt, script, after, expected = self._parsetest(lines)
 


More information about the Mercurial-devel mailing list