test-wildmatch: avoid Windows path mangling

The MSYS bash mangles arguments that begin with a forward slash when they are passed to test-wildmatch. This causes tests to fail. Avoid mangling by prepending "XXX", which is removed by test-wildmatch before further processing. [J6t: reworded commit message] Reported-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Johannes Sixt <j6t@kdbg.org>

Nguyễn Thái Ngọc Duy committed Nov 20, 2012 at 08:02 UTC ef49841ddf98ed1eb40c60153072fa1a91fc2f18
2 files changed +13 -5
t/t3070-wildmatch.sh
+5 -5
@@ -74,7 +74,7 @@ match 0 0 'foo/bar' 'foo[/]bar'
74 match 0 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
75 match 1 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
76 match 1 0 'foo' '**/foo'
77 -match 1 x '/foo' '**/foo'
77 +match 1 x 'XXX/foo' '**/foo'
78 match 1 0 'bar/baz/foo' '**/foo'
79 match 0 0 'bar/baz/foo' '*/foo'
80 match 0 0 'foo/bar/baz' '**/bar*'
@@ -95,8 +95,8 @@ match 0 0 ']' '[!]-]'
95 match 1 x 'a' '[!]-]'
96 match 0 0 '' '\'
97 match 0 x '\' '\'
98 -match 0 x '/\' '*/\'
99 -match 1 x '/\' '*/\\'
98 +match 0 x 'XXX/\' '*/\'
99 +match 1 x 'XXX/\' '*/\\'
100 match 1 1 'foo' 'foo'
101 match 1 1 '@foo' '@foo'
102 match 0 0 'foo' '@foo'
@@ -187,8 +187,8 @@ match 0 0 '-' '[[-\]]'
187 match 1 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
188 match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
189 match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
190 -match 1 1 '/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' '/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
191 -match 0 0 '/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' '/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
190 +match 1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
191 +match 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
192 match 1 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'
193 match 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'
194
test-wildmatch.c
+8
@@ -3,6 +3,14 @@
3
4 int main(int argc, char **argv)
5 {
6 + int i;
7 + for (i = 2; i < argc; i++) {
8 + if (argv[i][0] == '/')
9 + die("Forward slash is not allowed at the beginning of the\n"
10 + "pattern because Windows does not like it. Use `XXX/' instead.");
11 + else if (!strncmp(argv[i], "XXX/", 4))
12 + argv[i] += 3;
13 + }
14 if (!strcmp(argv[1], "wildmatch"))
15 return !!wildmatch(argv[3], argv[2], 0);
16 else if (!strcmp(argv[1], "iwildmatch"))