Mercurial > hg
view contrib/casesmash.py @ 41138:8ddc5d8bea25
tests: support passing testcase after .t paths that have path separators
This probably could have been implemented by changing the regex above this bit
of code, but I wasn't sure if it would end up handling various OSes correctly,
so I decided to go with this version instead.
Previously:
$ tests/run-tests.py tests/test-ssh.t -l
running 2 tests using 2 parallel processes
..
# Ran 2 tests, 0 skipped, 0 failed.
$ tests/run-tests.py tests/test-ssh.t#sshv1 -l
running 0 tests using 0 parallel processes
# Ran 0 tests, 0 skipped, 0 failed.
Now:
$ tests/run-tests.py tests/test-ssh.t -l
running 2 tests using 2 parallel processes
..
# Ran 2 tests, 0 skipped, 0 failed.
$ tests/run-tests.py tests/test-ssh.t#sshv1 -l
running 1 tests using 1 parallel processes
.
# Ran 1 tests, 0 skipped, 0 failed.
Differential Revision: https://phab.mercurial-scm.org/D5535
author | Kyle Lippincott <spectral@google.com> |
---|---|
date | Tue, 08 Jan 2019 17:52:39 -0800 |
parents | 42a7301fb4d5 |
children | 2372284d9457 |
line wrap: on
line source
from __future__ import absolute_import import __builtin__ import os from mercurial import ( util, ) def lowerwrap(scope, funcname): f = getattr(scope, funcname) def wrap(fname, *args, **kwargs): d, base = os.path.split(fname) try: files = os.listdir(d or '.') except OSError: files = [] if base in files: return f(fname, *args, **kwargs) for fn in files: if fn.lower() == base.lower(): return f(os.path.join(d, fn), *args, **kwargs) return f(fname, *args, **kwargs) scope.__dict__[funcname] = wrap def normcase(path): return path.lower() os.path.normcase = normcase for f in 'file open'.split(): lowerwrap(__builtin__, f) for f in "chmod chown open lstat stat remove unlink".split(): lowerwrap(os, f) for f in "exists lexists".split(): lowerwrap(os.path, f) lowerwrap(util, 'posixfile')