[PATCH 4 of 4] run-tests: allow test paths in other directories

Augie Fackler raf at durin42.com
Sat Apr 12 11:13:40 CDT 2014


On Mon, Mar 24, 2014 at 10:12:56PM -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1395724357 25200
> #      Mon Mar 24 22:12:37 2014 -0700
> # Node ID 30d0d63c248995f9e981e25389d2e79bf7e5f96c
> # Parent  9d7b3768e916df9eb4acbbbce6cb55b63f152b59
> run-tests: allow test paths in other directories

These all look good to me (especially as an external extension
author). Queued.

>
> Previously, test paths were assumed to be in the same directory and
> wouldn't have a directory component. If a path with a directory
> component was specified, it would be filtered out. This change allow
> paths to contain directories. This in turn allows tests from other
> directories to be executed.
>
> Executing tests in other directories may break assumptions elsewhere in
> the testing code. However, on initial glance, things appear to "just
> work." This approach of running tests from other directories is
> successfully being used at
> https://hg.mozilla.org/hgcustom/version-control-tools/file/7085790ff3af/run-mercurial-tests.py
>
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -934,17 +934,17 @@ def runone(options, test, count):
>              t = fp.read().lower() + test.lower()
>              fp.close()
>              for k in options.keywords.lower().split():
>                  if k in t:
>                      break
>                  else:
>                      return ignore("doesn't match keyword")
>
> -    if not lctest.startswith("test-"):
> +    if not os.path.basename(lctest).startswith("test-"):
>          return skip("not a test file")
>      for ext, func, out in testtypes:
>          if lctest.endswith(ext):
>              runner = func
>              ref = os.path.join(TESTDIR, test + out)
>              break
>      else:
>          return skip("unknown test type")
> @@ -1192,18 +1192,18 @@ def main(args, parser=None):
>              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-")
> -             and (t.endswith(".py") or t.endswith(".t"))]
> +             if os.path.basename(t).startswith("test-")
> +                 and (t.endswith(".py") or t.endswith(".t"))]
>
>      if options.random:
>          random.shuffle(tests)
>      else:
>          # keywords for slow tests
>          slow = 'svn gendoc check-code-hg'.split()
>          def sortkey(f):
>              # run largest tests first, as they tend to take the longest
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list