[PATCH] run-tests: fix -i when testcases are used

Martin von Zweigbergk martinvonz at google.com
Wed Jun 21 02:05:46 EDT 2017


On Tue, Jun 20, 2017 at 10:25 PM, Jun Wu <quark at fb.com> wrote:
> 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 at fb.com> wrote:
>> > # HG changeset patch
>> > # User Jun Wu <quark at 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".

I had never heard of "#testcases" before. I read it as saying that
"./run-tests.py -i test-commit.t" was broken (which didn't match my
perception of it -- I've done that successfully many times). So please
add the "#" in the subject line.

Since #testcases seems to have something to do with testing multiple
cases, I tried to extend your test case with not just case "a", but
also case "b". It wasn't obvious to me how that would work (would you
get one prompt per case?). Anyway, I wasn't very successful. Here's
what I had so far (on top of your patch):

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
@@ -644,30 +644,39 @@ Accept the fix
 With testcases

   $ cat >> test-failure.t <<EOF
-  > #testcases a
+  > #testcases a b
   > #if a
-  >   $ echo 1
+  >   $ echo a
+  > #endif
+  > #if b
+  >   $ echo b
   > #endif
   > EOF

-  $ echo 'y' | rt -i 2>&1
+  $ echo 'y\ny' | rt -i 2>&1

   --- $TESTTMP/test-failure.t
   +++ $TESTTMP/test-failure.t.a.err
-  @@ -17,4 +17,5 @@
-   #testcases a
+  @@ -17,6 +17,7 @@
+   #testcases a b
    #if a
-     $ echo 1
-  +  1
+     $ echo a
+  +  a
    #endif
+   #if b
+     $ echo b
   Accept this change? [n] ..
   # Ran 2 tests, 0 skipped, 0 failed.

-  $ tail -5 test-failure.t
-  #testcases a
+  $ tail -9 test-failure.t
+  #testcases a b
   #if a
-    $ echo 1
-    1
+    $ echo a
+    a
+  #endif
+  #if b
+    $ echo b
+    b
   #endif

 (reinstall)


>
> 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.


More information about the Mercurial-devel mailing list