[PATCH] run-tests: paths do automatically match on Windows
Simon Heimberg
simohe at besonet.ch
Fri Oct 5 04:00:41 UTC 2012
# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1349409552 -7200
# Node ID 2bb109db2f30bf6efc7999dc53c7a87c4d612b41
# Parent 5e641a809b056d42c495dbd69ca991ddb13c3c5d
run-tests: paths do automatically match on Windows
This makes writing tests easier. And it could speed up the test suite a little
bit because more lines will match without a glob comparison.
When a path MUST be written with / on any os, the (esc) syntax can be used.
also update check-code accordingly and warn about glob with no glob (? or *)
diff -r 5e641a809b05 -r 2bb109db2f30 contrib/check-code.py
--- a/contrib/check-code.py Fre Okt 05 05:35:02 2012 +0200
+++ b/contrib/check-code.py Fre Okt 05 05:59:12 2012 +0200
@@ -100,11 +100,12 @@
"explicit exit code checks unnecessary"),
(uprefix + r'set -e', "don't use set -e"),
(uprefix + r'\s', "don't indent commands, use > for continued lines"),
- (r'^ saved backup bundle to \$TESTTMP.*\.hg$',
- "use (glob) to match Windows paths too"),
],
# warnings
- []
+ [
+ (r'^ [^*?\n]* \(glob\)$',
+ "warning: remove (glob), Windows paths match automatically"),
+ ]
]
for i in [0, 1]:
diff -r 5e641a809b05 -r 2bb109db2f30 tests/run-tests.py
--- a/tests/run-tests.py Fre Okt 05 05:35:02 2012 +0200
+++ b/tests/run-tests.py Fre Okt 05 05:59:12 2012 +0200
@@ -536,6 +536,13 @@
res += re.escape(c)
return rematch(res, l)
+if os.name == 'nt':
+ def pathmatch(el, l):
+ return len(el) != len(l) and el == l.replace('\\', '/')
+else:
+ def pathmatch(el, l):
+ return False
+
def linematch(el, l):
if el == l: # perfect match (fast)
return True
@@ -545,7 +552,8 @@
el.endswith(" (esc)\n") and
(el[:-7].decode('string-escape') + '\n' == l or
el[:-7].decode('string-escape').replace('\r', '') +
- '\n' == l and os.name == 'nt'))):
+ '\n' == l and os.name == 'nt') or
+ pathmatch(el, l))):
return True
return False
More information about the Mercurial-devel
mailing list