Patchwork tests: add run-tests --changed option for running tests changed in revisions

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date March 25, 2014, 3:40 p.m.
Message ID <3d1d16b19e7dd5e96e24.1395762046@Iris>
Download mbox | patch
Permalink /patch/4061/
State Accepted
Headers show

Comments

Jordi Gutiérrez Hermoso - March 25, 2014, 3:40 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1393549740 -3600
#      Fri Feb 28 02:09:00 2014 +0100
# Node ID 3d1d16b19e7dd5e96e242daed86512429bc1d3f6
# Parent  f8e531a3a77cfe8aca930e60e66b5c25122a689e
tests: add run-tests --changed option for running tests changed in revisions

Convenient when polishing patches and changing details of how they change test
output.

This will probably break in weird ways for revsets with special quoting ... but
it is good enough for run-tests.

Usage example:
  yes | ./run-tests.py -li --changed qparent
David Soria Parra - March 25, 2014, 4:38 p.m.
Jordi Gutiérrez Hermoso <jordigh@octave.org> writes:

> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1393549740 -3600
> #      Fri Feb 28 02:09:00 2014 +0100
> # Node ID 3d1d16b19e7dd5e96e242daed86512429bc1d3f6
> # Parent  f8e531a3a77cfe8aca930e60e66b5c25122a689e
> tests: add run-tests --changed option for running tests changed in revisions
>
> Convenient when polishing patches and changing details of how they change test
> output.
>
> This will probably break in weird ways for revsets with special quoting ... but
> it is good enough for run-tests.

I personally think this is not really needed. First we definately need
to escape the shell arguments properly and second I don't see much of a 
benefit of this compared a small shell script or an alias.
Jordi Gutiérrez Hermoso - March 25, 2014, 5:50 p.m.
On Tue, 2014-03-25 at 16:38 +0000, David Soria Parra wrote:
> Jordi Gutiérrez Hermoso <jordigh@octave.org> writes:
> 
> > # HG changeset patch
> > # User Mads Kiilerich <madski@unity3d.com>
> > # Date 1393549740 -3600
> > #      Fri Feb 28 02:09:00 2014 +0100
> > # Node ID 3d1d16b19e7dd5e96e242daed86512429bc1d3f6
> > # Parent  f8e531a3a77cfe8aca930e60e66b5c25122a689e
> > tests: add run-tests --changed option for running tests changed in revisions
> >
> > Convenient when polishing patches and changing details of how they change test
> > output.
> >
> > This will probably break in weird ways for revsets with special quoting ... but
> > it is good enough for run-tests.
> 
> I personally think this is not really needed. First we definately need
> to escape the shell arguments properly and second I don't see much of a 
> benefit of this compared a small shell script or an alias.

The patch is already in crew. I emailed this by mistake.

- Jordi G. H.

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 @@ 
         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", type="string",
+        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,13 @@ 
     checktools()
 
     if not args:
-        args = os.listdir(".")
+        if options.changed:
+            proc = Popen4('hg st --rev "%s" -man0 .' % options.changed,
+                          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-")