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

login
register
mail settings
Submitter Anurag Goel
Date June 9, 2014, 5:09 p.m.
Message ID <CAMq1dJJJfdpoBO4oEejxuhGbag6Y7L6sRKijBv-N70KCMbQDgQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/4953/
State Not Applicable
Headers show

Comments

Anurag Goel - June 9, 2014, 5:09 p.m.
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.
Pierre-Yves David - June 9, 2014, 5:52 p.m.
On 06/09/2014 10:09 AM, Anurag Goel wrote:
> Previuosly when --interactive option is active, it doesnot prompt user
> whether to "accept changes or not" during failure.

Nice, can you patchbomb this to the list as a real patch? (same apply to 
the two others fixes)

>
> 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)
>
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>

Patch

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)