[PATCH 10 of 11 FOR-REFERENCE] test-run-tests.y: test the --interactive option

Anurag Goel anurag.dsps at gmail.com
Mon Jun 9 12:09:49 CDT 2014


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 ebedc47093ab tests/run-tests.py
--- a/tests/run-tests.py    Mon Jun 09 17:05:39 2014 +0530
+++ b/tests/run-tests.py    Mon Jun 09 17:12:41 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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20140609/b16475d7/attachment.html>


More information about the Mercurial-devel mailing list