Patchwork [7,of,9] tests: add run-tests --changed option for running tests changed in parent or wd

login
register
mail settings
Submitter Mads Kiilerich
Date March 18, 2014, 11:33 p.m.
Message ID <e00c2a57827a52e15ada.1395185635@localhost.localdomain>
Download mbox | patch
Permalink /patch/3977/
State Accepted
Headers show

Comments

Mads Kiilerich - March 18, 2014, 11:33 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1393549740 -3600
#      Fri Feb 28 02:09:00 2014 +0100
# Node ID e00c2a57827a52e15adaa000e427306a8b904bdb
# Parent  4546fe5f1b924ca58ac18a14253ebdc31c9af9bd
tests: add run-tests --changed option for running tests changed in parent or wd

Convenient when polishing patches and changing details of how they change test
output.
Siddharth Agarwal - March 19, 2014, 3:02 a.m.
On 03/18/2014 04:33 PM, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1393549740 -3600
> #      Fri Feb 28 02:09:00 2014 +0100
> # Node ID e00c2a57827a52e15adaa000e427306a8b904bdb
> # Parent  4546fe5f1b924ca58ac18a14253ebdc31c9af9bd
> tests: add run-tests --changed option for running tests changed in parent or wd
>
> Convenient when polishing patches and changing details of how they change test
> output.

Eh, I'd rather this took an argument indicating the rev to compare against.

./run-tests.py --changed .^


>
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -141,6 +141,8 @@ def parseargs():
>           help="skip tests listed in the specified blacklist file")
>       parser.add_option("--whitelist", action="append",
>           help="always run tests listed in the specified whitelist file")
> +    parser.add_option("--changed", action="store_true",
> +        help="run tests that are changed in parent rev or working directory")
>       parser.add_option("-C", "--annotate", action="store_true",
>           help="output files annotated with coverage")
>       parser.add_option("-c", "--cover", action="store_true",
> @@ -1181,7 +1183,12 @@ def main():
>       checktools()
>   
>       if not args:
> -        args = os.listdir(".")
> +        if options.changed:
> +            proc = Popen4('hg st --rev "p1(.)" -man0 .', None, 0)
> +            stdout, stderr = proc.communicate()
> +            args = stdout.strip('\0').split('\0')
> +        else:
> +            args = os.listdir(".")
>   
>       tests = [t for t in args
>                if t.startswith("test-")
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://urldefense.proofpoint.com/v1/url?u=http://selenic.com/mailman/listinfo/mercurial-devel&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=%2FSg8Zq7yFXBOhOzuAORckw%3D%3D%0A&m=asUkuTOU2bhxolR8GiLuXGCGEgGCJUZQQVMfnQW%2BLAw%3D%0A&s=f3e5ad893159988752840b07c7eba00bcfcb4d628a7d4f850c4a60106b94ebe1

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -141,6 +141,8 @@  def parseargs():
         help="skip tests listed in the specified blacklist file")
     parser.add_option("--whitelist", action="append",
         help="always run tests listed in the specified whitelist file")
+    parser.add_option("--changed", action="store_true",
+        help="run tests that are changed in parent rev or working directory")
     parser.add_option("-C", "--annotate", action="store_true",
         help="output files annotated with coverage")
     parser.add_option("-c", "--cover", action="store_true",
@@ -1181,7 +1183,12 @@  def main():
     checktools()
 
     if not args:
-        args = os.listdir(".")
+        if options.changed:
+            proc = Popen4('hg st --rev "p1(.)" -man0 .', None, 0)
+            stdout, stderr = proc.communicate()
+            args = stdout.strip('\0').split('\0')
+        else:
+            args = os.listdir(".")
 
     tests = [t for t in args
              if t.startswith("test-")