Patchwork run-tests: fix -i when testcases are used

login
register
mail settings
Submitter Jun Wu
Date June 21, 2017, 4:45 a.m.
Message ID <30a98655ab27976c2020.1498020343@x1c>
Download mbox | patch
Permalink /patch/21577/
State Changes Requested
Headers show

Comments

Jun Wu - June 21, 2017, 4:45 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1498019662 25200
#      Tue Jun 20 21:34:22 2017 -0700
# Node ID 30a98655ab27976c2020e20909093e2cb678758b
# Parent  0ce2cbebd74964ffe61e79de8941461bccc9371b
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 30a98655ab27
run-tests: fix -i when testcases are used
via Mercurial-devel - June 21, 2017, 4:48 a.m.
On Tue, Jun 20, 2017 at 9:45 PM, Jun Wu <quark@fb.com> wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1498019662 25200
> #      Tue Jun 20 21:34:22 2017 -0700
> # Node ID 30a98655ab27976c2020e20909093e2cb678758b
> # Parent  0ce2cbebd74964ffe61e79de8941461bccc9371b
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 30a98655ab27
> run-tests: fix -i when testcases are used

What was broken?
Jun Wu - June 21, 2017, 5:25 a.m.
Excerpts from Martin von Zweigbergk's message of 2017-06-20 21:48:05 -0700:
> On Tue, Jun 20, 2017 at 9:45 PM, Jun Wu <quark@fb.com> wrote:
> > # HG changeset patch
> > # User Jun Wu <quark@fb.com>
> > # Date 1498019662 25200
> > #      Tue Jun 20 21:34:22 2017 -0700
> > # Node ID 30a98655ab27976c2020e20909093e2cb678758b
> > # Parent  0ce2cbebd74964ffe61e79de8941461bccc9371b
> > # Available At https://bitbucket.org/quark-zju/hg-draft 
> > #              hg pull https://bitbucket.org/quark-zju/hg-draft  -r 30a98655ab27
> > run-tests: fix -i when testcases are used
> 
> What was broken?

./run-tests.py -i with a .t test using "#testcases".

The fix was just one line - to detect ".t" correctly. Otherwise the .t test
will be treated like a ".py" and "-i" won't update ".t" file.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1592,5 +1592,5 @@  class TestResult(unittest._TextTestResul
                 answer = sys.stdin.readline().strip()
                 if answer.lower() in ('y', 'yes'):
-                    if test.name.endswith('.t'):
+                    if test.path.endswith(b'.t'):
                         rename(test.errpath, test.path)
                     else:
diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
--- a/tests/test-run-tests.t
+++ b/tests/test-run-tests.t
@@ -642,4 +642,33 @@  Accept the fix
     saved backup bundle to $TESTTMP/*.hg (glob)<
 
+With testcases
+
+  $ cat >> test-failure.t <<EOF
+  > #testcases a
+  > #if a
+  >   $ echo 1
+  > #endif
+  > EOF
+
+  $ echo 'y' | rt -i 2>&1
+  
+  --- $TESTTMP/test-failure.t
+  +++ $TESTTMP/test-failure.t.a.err
+  @@ -17,4 +17,5 @@
+   #testcases a
+   #if a
+     $ echo 1
+  +  1
+   #endif
+  Accept this change? [n] ..
+  # Ran 2 tests, 0 skipped, 0 failed.
+
+  $ tail -5 test-failure.t
+  #testcases a
+  #if a
+    $ echo 1
+    1
+  #endif
+
 (reinstall)
   $ mv backup test-failure.t