[PATCH STABLE] run-tests: don't error when glob matched line ends with backslash
Gregory Szorc
gregory.szorc at gmail.com
Fri Apr 17 21:13:34 UTC 2015
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1429305121 25200
# Fri Apr 17 14:12:01 2015 -0700
# Branch stable
# Node ID fd6f10c53bfa25b04602e7792c7bd729fb5a5afd
# Parent 32d0d2f38910d4397b2a05c148e3fb0255588539
run-tests: don't error when glob matched line ends with backslash
As part of writing another test, I triggered an array index error in
glob match processing code by having a (glob) line end in a single
backslash (which is the escape character).
Adding a simple bounds check prevents the error in run-tests.py.
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1065,7 +1065,7 @@
while i < n:
c = el[i]
i += 1
- if c == '\\' and el[i] in '*?\\/':
+ if c == '\\' and i < n and el[i] in '*?\\/':
res += el[i - 1:i + 1]
i += 1
elif c == '*':
diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
--- a/tests/test-run-tests.t
+++ b/tests/test-run-tests.t
@@ -491,3 +491,17 @@
} (no-eol)
#endif
+
+backslash on end of line with glob matching is handled properly
+
+ $ cat > test-glob-backslash.t << EOF
+ > $ echo 'foo bar \\'
+ > foo * \ (glob)
+ > EOF
+
+ $ $TESTDIR/run-tests.py --with-hg=`which hg` test-glob-backslash.t
+ .
+ # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
+
+ $ rm -f test-glob-backslash.t
+
More information about the Mercurial-devel
mailing list