[PATCH 3 of 3 stable] run-tests: fixed the --interactive option error

Anurag Goel anurag.dsps at gmail.com
Mon Jun 9 14:54:01 CDT 2014


# HG changeset patch
# User anuraggoel <anurag.dsps at gmail.com>
# Date 1402342817 -19800
#      Tue Jun 10 01:10:17 2014 +0530
# Node ID 47040029ab54f86ead3b0720fec6ce28a60789c8
# Parent  976ed600c1cb5adffd690df9c34bbcac66d02f2d
run-tests: fixed the --interactive option error

Previuosly when --interactive option is active, it doesnot prompt user
whether to "accept changes or not" during failure.

Now this has been resolved.
Also on every failure, result gets appended in "result.failure" list.
Therefore, if failure is accepted by user then it has to be pop out from
the failure list.

diff -r 976ed600c1cb -r 47040029ab54 tests/run-tests.py
--- a/tests/run-tests.py	Tue Jun 10 01:03:08 2014 +0530
+++ b/tests/run-tests.py	Tue Jun 10 01:10:17 2014 +0530
@@ -466,7 +466,8 @@
                 # the stack trace. This is for historical reasons and
                 # this decision could be revisted in the future,
                 # especially for PythonTest instances.
-                result.addFailure(self, str(e))
+                if result.addFailure(self, str(e)):
+                    success = True
             except Exception:
                 result.addError(self, sys.exc_info())
             else:
@@ -1077,6 +1078,18 @@
             self.stop()
         else:
             self.stream.write('\nERROR: %s output changed\n' % test)
+            if self._options.interactive:
+                iolock.acquire()
+                self.stream.write('Accept this change? [n] ')
+                answer = sys.stdin.readline().strip()
+                iolock.release()
+                if answer.lower() in ('y', 'yes'):
+                    if test.name.endswith('.t'):
+                        rename(test.errpath, test.path)
+                    else:
+                        rename(test.errpath, '%s.out' % test.path)
+                    self.failures.pop()
+                    return 1
             self.stream.write('!')
 
     def addError(self, *args, **kwargs):
@@ -1136,20 +1149,9 @@
                     self.stream.write(line)
                 self.stream.flush()
 
-        if ret or not self._options.interactive or \
-            not os.path.exists(test.errpath):
+        if ret or not self._options.interactive or os.path.exists(test.errpath):
             return
 
-        iolock.acquire()
-        print 'Accept this change? [n] ',
-        answer = sys.stdin.readline().strip()
-        iolock.release()
-        if answer.lower() in ('y', 'yes'):
-            if test.name.endswith('.t'):
-                rename(test.errpath, test.path)
-            else:
-                rename(test.errpath, '%s.out' % test.path)
-
     def startTest(self, test):
         super(TestResult, self).startTest(test)
 


More information about the Mercurial-devel mailing list