Patchwork [3,of,3] run-tests: fix -i when "#testcases" is used in .t test

login
register
mail settings
Submitter Jun Wu
Date June 21, 2017, 8:13 a.m.
Message ID <14175499d8e87e546962.1498032801@x1c>
Download mbox | patch
Permalink /patch/21584/
State Accepted
Headers show

Comments

Jun Wu - June 21, 2017, 8:13 a.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1498032751 25200
#      Wed Jun 21 01:12:31 2017 -0700
# Node ID 14175499d8e87e54696236946dc8395d258dbc47
# Parent  11e29cedc0537e49effd2b5023b12fe6e327c037
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 14175499d8e8
run-tests: fix -i when "#testcases" is used in .t test

The "#testcases" feature introduced by 7340465bd788 has issues with "-i"
because "-i" uses "test.name.endswith('.t')" to test if a test is .t or not.

test.name could now be something like "test-foo.t (caseA)" so the above
endswith test is no longer valid.

This patch changes the test to use "self.path" which won't have the issue.
via Mercurial-devel - June 22, 2017, 5:59 a.m.
On Wed, Jun 21, 2017 at 1:13 AM, Jun Wu <quark@fb.com> wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1498032751 25200
> #      Wed Jun 21 01:12:31 2017 -0700
> # Node ID 14175499d8e87e54696236946dc8395d258dbc47
> # Parent  11e29cedc0537e49effd2b5023b12fe6e327c037
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 14175499d8e8
> run-tests: fix -i when "#testcases" is used in .t test

Queued, thanks.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1606,5 +1606,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
@@ -669,4 +669,56 @@  Race condition - test file was modified 
   $ rm test-race.t
 
+When "#testcases" is used in .t files
+
+  $ cat >> test-cases.t <<EOF
+  > #testcases a b
+  > #if a
+  >   $ echo 1
+  > #endif
+  > #if b
+  >   $ echo 2
+  > #endif
+  > EOF
+
+  $ cat <<EOF | rt -i test-cases.t 2>&1
+  > y
+  > y
+  > EOF
+  
+  --- $TESTTMP/test-cases.t
+  +++ $TESTTMP/test-cases.t.a.err
+  @@ -1,6 +1,7 @@
+   #testcases a b
+   #if a
+     $ echo 1
+  +  1
+   #endif
+   #if b
+     $ echo 2
+  Accept this change? [n] .
+  --- $TESTTMP/test-cases.t
+  +++ $TESTTMP/test-cases.t.b.err
+  @@ -5,4 +5,5 @@
+   #endif
+   #if b
+     $ echo 2
+  +  2
+   #endif
+  Accept this change? [n] .
+  # Ran 2 tests, 0 skipped, 0 failed.
+
+  $ cat test-cases.t
+  #testcases a b
+  #if a
+    $ echo 1
+    1
+  #endif
+  #if b
+    $ echo 2
+    2
+  #endif
+
+  $ rm test-cases.t
+
 (reinstall)
   $ mv backup test-failure.t