Patchwork run-tests: allow run-tests.py to run tests outside current directory

login
register
mail settings
Submitter David MacIver
Date Feb. 17, 2016, 11:38 a.m.
Message ID <29fd0a20bb724be92c2b.1455709084@laser-shark>
Download mbox | patch
Permalink /patch/13237/
State Superseded
Headers show

Comments

David MacIver - Feb. 17, 2016, 11:38 a.m.
# HG changeset patch
# User David R. MacIver <david@drmaciver.com>
# Date 1455708193 0
#      Wed Feb 17 11:23:13 2016 +0000
# Branch all
# Node ID 29fd0a20bb724be92c2bcc6a5fa71eaca290c158
# Parent  a036e1ae1fbe88ab99cb861ebfc2e4da7a3912ca
run-tests: allow run-tests.py to run tests outside current directory

When reloading tests, run-tests.py was assuming that it could look
up the test by the basename, which only works if you are running
tests which are in the current directory.

This patch changes that lookup to use the full path. This is all
that was needed, and does not appear to cause any problems for
any of the existing testing work flows based on running the
suggested commands at the top of run-tests.py.

Motivation: In order to test Mercurial with Hypothesis (according
to https://www.mercurial-scm.org/wiki/HypothesisPlan) it is
useful to be able to generate temporary test files and execute
them. Generating temporary files in the tests/ directory leads to
a lot of suboptimal clutter.
timeless - Feb. 17, 2016, 7:59 p.m.
Please provide a test.
Basically, your test should generate such a directory+test file and
call run-tests (with --local) with it.

On Wed, Feb 17, 2016 at 6:38 AM, David R. MacIver <david@drmaciver.com> wrote:
> # HG changeset patch
> # User David R. MacIver <david@drmaciver.com>
> # Date 1455708193 0
> #      Wed Feb 17 11:23:13 2016 +0000
> # Branch all
> # Node ID 29fd0a20bb724be92c2bcc6a5fa71eaca290c158
> # Parent  a036e1ae1fbe88ab99cb861ebfc2e4da7a3912ca
> run-tests: allow run-tests.py to run tests outside current directory
>
> When reloading tests, run-tests.py was assuming that it could look
> up the test by the basename, which only works if you are running
> tests which are in the current directory.
>
> This patch changes that lookup to use the full path. This is all
> that was needed, and does not appear to cause any problems for
> any of the existing testing work flows based on running the
> suggested commands at the top of run-tests.py.
>
> Motivation: In order to test Mercurial with Hypothesis (according
> to https://www.mercurial-scm.org/wiki/HypothesisPlan) it is
> useful to be able to generate temporary test files and execute
> them. Generating temporary files in the tests/ directory leads to
> a lot of suboptimal clutter.
>
> diff -r a036e1ae1fbe -r 29fd0a20bb72 tests/run-tests.py
> --- a/tests/run-tests.py        Sun Feb 07 00:49:31 2016 -0600
> +++ b/tests/run-tests.py        Wed Feb 17 11:23:13 2016 +0000
> @@ -1485,7 +1485,7 @@
>              def get():
>                  num_tests[0] += 1
>                  if getattr(test, 'should_reload', False):
> -                    return self._loadtest(test.bname, num_tests[0])
> +                    return self._loadtest(test.path, num_tests[0])
>                  return test
>              if not os.path.exists(test.path):
>                  result.addSkip(test, "Doesn't exist")
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
David MacIver - Feb. 18, 2016, 8:59 a.m.
Certainly. Done and sent.

The comment at the top of run-tests.py suggested that testing of it was
manual, which is why I didn't think to look for similar tests. Would you be
amenable to a second patch to amend the comment?

On 17 February 2016 at 19:59, timeless <timeless@gmail.com> wrote:

> Please provide a test.
> Basically, your test should generate such a directory+test file and
> call run-tests (with --local) with it.
>
> On Wed, Feb 17, 2016 at 6:38 AM, David R. MacIver <david@drmaciver.com>
> wrote:
> > # HG changeset patch
> > # User David R. MacIver <david@drmaciver.com>
> > # Date 1455708193 0
> > #      Wed Feb 17 11:23:13 2016 +0000
> > # Branch all
> > # Node ID 29fd0a20bb724be92c2bcc6a5fa71eaca290c158
> > # Parent  a036e1ae1fbe88ab99cb861ebfc2e4da7a3912ca
> > run-tests: allow run-tests.py to run tests outside current directory
> >
> > When reloading tests, run-tests.py was assuming that it could look
> > up the test by the basename, which only works if you are running
> > tests which are in the current directory.
> >
> > This patch changes that lookup to use the full path. This is all
> > that was needed, and does not appear to cause any problems for
> > any of the existing testing work flows based on running the
> > suggested commands at the top of run-tests.py.
> >
> > Motivation: In order to test Mercurial with Hypothesis (according
> > to https://www.mercurial-scm.org/wiki/HypothesisPlan) it is
> > useful to be able to generate temporary test files and execute
> > them. Generating temporary files in the tests/ directory leads to
> > a lot of suboptimal clutter.
> >
> > diff -r a036e1ae1fbe -r 29fd0a20bb72 tests/run-tests.py
> > --- a/tests/run-tests.py        Sun Feb 07 00:49:31 2016 -0600
> > +++ b/tests/run-tests.py        Wed Feb 17 11:23:13 2016 +0000
> > @@ -1485,7 +1485,7 @@
> >              def get():
> >                  num_tests[0] += 1
> >                  if getattr(test, 'should_reload', False):
> > -                    return self._loadtest(test.bname, num_tests[0])
> > +                    return self._loadtest(test.path, num_tests[0])
> >                  return test
> >              if not os.path.exists(test.path):
> >                  result.addSkip(test, "Doesn't exist")
> > _______________________________________________
> > Mercurial-devel mailing list
> > Mercurial-devel@mercurial-scm.org
> > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
timeless - Feb. 19, 2016, 4:06 a.m.
David MacIver wrote:
> The comment at the top of run-tests.py suggested that testing of it was
> manual, which is why I didn't think to look for similar tests. Would you be
> amenable to a second patch to amend the comment?

tests/test-run-tests.t exists, and could be listed as a 0 step, but,
it's not that simple.

Basically test-run-tests.t can handle basic features, but a change to
run-tests.py can easily be only found in a certain mode and a certain
bigger test. Sometimes it's possible to enhance test-run-tests.t,
sometimes it's /probably/ too hard.

I haven't figured out how to write a useful comment, but I'd be
willing to offer feedback on a suggestion.

Patch

diff -r a036e1ae1fbe -r 29fd0a20bb72 tests/run-tests.py
--- a/tests/run-tests.py	Sun Feb 07 00:49:31 2016 -0600
+++ b/tests/run-tests.py	Wed Feb 17 11:23:13 2016 +0000
@@ -1485,7 +1485,7 @@ 
             def get():
                 num_tests[0] += 1
                 if getattr(test, 'should_reload', False):
-                    return self._loadtest(test.bname, num_tests[0])
+                    return self._loadtest(test.path, num_tests[0])
                 return test
             if not os.path.exists(test.path):
                 result.addSkip(test, "Doesn't exist")