run-tests: make --interactive work with --view
authorGregory Szorc <gregory.szorc@gmail.com>
Sun, 31 Aug 2014 12:22:44 +0200
changeset 22361 eb6adf750954
parent 22360 3e483253213e
child 22362 c9b32c6a2944
run-tests: make --interactive work with --view
tests/run-tests.py
tests/test-run-tests.t
--- a/tests/run-tests.py	Sun Aug 31 11:11:42 2014 +0200
+++ b/tests/run-tests.py	Sun Aug 31 12:22:44 2014 +0200
@@ -1201,18 +1201,18 @@
                     self.stream.write(line)
                 self.stream.flush()
 
-            # handle interactive prompt without releasing iolock
-            if self._options.interactive:
-                self.stream.write('Accept this change? [n] ')
-                answer = sys.stdin.readline().strip()
-                if answer.lower() in ('y', 'yes'):
-                    if test.name.endswith('.t'):
-                        rename(test.errpath, test.path)
-                    else:
-                        rename(test.errpath, '%s.out' % test.path)
-                    accepted = True
-            if not accepted and not failed:
-                self.faildata[test.name] = ''.join(lines)
+        # handle interactive prompt without releasing iolock
+        if self._options.interactive:
+            self.stream.write('Accept this change? [n] ')
+            answer = sys.stdin.readline().strip()
+            if answer.lower() in ('y', 'yes'):
+                if test.name.endswith('.t'):
+                    rename(test.errpath, test.path)
+                else:
+                    rename(test.errpath, '%s.out' % test.path)
+                accepted = True
+        if not accepted and not failed:
+            self.faildata[test.name] = ''.join(lines)
         iolock.release()
 
         return accepted
--- a/tests/test-run-tests.t	Sun Aug 31 11:11:42 2014 +0200
+++ b/tests/test-run-tests.t	Sun Aug 31 12:22:44 2014 +0200
@@ -251,6 +251,18 @@
   This is a noop statement so that
   this test is still more bytes than success.
 
+Interactive with custom view
+
+  $ echo 'n' | $TESTDIR/run-tests.py --with-hg=`which hg` -i --view echo
+  $TESTTMP/test-failure.t $TESTTMP/test-failure.t.err
+  Accept this change? [n]* (glob)
+  ERROR: test-failure.t output changed
+  !.
+  Failed test-failure.t: output changed
+  # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
+  python hash seed: * (glob)
+  [1]
+
 View the fix
 
   $ echo 'y' | $TESTDIR/run-tests.py --with-hg=`which hg` --view echo