hgignore: add escape syntax test for glob patterns
authorYuya Nishihara <yuya@tcha.org>
Sun, 21 Jul 2019 13:48:29 +0900
changeset 42633 f78f305454fd
parent 42632 c67e3f966867
child 42634 0247601869ba
hgignore: add escape syntax test for glob patterns The last example, [\#], is what the rust implementation fails to parse. The other escapes can be removed by regexp engine or _globre().
tests/test-hgignore.t
--- a/tests/test-hgignore.t	Sun Jul 21 13:37:24 2019 +0900
+++ b/tests/test-hgignore.t	Sun Jul 21 13:48:29 2019 +0900
@@ -90,10 +90,11 @@
 
 Ensure that comments work:
 
-  $ touch 'foo#bar' 'quux#'
+  $ touch 'foo#bar' 'quux#' 'quu0#'
 #if no-windows
-  $ touch 'baz\wat' 'ba0\#wat' 'ba1\\wat'
+  $ touch 'baz\' 'baz\wat' 'ba0\#wat' 'ba1\\' 'ba1\\wat' 'quu0\'
 #endif
+
   $ cat <<'EOF' >> .hgignore
   > # full-line comment
   >   # whitespace-only comment line
@@ -108,9 +109,31 @@
   $ hg status
   A dir/b.o
   ? .hgignore
-  $ rm 'foo#bar' 'quux#'
+  ? quu0#
+  ? quu0\ (no-windows !)
+
+  $ cat <<'EOF' > .hgignore
+  > .*\.o
+  > syntax: glob
+  > syntax# pattern, no whitespace, then comment
+  > a.c  # pattern, then whitespace, then comment
+  > baz\\#* # (escaped) backslash, then comment
+  > ba0\\\#w* # (escaped) backslash, escaped comment character, then comment
+  > ba1\\\\#* # (escaped) backslashes, then comment
+  > foo\#b* # escaped comment character
+  > quux\## escaped comment character at end of name
+  > quu0[\#]# escaped comment character inside [...]
+  > EOF
+  $ hg status
+  A dir/b.o
+  ? .hgignore
+  ? ba1\\wat (no-windows !)
+  ? baz\wat (no-windows !)
+  ? quu0\ (no-windows !)
+
+  $ rm 'foo#bar' 'quux#' 'quu0#'
 #if no-windows
-  $ rm 'baz\wat' 'ba0\#wat' 'ba1\\wat'
+  $ rm 'baz\' 'baz\wat' 'ba0\#wat' 'ba1\\' 'ba1\\wat' 'quu0\'
 #endif
 
 Check that '^\.' does not ignore the root directory: