{"thread":{"id":"47493","subject":"[PATCH 0/6] increase wildmatch test coverage","startedAt":"2017-12-23T21:30:39Z","lastAt":"2018-01-30T21:22:46Z","messageCount":73,"participants":["Ævar Arnfjörð Bjarmason","Johannes Sixt","Junio C Hamano","Adam Dinwoodie","Johannes Schindelin","Duy Nguyen"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"335234","messageId":"20171223213012.1962-1-avarab@gmail.com","threadId":"47493","inReplyTo":null,"subject":"[PATCH 0/6] increase wildmatch test coverage","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-23T21:30:06Z","receivedAt":"2017-12-23T21:30:39Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This increases the test coverage we have for wildmatch, and hopefully\ndoesn't break anything, but see the fantastic hack that is 6/6 and\nform your own opinion.\n\nThe backstory of this is that back in June I posted an RFC series here\nto the list to refactor wildmatch() itself to no-op support\nprecompiling patterns:\nhttps://public-inbox.org/git/20170622213810.14785-1-avarab@gmail.com/\n\nThe intent was to swap out wildmatch() to use PCRE as an engine, my\nperformance tests reveal that that was probably a dumb idea.\n\nWe may still want something like those patches I submitted back in\nJune, in particular we could rewrite wildmatch.c itself to precompile\na pattern. if this makes it in I'll see about rebasing those on top,\nbut I'm not in any rush with those.\n\nBut in writing up those initial patches (and some \"use PCRE for this\")\nthat hasn't made it on the list, I discovered that I didn't have any\nfaith in our wildmatch tests, it was easy to find case I could break\nand all tests would still pass.\n\nThis series fixes that, whatever we do with wildmatch in the future\nit'll be really nice to have this, since we now have exhaustive test\ncoverage of wildmatch, both through the raw function as before (but as\n5/6 there were holes in that), and more importantly by doing the same\ntests through ls-files, which is the interface users actually use, and\nas 6/6 reveals sometimes behaves differently than the underlying\nmatching function.\n\nÆvar Arnfjörð Bjarmason (6):\n  wildmatch test: indent with tabs, not spaces\n  wildmatch test: use more standard shell style\n  wildmatch test: use a paranoia pattern from nul_match()\n  wildmatch test: remove dead fnmatch() test code\n  wildmatch test: perform all tests under all wildmatch() modes\n  wildmatch test: create & test files on disk in addition to in-memory\n\n a[]b                      |   0\n t/helper/test-wildmatch.c |   2 +\n t/t3070-wildmatch.sh      | 802 ++++++++++++++++++++++++++++++++--------------\n 3 files changed, 558 insertions(+), 246 deletions(-)\n create mode 100644 a[]b\n\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335235","messageId":"20171223213012.1962-3-avarab@gmail.com","threadId":"47493","inReplyTo":"20171223213012.1962-1-avarab@gmail.com","subject":"[PATCH 2/6] wildmatch test: use more standard shell style","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-23T21:30:08Z","receivedAt":"2017-12-23T21:30:41Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the wildmatch test to use more standard shell style, usually we\nuse \"if test\" not \"if [\".\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 9 ++++++---\n 1 file changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 27fa878f6e..4d589d1f9a 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -5,7 +5,8 @@ test_description='wildmatch tests'\n . ./test-lib.sh\n \n match() {\n-\tif [ $1 = 1 ]; then\n+\tif test \"$1\" = 1\n+\tthen\n \t\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n \t\t\ttest-wildmatch wildmatch '$3' '$4'\n \t\t\"\n@@ -17,7 +18,8 @@ match() {\n }\n \n imatch() {\n-\tif [ $1 = 1 ]; then\n+\tif test \"$1\" = 1\n+\tthen\n \t\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n \t\t\ttest-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n@@ -29,7 +31,8 @@ imatch() {\n }\n \n pathmatch() {\n-\tif [ $1 = 1 ]; then\n+\tif test \"$1\" = 1\n+\tthen\n \t\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n \t\t\ttest-wildmatch pathmatch '$2' '$3'\n \t\t\"\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335236","messageId":"20171223213012.1962-2-avarab@gmail.com","threadId":"47493","inReplyTo":"20171223213012.1962-1-avarab@gmail.com","subject":"[PATCH 1/6] wildmatch test: indent with tabs, not spaces","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-23T21:30:07Z","receivedAt":"2017-12-23T21:30:42Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Replace the 4-width mixed space & tab indentation in this file with\nindentation with tabs as we do in most of the rest of our tests.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 54 ++++++++++++++++++++++++++--------------------------\n 1 file changed, 27 insertions(+), 27 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 163a14a1c2..27fa878f6e 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -5,39 +5,39 @@ test_description='wildmatch tests'\n . ./test-lib.sh\n \n match() {\n-    if [ $1 = 1 ]; then\n-\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n-\t    test-wildmatch wildmatch '$3' '$4'\n-\t\"\n-    else\n-\ttest_expect_success \"wildmatch:  no match '$3' '$4'\" \"\n-\t    ! test-wildmatch wildmatch '$3' '$4'\n-\t\"\n-    fi\n+\tif [ $1 = 1 ]; then\n+\t\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n+\t\t\ttest-wildmatch wildmatch '$3' '$4'\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"wildmatch:  no match '$3' '$4'\" \"\n+\t\t\t! test-wildmatch wildmatch '$3' '$4'\n+\t\t\"\n+\tfi\n }\n \n imatch() {\n-    if [ $1 = 1 ]; then\n-\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n-\t    test-wildmatch iwildmatch '$2' '$3'\n-\t\"\n-    else\n-\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n-\t    ! test-wildmatch iwildmatch '$2' '$3'\n-\t\"\n-    fi\n+\tif [ $1 = 1 ]; then\n+\t\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n+\t\t\ttest-wildmatch iwildmatch '$2' '$3'\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n+\t\t\t! test-wildmatch iwildmatch '$2' '$3'\n+\t\t\"\n+\tfi\n }\n \n pathmatch() {\n-    if [ $1 = 1 ]; then\n-\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n-\t    test-wildmatch pathmatch '$2' '$3'\n-\t\"\n-    else\n-\ttest_expect_success \"pathmatch:  no match '$2' '$3'\" \"\n-\t    ! test-wildmatch pathmatch '$2' '$3'\n-\t\"\n-    fi\n+\tif [ $1 = 1 ]; then\n+\t\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n+\t\t\ttest-wildmatch pathmatch '$2' '$3'\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"pathmatch:  no match '$2' '$3'\" \"\n+\t\t\t! test-wildmatch pathmatch '$2' '$3'\n+\t\t\"\n+\tfi\n }\n \n # Basic wildmat features\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335237","messageId":"20171223213012.1962-4-avarab@gmail.com","threadId":"47493","inReplyTo":"20171223213012.1962-1-avarab@gmail.com","subject":"[PATCH 3/6] wildmatch test: use a paranoia pattern from nul_match()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-23T21:30:09Z","receivedAt":"2017-12-23T21:30:43Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Use a pattern from the nul_match() function in t7008-grep-binary.sh to\nmake sure that we don't just fall through to the \"else\" if there's an\nunknown parameter.\n\nThis is something I added in commit 77f6f4406f (\"grep: add a test\nhelper function for less verbose -f \\0 tests\", 2017-05-20) to grep\ntests, which were modeled on these wildmatch tests, and I'm now\nporting back to the original wildmatch tests.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 15 ++++++++++++---\n 1 file changed, 12 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 4d589d1f9a..71d6ea0f56 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -10,10 +10,13 @@ match() {\n \t\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n \t\t\ttest-wildmatch wildmatch '$3' '$4'\n \t\t\"\n-\telse\n+\telif test \"$1\" = 0\n+\tthen\n \t\ttest_expect_success \"wildmatch:  no match '$3' '$4'\" \"\n \t\t\t! test-wildmatch wildmatch '$3' '$4'\n \t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n \tfi\n }\n \n@@ -23,10 +26,13 @@ imatch() {\n \t\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n \t\t\ttest-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n-\telse\n+\telif test \"$1\" = 0\n+\tthen\n \t\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n \t\t\t! test-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n \tfi\n }\n \n@@ -36,10 +42,13 @@ pathmatch() {\n \t\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n \t\t\ttest-wildmatch pathmatch '$2' '$3'\n \t\t\"\n-\telse\n+\telif test \"$1\" = 0\n+\tthen\n \t\ttest_expect_success \"pathmatch:  no match '$2' '$3'\" \"\n \t\t\t! test-wildmatch pathmatch '$2' '$3'\n \t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n \tfi\n }\n \n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335238","messageId":"20171223213012.1962-5-avarab@gmail.com","threadId":"47493","inReplyTo":"20171223213012.1962-1-avarab@gmail.com","subject":"[PATCH 4/6] wildmatch test: remove dead fnmatch() test code","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-23T21:30:10Z","receivedAt":"2017-12-23T21:30:49Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the unused fnmatch() test parameter from the wildmatch\ntest. The code that used to test this was removed in 70a8fc999d (\"stop\nusing fnmatch (either native or compat)\", 2014-02-15).\n\nAs a --word-diff shows the only change to the body of the tests is the\nremoval of the second out of four parameters passed to match().\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 356 +++++++++++++++++++++++++--------------------------\n 1 file changed, 178 insertions(+), 178 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 71d6ea0f56..1624200a1e 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -7,13 +7,13 @@ test_description='wildmatch tests'\n match() {\n \tif test \"$1\" = 1\n \tthen\n-\t\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n-\t\t\ttest-wildmatch wildmatch '$3' '$4'\n+\t\ttest_expect_success \"wildmatch:     match '$2' '$3'\" \"\n+\t\t\ttest-wildmatch wildmatch '$2' '$3'\n \t\t\"\n \telif test \"$1\" = 0\n \tthen\n-\t\ttest_expect_success \"wildmatch:  no match '$3' '$4'\" \"\n-\t\t\t! test-wildmatch wildmatch '$3' '$4'\n+\t\ttest_expect_success \"wildmatch:  no match '$2' '$3'\" \"\n+\t\t\t! test-wildmatch wildmatch '$2' '$3'\n \t\t\"\n \telse\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n@@ -53,176 +53,176 @@ pathmatch() {\n }\n \n # Basic wildmat features\n-match 1 1 foo foo\n-match 0 0 foo bar\n-match 1 1 '' \"\"\n-match 1 1 foo '???'\n-match 0 0 foo '??'\n-match 1 1 foo '*'\n-match 1 1 foo 'f*'\n-match 0 0 foo '*f'\n-match 1 1 foo '*foo*'\n-match 1 1 foobar '*ob*a*r*'\n-match 1 1 aaaaaaabababab '*ab'\n-match 1 1 'foo*' 'foo\\*'\n-match 0 0 foobar 'foo\\*bar'\n-match 1 1 'f\\oo' 'f\\\\oo'\n-match 1 1 ball '*[al]?'\n-match 0 0 ten '[ten]'\n-match 0 1 ten '**[!te]'\n-match 0 0 ten '**[!ten]'\n-match 1 1 ten 't[a-g]n'\n-match 0 0 ten 't[!a-g]n'\n-match 1 1 ton 't[!a-g]n'\n-match 1 1 ton 't[^a-g]n'\n-match 1 x 'a]b' 'a[]]b'\n-match 1 x a-b 'a[]-]b'\n-match 1 x 'a]b' 'a[]-]b'\n-match 0 x aab 'a[]-]b'\n-match 1 x aab 'a[]a-]b'\n-match 1 1 ']' ']'\n+match 1 foo foo\n+match 0 foo bar\n+match 1 '' \"\"\n+match 1 foo '???'\n+match 0 foo '??'\n+match 1 foo '*'\n+match 1 foo 'f*'\n+match 0 foo '*f'\n+match 1 foo '*foo*'\n+match 1 foobar '*ob*a*r*'\n+match 1 aaaaaaabababab '*ab'\n+match 1 'foo*' 'foo\\*'\n+match 0 foobar 'foo\\*bar'\n+match 1 'f\\oo' 'f\\\\oo'\n+match 1 ball '*[al]?'\n+match 0 ten '[ten]'\n+match 0 ten '**[!te]'\n+match 0 ten '**[!ten]'\n+match 1 ten 't[a-g]n'\n+match 0 ten 't[!a-g]n'\n+match 1 ton 't[!a-g]n'\n+match 1 ton 't[^a-g]n'\n+match 1 'a]b' 'a[]]b'\n+match 1 a-b 'a[]-]b'\n+match 1 'a]b' 'a[]-]b'\n+match 0 aab 'a[]-]b'\n+match 1 aab 'a[]a-]b'\n+match 1 ']' ']'\n \n # Extended slash-matching features\n-match 0 0 'foo/baz/bar' 'foo*bar'\n-match 0 0 'foo/baz/bar' 'foo**bar'\n-match 0 1 'foobazbar' 'foo**bar'\n-match 1 1 'foo/baz/bar' 'foo/**/bar'\n-match 1 0 'foo/baz/bar' 'foo/**/**/bar'\n-match 1 0 'foo/b/a/z/bar' 'foo/**/bar'\n-match 1 0 'foo/b/a/z/bar' 'foo/**/**/bar'\n-match 1 0 'foo/bar' 'foo/**/bar'\n-match 1 0 'foo/bar' 'foo/**/**/bar'\n-match 0 0 'foo/bar' 'foo?bar'\n-match 0 0 'foo/bar' 'foo[/]bar'\n-match 0 0 'foo/bar' 'foo[^a-z]bar'\n-match 0 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 0 'foo' '**/foo'\n-match 1 x 'XXX/foo' '**/foo'\n-match 1 0 'bar/baz/foo' '**/foo'\n-match 0 0 'bar/baz/foo' '*/foo'\n-match 0 0 'foo/bar/baz' '**/bar*'\n-match 1 0 'deep/foo/bar/baz' '**/bar/*'\n-match 0 0 'deep/foo/bar/baz/' '**/bar/*'\n-match 1 0 'deep/foo/bar/baz/' '**/bar/**'\n-match 0 0 'deep/foo/bar' '**/bar/*'\n-match 1 0 'deep/foo/bar/' '**/bar/**'\n-match 0 0 'foo/bar/baz' '**/bar**'\n-match 1 0 'foo/bar/baz/x' '*/bar/**'\n-match 0 0 'deep/foo/bar/baz/x' '*/bar/**'\n-match 1 0 'deep/foo/bar/baz/x' '**/bar/*/*'\n+match 0 'foo/baz/bar' 'foo*bar'\n+match 0 'foo/baz/bar' 'foo**bar'\n+match 0 'foobazbar' 'foo**bar'\n+match 1 'foo/baz/bar' 'foo/**/bar'\n+match 1 'foo/baz/bar' 'foo/**/**/bar'\n+match 1 'foo/b/a/z/bar' 'foo/**/bar'\n+match 1 'foo/b/a/z/bar' 'foo/**/**/bar'\n+match 1 'foo/bar' 'foo/**/bar'\n+match 1 'foo/bar' 'foo/**/**/bar'\n+match 0 'foo/bar' 'foo?bar'\n+match 0 'foo/bar' 'foo[/]bar'\n+match 0 'foo/bar' 'foo[^a-z]bar'\n+match 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+match 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+match 1 'foo' '**/foo'\n+match 1 'XXX/foo' '**/foo'\n+match 1 'bar/baz/foo' '**/foo'\n+match 0 'bar/baz/foo' '*/foo'\n+match 0 'foo/bar/baz' '**/bar*'\n+match 1 'deep/foo/bar/baz' '**/bar/*'\n+match 0 'deep/foo/bar/baz/' '**/bar/*'\n+match 1 'deep/foo/bar/baz/' '**/bar/**'\n+match 0 'deep/foo/bar' '**/bar/*'\n+match 1 'deep/foo/bar/' '**/bar/**'\n+match 0 'foo/bar/baz' '**/bar**'\n+match 1 'foo/bar/baz/x' '*/bar/**'\n+match 0 'deep/foo/bar/baz/x' '*/bar/**'\n+match 1 'deep/foo/bar/baz/x' '**/bar/*/*'\n \n # Various additional tests\n-match 0 0 'acrt' 'a[c-c]st'\n-match 1 1 'acrt' 'a[c-c]rt'\n-match 0 0 ']' '[!]-]'\n-match 1 x 'a' '[!]-]'\n-match 0 0 '' '\\'\n-match 0 x '\\' '\\'\n-match 0 x 'XXX/\\' '*/\\'\n-match 1 x 'XXX/\\' '*/\\\\'\n-match 1 1 'foo' 'foo'\n-match 1 1 '@foo' '@foo'\n-match 0 0 'foo' '@foo'\n-match 1 1 '[ab]' '\\[ab]'\n-match 1 1 '[ab]' '[[]ab]'\n-match 1 x '[ab]' '[[:]ab]'\n-match 0 x '[ab]' '[[::]ab]'\n-match 1 x '[ab]' '[[:digit]ab]'\n-match 1 x '[ab]' '[\\[:]ab]'\n-match 1 1 '?a?b' '\\??\\?b'\n-match 1 1 'abc' '\\a\\b\\c'\n-match 0 0 'foo' ''\n-match 1 0 'foo/bar/baz/to' '**/t[o]'\n+match 0 'acrt' 'a[c-c]st'\n+match 1 'acrt' 'a[c-c]rt'\n+match 0 ']' '[!]-]'\n+match 1 'a' '[!]-]'\n+match 0 '' '\\'\n+match 0 '\\' '\\'\n+match 0 'XXX/\\' '*/\\'\n+match 1 'XXX/\\' '*/\\\\'\n+match 1 'foo' 'foo'\n+match 1 '@foo' '@foo'\n+match 0 'foo' '@foo'\n+match 1 '[ab]' '\\[ab]'\n+match 1 '[ab]' '[[]ab]'\n+match 1 '[ab]' '[[:]ab]'\n+match 0 '[ab]' '[[::]ab]'\n+match 1 '[ab]' '[[:digit]ab]'\n+match 1 '[ab]' '[\\[:]ab]'\n+match 1 '?a?b' '\\??\\?b'\n+match 1 'abc' '\\a\\b\\c'\n+match 0 'foo' ''\n+match 1 'foo/bar/baz/to' '**/t[o]'\n \n # Character class tests\n-match 1 x 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n-match 0 x 'a' '[[:digit:][:upper:][:space:]]'\n-match 1 x 'A' '[[:digit:][:upper:][:space:]]'\n-match 1 x '1' '[[:digit:][:upper:][:space:]]'\n-match 0 x '1' '[[:digit:][:upper:][:spaci:]]'\n-match 1 x ' ' '[[:digit:][:upper:][:space:]]'\n-match 0 x '.' '[[:digit:][:upper:][:space:]]'\n-match 1 x '.' '[[:digit:][:punct:][:space:]]'\n-match 1 x '5' '[[:xdigit:]]'\n-match 1 x 'f' '[[:xdigit:]]'\n-match 1 x 'D' '[[:xdigit:]]'\n-match 1 x '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n-match 1 x '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n-match 1 x '5' '[a-c[:digit:]x-z]'\n-match 1 x 'b' '[a-c[:digit:]x-z]'\n-match 1 x 'y' '[a-c[:digit:]x-z]'\n-match 0 x 'q' '[a-c[:digit:]x-z]'\n+match 1 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n+match 0 'a' '[[:digit:][:upper:][:space:]]'\n+match 1 'A' '[[:digit:][:upper:][:space:]]'\n+match 1 '1' '[[:digit:][:upper:][:space:]]'\n+match 0 '1' '[[:digit:][:upper:][:spaci:]]'\n+match 1 ' ' '[[:digit:][:upper:][:space:]]'\n+match 0 '.' '[[:digit:][:upper:][:space:]]'\n+match 1 '.' '[[:digit:][:punct:][:space:]]'\n+match 1 '5' '[[:xdigit:]]'\n+match 1 'f' '[[:xdigit:]]'\n+match 1 'D' '[[:xdigit:]]'\n+match 1 '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n+match 1 '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n+match 1 '5' '[a-c[:digit:]x-z]'\n+match 1 'b' '[a-c[:digit:]x-z]'\n+match 1 'y' '[a-c[:digit:]x-z]'\n+match 0 'q' '[a-c[:digit:]x-z]'\n \n # Additional tests, including some malformed wildmats\n-match 1 x ']' '[\\\\-^]'\n-match 0 0 '[' '[\\\\-^]'\n-match 1 x '-' '[\\-_]'\n-match 1 x ']' '[\\]]'\n-match 0 0 '\\]' '[\\]]'\n-match 0 0 '\\' '[\\]]'\n-match 0 0 'ab' 'a[]b'\n-match 0 x 'a[]b' 'a[]b'\n-match 0 x 'ab[' 'ab['\n-match 0 0 'ab' '[!'\n-match 0 0 'ab' '[-'\n-match 1 1 '-' '[-]'\n-match 0 0 '-' '[a-'\n-match 0 0 '-' '[!a-'\n-match 1 x '-' '[--A]'\n-match 1 x '5' '[--A]'\n-match 1 1 ' ' '[ --]'\n-match 1 1 '$' '[ --]'\n-match 1 1 '-' '[ --]'\n-match 0 0 '0' '[ --]'\n-match 1 x '-' '[---]'\n-match 1 x '-' '[------]'\n-match 0 0 'j' '[a-e-n]'\n-match 1 x '-' '[a-e-n]'\n-match 1 x 'a' '[!------]'\n-match 0 0 '[' '[]-a]'\n-match 1 x '^' '[]-a]'\n-match 0 0 '^' '[!]-a]'\n-match 1 x '[' '[!]-a]'\n-match 1 1 '^' '[a^bc]'\n-match 1 x '-b]' '[a-]b]'\n-match 0 0 '\\' '[\\]'\n-match 1 1 '\\' '[\\\\]'\n-match 0 0 '\\' '[!\\\\]'\n-match 1 1 'G' '[A-\\\\]'\n-match 0 0 'aaabbb' 'b*a'\n-match 0 0 'aabcaa' '*ba*'\n-match 1 1 ',' '[,]'\n-match 1 1 ',' '[\\\\,]'\n-match 1 1 '\\' '[\\\\,]'\n-match 1 1 '-' '[,-.]'\n-match 0 0 '+' '[,-.]'\n-match 0 0 '-.]' '[,-.]'\n-match 1 1 '2' '[\\1-\\3]'\n-match 1 1 '3' '[\\1-\\3]'\n-match 0 0 '4' '[\\1-\\3]'\n-match 1 1 '\\' '[[-\\]]'\n-match 1 1 '[' '[[-\\]]'\n-match 1 1 ']' '[[-\\]]'\n-match 0 0 '-' '[[-\\]]'\n+match 1 ']' '[\\\\-^]'\n+match 0 '[' '[\\\\-^]'\n+match 1 '-' '[\\-_]'\n+match 1 ']' '[\\]]'\n+match 0 '\\]' '[\\]]'\n+match 0 '\\' '[\\]]'\n+match 0 'ab' 'a[]b'\n+match 0 'a[]b' 'a[]b'\n+match 0 'ab[' 'ab['\n+match 0 'ab' '[!'\n+match 0 'ab' '[-'\n+match 1 '-' '[-]'\n+match 0 '-' '[a-'\n+match 0 '-' '[!a-'\n+match 1 '-' '[--A]'\n+match 1 '5' '[--A]'\n+match 1 ' ' '[ --]'\n+match 1 '$' '[ --]'\n+match 1 '-' '[ --]'\n+match 0 '0' '[ --]'\n+match 1 '-' '[---]'\n+match 1 '-' '[------]'\n+match 0 'j' '[a-e-n]'\n+match 1 '-' '[a-e-n]'\n+match 1 'a' '[!------]'\n+match 0 '[' '[]-a]'\n+match 1 '^' '[]-a]'\n+match 0 '^' '[!]-a]'\n+match 1 '[' '[!]-a]'\n+match 1 '^' '[a^bc]'\n+match 1 '-b]' '[a-]b]'\n+match 0 '\\' '[\\]'\n+match 1 '\\' '[\\\\]'\n+match 0 '\\' '[!\\\\]'\n+match 1 'G' '[A-\\\\]'\n+match 0 'aaabbb' 'b*a'\n+match 0 'aabcaa' '*ba*'\n+match 1 ',' '[,]'\n+match 1 ',' '[\\\\,]'\n+match 1 '\\' '[\\\\,]'\n+match 1 '-' '[,-.]'\n+match 0 '+' '[,-.]'\n+match 0 '-.]' '[,-.]'\n+match 1 '2' '[\\1-\\3]'\n+match 1 '3' '[\\1-\\3]'\n+match 0 '4' '[\\1-\\3]'\n+match 1 '\\' '[[-\\]]'\n+match 1 '[' '[[-\\]]'\n+match 1 ']' '[[-\\]]'\n+match 0 '-' '[[-\\]]'\n \n # Test recursion and the abort code (use \"wildtest -i\" to see iteration counts)\n-match 1 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 1 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n-match 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n-match 0 x foo '*/*/*'\n-match 0 x foo/bar '*/*/*'\n-match 1 x foo/bba/arr '*/*/*'\n-match 0 x foo/bb/aa/rr '*/*/*'\n-match 1 x foo/bb/aa/rr '**/**/**'\n-match 1 x abcXdefXghi '*X*i'\n-match 0 x ab/cXd/efXg/hi '*X*i'\n-match 1 x ab/cXd/efXg/hi '*/*X*/*/*i'\n-match 1 x ab/cXd/efXg/hi '**/*X*/**/*i'\n+match 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+match 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+match 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+match 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+match 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+match 1 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n+match 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n+match 0 foo '*/*/*'\n+match 0 foo/bar '*/*/*'\n+match 1 foo/bba/arr '*/*/*'\n+match 0 foo/bb/aa/rr '*/*/*'\n+match 1 foo/bb/aa/rr '**/**/**'\n+match 1 abcXdefXghi '*X*i'\n+match 0 ab/cXd/efXg/hi '*X*i'\n+match 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n+match 1 ab/cXd/efXg/hi '**/*X*/**/*i'\n \n pathmatch 1 foo foo\n pathmatch 0 foo fo\n@@ -248,20 +248,20 @@ pathmatch 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n pathmatch 1 ab/cXd/efXg/hi '*Xg*i'\n \n # Case-sensitivity features\n-match 0 x 'a' '[A-Z]'\n-match 1 x 'A' '[A-Z]'\n-match 0 x 'A' '[a-z]'\n-match 1 x 'a' '[a-z]'\n-match 0 x 'a' '[[:upper:]]'\n-match 1 x 'A' '[[:upper:]]'\n-match 0 x 'A' '[[:lower:]]'\n-match 1 x 'a' '[[:lower:]]'\n-match 0 x 'A' '[B-Za]'\n-match 1 x 'a' '[B-Za]'\n-match 0 x 'A' '[B-a]'\n-match 1 x 'a' '[B-a]'\n-match 0 x 'z' '[Z-y]'\n-match 1 x 'Z' '[Z-y]'\n+match 0 'a' '[A-Z]'\n+match 1 'A' '[A-Z]'\n+match 0 'A' '[a-z]'\n+match 1 'a' '[a-z]'\n+match 0 'a' '[[:upper:]]'\n+match 1 'A' '[[:upper:]]'\n+match 0 'A' '[[:lower:]]'\n+match 1 'a' '[[:lower:]]'\n+match 0 'A' '[B-Za]'\n+match 1 'a' '[B-Za]'\n+match 0 'A' '[B-a]'\n+match 1 'a' '[B-a]'\n+match 0 'z' '[Z-y]'\n+match 1 'Z' '[Z-y]'\n \n imatch 1 'a' '[A-Z]'\n imatch 1 'A' '[A-Z]'\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335239","messageId":"20171223213012.1962-6-avarab@gmail.com","threadId":"47493","inReplyTo":"20171223213012.1962-1-avarab@gmail.com","subject":"[PATCH 5/6] wildmatch test: perform all tests under all wildmatch() modes","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-23T21:30:11Z","receivedAt":"2017-12-23T21:30:51Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Rewrite the wildmatch() test suite so that each test now tests all\ncombinations of the wildmatch() WM_CASEFOLD and WM_PATHNAME flags.\n\nBefore this change some test inputs were not tested on\ne.g. WM_PATHNAME. Now the function is stress tested on all possible\ninputs, and for each input we declare what the result should be if the\nmode is case-insensitive, or pathname matching, or case-sensitive or\nnot matching pathnames.\n\nAlso before this change, nothing was testing case-insensitive\nnon-pathname matching, so I've added that to test-wildmatch.c and made\nuse of it.\n\nThis yields a rather scary patch, but there are no functional changes\nhere, just more test coverage. Some now-redundant tests were deleted\nas a result of this change, since they were now duplicating an earlier\ntest.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/helper/test-wildmatch.c |   2 +\n t/t3070-wildmatch.sh      | 478 +++++++++++++++++++++++-----------------------\n 2 files changed, 239 insertions(+), 241 deletions(-)\n\ndiff --git a/t/helper/test-wildmatch.c b/t/helper/test-wildmatch.c\nindex 921d7b3e7e..66d33dfcfd 100644\n--- a/t/helper/test-wildmatch.c\n+++ b/t/helper/test-wildmatch.c\n@@ -16,6 +16,8 @@ int cmd_main(int argc, const char **argv)\n \t\treturn !!wildmatch(argv[3], argv[2], WM_PATHNAME | WM_CASEFOLD);\n \telse if (!strcmp(argv[1], \"pathmatch\"))\n \t\treturn !!wildmatch(argv[3], argv[2], 0);\n+\telse if (!strcmp(argv[1], \"ipathmatch\"))\n+\t\treturn !!wildmatch(argv[3], argv[2], WM_CASEFOLD);\n \telse\n \t\treturn 1;\n }\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 1624200a1e..47b479e423 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -4,278 +4,274 @@ test_description='wildmatch tests'\n \n . ./test-lib.sh\n \n-match() {\n-\tif test \"$1\" = 1\n+wildtest() {\n+\tmatch_w_glob=$1\n+\tmatch_w_globi=$2\n+\tmatch_w_pathmatch=$3\n+\tmatch_w_pathmatchi=$4\n+\ttext=$5\n+\tpattern=$6\n+\n+\tif test \"$match_w_glob\" = 1\n \tthen\n-\t\ttest_expect_success \"wildmatch:     match '$2' '$3'\" \"\n-\t\t\ttest-wildmatch wildmatch '$2' '$3'\n+\t\ttest_expect_success \"wildmatch:     match '$text' '$pattern'\" \"\n+\t\t\ttest-wildmatch wildmatch '$text' '$pattern'\n \t\t\"\n-\telif test \"$1\" = 0\n+\telif test \"$match_w_glob\" = 0\n \tthen\n-\t\ttest_expect_success \"wildmatch:  no match '$2' '$3'\" \"\n-\t\t\t! test-wildmatch wildmatch '$2' '$3'\n+\t\ttest_expect_success \"wildmatch:  no match '$text' '$pattern'\" \"\n+\t\t\t! test-wildmatch wildmatch '$text' '$pattern'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_glob\" 'false'\n \tfi\n-}\n \n-imatch() {\n-\tif test \"$1\" = 1\n+\tif test \"$match_w_globi\" = 1\n \tthen\n-\t\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n-\t\t\ttest-wildmatch iwildmatch '$2' '$3'\n+\t\ttest_expect_success \"iwildmatch:    match '$text' '$pattern'\" \"\n+\t\t\ttest-wildmatch iwildmatch '$text' '$pattern'\n \t\t\"\n-\telif test \"$1\" = 0\n+\telif test \"$match_w_globi\" = 0\n \tthen\n-\t\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n-\t\t\t! test-wildmatch iwildmatch '$2' '$3'\n+\t\ttest_expect_success \"iwildmatch: no match '$text' '$pattern'\" \"\n+\t\t\t! test-wildmatch iwildmatch '$text' '$pattern'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_globi\" 'false'\n \tfi\n-}\n \n-pathmatch() {\n-\tif test \"$1\" = 1\n+\tif test \"$match_w_pathmatch\" = 1\n \tthen\n-\t\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n-\t\t\ttest-wildmatch pathmatch '$2' '$3'\n+\t\ttest_expect_success \"pathmatch:     match '$text' '$pattern'\" \"\n+\t\t\ttest-wildmatch pathmatch '$text' '$pattern'\n \t\t\"\n-\telif test \"$1\" = 0\n+\telif test \"$match_w_pathmatch\" = 0\n \tthen\n-\t\ttest_expect_success \"pathmatch:  no match '$2' '$3'\" \"\n-\t\t\t! test-wildmatch pathmatch '$2' '$3'\n+\t\ttest_expect_success \"pathmatch:  no match '$text' '$pattern'\" \"\n+\t\t\t! test-wildmatch pathmatch '$text' '$pattern'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_pathmatch\" 'false'\n+\tfi\n+\n+\tif test \"$match_w_pathmatchi\" = 1\n+\tthen\n+\t\ttest_expect_success \"ipathmatch:    match '$text' '$pattern'\" \"\n+\t\t\ttest-wildmatch ipathmatch '$text' '$pattern'\n+\t\t\"\n+\telif test \"$match_w_pathmatchi\" = 0\n+\tthen\n+\t\ttest_expect_success \"ipathmatch: no match '$text' '$pattern'\" \"\n+\t\t\t! test-wildmatch ipathmatch '$text' '$pattern'\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_pathmatchi\" 'false'\n \tfi\n }\n \n-# Basic wildmat features\n-match 1 foo foo\n-match 0 foo bar\n-match 1 '' \"\"\n-match 1 foo '???'\n-match 0 foo '??'\n-match 1 foo '*'\n-match 1 foo 'f*'\n-match 0 foo '*f'\n-match 1 foo '*foo*'\n-match 1 foobar '*ob*a*r*'\n-match 1 aaaaaaabababab '*ab'\n-match 1 'foo*' 'foo\\*'\n-match 0 foobar 'foo\\*bar'\n-match 1 'f\\oo' 'f\\\\oo'\n-match 1 ball '*[al]?'\n-match 0 ten '[ten]'\n-match 0 ten '**[!te]'\n-match 0 ten '**[!ten]'\n-match 1 ten 't[a-g]n'\n-match 0 ten 't[!a-g]n'\n-match 1 ton 't[!a-g]n'\n-match 1 ton 't[^a-g]n'\n-match 1 'a]b' 'a[]]b'\n-match 1 a-b 'a[]-]b'\n-match 1 'a]b' 'a[]-]b'\n-match 0 aab 'a[]-]b'\n-match 1 aab 'a[]a-]b'\n-match 1 ']' ']'\n+# Basic wildmatch features\n+wildtest 1 1 1 1 foo foo\n+wildtest 0 0 0 0 foo bar\n+wildtest 1 1 1 1 '' \"\"\n+wildtest 1 1 1 1 foo '???'\n+wildtest 0 0 0 0 foo '??'\n+wildtest 1 1 1 1 foo '*'\n+wildtest 1 1 1 1 foo 'f*'\n+wildtest 0 0 0 0 foo '*f'\n+wildtest 1 1 1 1 foo '*foo*'\n+wildtest 1 1 1 1 foobar '*ob*a*r*'\n+wildtest 1 1 1 1 aaaaaaabababab '*ab'\n+wildtest 1 1 1 1 'foo*' 'foo\\*'\n+wildtest 0 0 0 0 foobar 'foo\\*bar'\n+wildtest 1 1 1 1 'f\\oo' 'f\\\\oo'\n+wildtest 1 1 1 1 ball '*[al]?'\n+wildtest 0 0 0 0 ten '[ten]'\n+wildtest 0 0 1 1 ten '**[!te]'\n+wildtest 0 0 0 0 ten '**[!ten]'\n+wildtest 1 1 1 1 ten 't[a-g]n'\n+wildtest 0 0 0 0 ten 't[!a-g]n'\n+wildtest 1 1 1 1 ton 't[!a-g]n'\n+wildtest 1 1 1 1 ton 't[^a-g]n'\n+wildtest 1 1 1 1 'a]b' 'a[]]b'\n+wildtest 1 1 1 1 a-b 'a[]-]b'\n+wildtest 1 1 1 1 'a]b' 'a[]-]b'\n+wildtest 0 0 0 0 aab 'a[]-]b'\n+wildtest 1 1 1 1 aab 'a[]a-]b'\n+wildtest 1 1 1 1 ']' ']'\n \n # Extended slash-matching features\n-match 0 'foo/baz/bar' 'foo*bar'\n-match 0 'foo/baz/bar' 'foo**bar'\n-match 0 'foobazbar' 'foo**bar'\n-match 1 'foo/baz/bar' 'foo/**/bar'\n-match 1 'foo/baz/bar' 'foo/**/**/bar'\n-match 1 'foo/b/a/z/bar' 'foo/**/bar'\n-match 1 'foo/b/a/z/bar' 'foo/**/**/bar'\n-match 1 'foo/bar' 'foo/**/bar'\n-match 1 'foo/bar' 'foo/**/**/bar'\n-match 0 'foo/bar' 'foo?bar'\n-match 0 'foo/bar' 'foo[/]bar'\n-match 0 'foo/bar' 'foo[^a-z]bar'\n-match 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 'foo' '**/foo'\n-match 1 'XXX/foo' '**/foo'\n-match 1 'bar/baz/foo' '**/foo'\n-match 0 'bar/baz/foo' '*/foo'\n-match 0 'foo/bar/baz' '**/bar*'\n-match 1 'deep/foo/bar/baz' '**/bar/*'\n-match 0 'deep/foo/bar/baz/' '**/bar/*'\n-match 1 'deep/foo/bar/baz/' '**/bar/**'\n-match 0 'deep/foo/bar' '**/bar/*'\n-match 1 'deep/foo/bar/' '**/bar/**'\n-match 0 'foo/bar/baz' '**/bar**'\n-match 1 'foo/bar/baz/x' '*/bar/**'\n-match 0 'deep/foo/bar/baz/x' '*/bar/**'\n-match 1 'deep/foo/bar/baz/x' '**/bar/*/*'\n+wildtest 0 0 1 1 'foo/baz/bar' 'foo*bar'\n+wildtest 0 0 1 1 'foo/baz/bar' 'foo**bar'\n+wildtest 0 0 1 1 'foobazbar' 'foo**bar'\n+wildtest 1 1 1 1 'foo/baz/bar' 'foo/**/bar'\n+wildtest 1 1 0 0 'foo/baz/bar' 'foo/**/**/bar'\n+wildtest 1 1 1 1 'foo/b/a/z/bar' 'foo/**/bar'\n+wildtest 1 1 1 1 'foo/b/a/z/bar' 'foo/**/**/bar'\n+wildtest 1 1 0 0 'foo/bar' 'foo/**/bar'\n+wildtest 1 1 0 0 'foo/bar' 'foo/**/**/bar'\n+wildtest 0 0 1 1 'foo/bar' 'foo?bar'\n+wildtest 0 0 1 1 'foo/bar' 'foo[/]bar'\n+wildtest 0 0 1 1 'foo/bar' 'foo[^a-z]bar'\n+wildtest 0 0 1 1 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+wildtest 1 1 1 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+wildtest 1 1 0 0 'foo' '**/foo'\n+wildtest 1 1 1 1 'XXX/foo' '**/foo'\n+wildtest 1 1 1 1 'bar/baz/foo' '**/foo'\n+wildtest 0 0 1 1 'bar/baz/foo' '*/foo'\n+wildtest 0 0 1 1 'foo/bar/baz' '**/bar*'\n+wildtest 1 1 1 1 'deep/foo/bar/baz' '**/bar/*'\n+wildtest 0 0 1 1 'deep/foo/bar/baz/' '**/bar/*'\n+wildtest 1 1 1 1 'deep/foo/bar/baz/' '**/bar/**'\n+wildtest 0 0 0 0 'deep/foo/bar' '**/bar/*'\n+wildtest 1 1 1 1 'deep/foo/bar/' '**/bar/**'\n+wildtest 0 0 1 1 'foo/bar/baz' '**/bar**'\n+wildtest 1 1 1 1 'foo/bar/baz/x' '*/bar/**'\n+wildtest 0 0 1 1 'deep/foo/bar/baz/x' '*/bar/**'\n+wildtest 1 1 1 1 'deep/foo/bar/baz/x' '**/bar/*/*'\n \n # Various additional tests\n-match 0 'acrt' 'a[c-c]st'\n-match 1 'acrt' 'a[c-c]rt'\n-match 0 ']' '[!]-]'\n-match 1 'a' '[!]-]'\n-match 0 '' '\\'\n-match 0 '\\' '\\'\n-match 0 'XXX/\\' '*/\\'\n-match 1 'XXX/\\' '*/\\\\'\n-match 1 'foo' 'foo'\n-match 1 '@foo' '@foo'\n-match 0 'foo' '@foo'\n-match 1 '[ab]' '\\[ab]'\n-match 1 '[ab]' '[[]ab]'\n-match 1 '[ab]' '[[:]ab]'\n-match 0 '[ab]' '[[::]ab]'\n-match 1 '[ab]' '[[:digit]ab]'\n-match 1 '[ab]' '[\\[:]ab]'\n-match 1 '?a?b' '\\??\\?b'\n-match 1 'abc' '\\a\\b\\c'\n-match 0 'foo' ''\n-match 1 'foo/bar/baz/to' '**/t[o]'\n+wildtest 0 0 0 0 'acrt' 'a[c-c]st'\n+wildtest 1 1 1 1 'acrt' 'a[c-c]rt'\n+wildtest 0 0 0 0 ']' '[!]-]'\n+wildtest 1 1 1 1 'a' '[!]-]'\n+wildtest 0 0 0 0 '' '\\'\n+wildtest 0 0 0 0 '\\' '\\'\n+wildtest 0 0 0 0 'XXX/\\' '*/\\'\n+wildtest 1 1 1 1 'XXX/\\' '*/\\\\'\n+wildtest 1 1 1 1 'foo' 'foo'\n+wildtest 1 1 1 1 '@foo' '@foo'\n+wildtest 0 0 0 0 'foo' '@foo'\n+wildtest 1 1 1 1 '[ab]' '\\[ab]'\n+wildtest 1 1 1 1 '[ab]' '[[]ab]'\n+wildtest 1 1 1 1 '[ab]' '[[:]ab]'\n+wildtest 0 0 0 0 '[ab]' '[[::]ab]'\n+wildtest 1 1 1 1 '[ab]' '[[:digit]ab]'\n+wildtest 1 1 1 1 '[ab]' '[\\[:]ab]'\n+wildtest 1 1 1 1 '?a?b' '\\??\\?b'\n+wildtest 1 1 1 1 'abc' '\\a\\b\\c'\n+wildtest 0 0 0 0 'foo' ''\n+wildtest 1 1 1 1 'foo/bar/baz/to' '**/t[o]'\n \n # Character class tests\n-match 1 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n-match 0 'a' '[[:digit:][:upper:][:space:]]'\n-match 1 'A' '[[:digit:][:upper:][:space:]]'\n-match 1 '1' '[[:digit:][:upper:][:space:]]'\n-match 0 '1' '[[:digit:][:upper:][:spaci:]]'\n-match 1 ' ' '[[:digit:][:upper:][:space:]]'\n-match 0 '.' '[[:digit:][:upper:][:space:]]'\n-match 1 '.' '[[:digit:][:punct:][:space:]]'\n-match 1 '5' '[[:xdigit:]]'\n-match 1 'f' '[[:xdigit:]]'\n-match 1 'D' '[[:xdigit:]]'\n-match 1 '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n-match 1 '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n-match 1 '5' '[a-c[:digit:]x-z]'\n-match 1 'b' '[a-c[:digit:]x-z]'\n-match 1 'y' '[a-c[:digit:]x-z]'\n-match 0 'q' '[a-c[:digit:]x-z]'\n-\n-# Additional tests, including some malformed wildmats\n-match 1 ']' '[\\\\-^]'\n-match 0 '[' '[\\\\-^]'\n-match 1 '-' '[\\-_]'\n-match 1 ']' '[\\]]'\n-match 0 '\\]' '[\\]]'\n-match 0 '\\' '[\\]]'\n-match 0 'ab' 'a[]b'\n-match 0 'a[]b' 'a[]b'\n-match 0 'ab[' 'ab['\n-match 0 'ab' '[!'\n-match 0 'ab' '[-'\n-match 1 '-' '[-]'\n-match 0 '-' '[a-'\n-match 0 '-' '[!a-'\n-match 1 '-' '[--A]'\n-match 1 '5' '[--A]'\n-match 1 ' ' '[ --]'\n-match 1 '$' '[ --]'\n-match 1 '-' '[ --]'\n-match 0 '0' '[ --]'\n-match 1 '-' '[---]'\n-match 1 '-' '[------]'\n-match 0 'j' '[a-e-n]'\n-match 1 '-' '[a-e-n]'\n-match 1 'a' '[!------]'\n-match 0 '[' '[]-a]'\n-match 1 '^' '[]-a]'\n-match 0 '^' '[!]-a]'\n-match 1 '[' '[!]-a]'\n-match 1 '^' '[a^bc]'\n-match 1 '-b]' '[a-]b]'\n-match 0 '\\' '[\\]'\n-match 1 '\\' '[\\\\]'\n-match 0 '\\' '[!\\\\]'\n-match 1 'G' '[A-\\\\]'\n-match 0 'aaabbb' 'b*a'\n-match 0 'aabcaa' '*ba*'\n-match 1 ',' '[,]'\n-match 1 ',' '[\\\\,]'\n-match 1 '\\' '[\\\\,]'\n-match 1 '-' '[,-.]'\n-match 0 '+' '[,-.]'\n-match 0 '-.]' '[,-.]'\n-match 1 '2' '[\\1-\\3]'\n-match 1 '3' '[\\1-\\3]'\n-match 0 '4' '[\\1-\\3]'\n-match 1 '\\' '[[-\\]]'\n-match 1 '[' '[[-\\]]'\n-match 1 ']' '[[-\\]]'\n-match 0 '-' '[[-\\]]'\n+wildtest 1 1 1 1 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n+wildtest 0 1 0 1 'a' '[[:digit:][:upper:][:space:]]'\n+wildtest 1 1 1 1 'A' '[[:digit:][:upper:][:space:]]'\n+wildtest 1 1 1 1 '1' '[[:digit:][:upper:][:space:]]'\n+wildtest 0 0 0 0 '1' '[[:digit:][:upper:][:spaci:]]'\n+wildtest 1 1 1 1 ' ' '[[:digit:][:upper:][:space:]]'\n+wildtest 0 0 0 0 '.' '[[:digit:][:upper:][:space:]]'\n+wildtest 1 1 1 1 '.' '[[:digit:][:punct:][:space:]]'\n+wildtest 1 1 1 1 '5' '[[:xdigit:]]'\n+wildtest 1 1 1 1 'f' '[[:xdigit:]]'\n+wildtest 1 1 1 1 'D' '[[:xdigit:]]'\n+wildtest 1 1 1 1 '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n+wildtest 1 1 1 1 '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n+wildtest 1 1 1 1 '5' '[a-c[:digit:]x-z]'\n+wildtest 1 1 1 1 'b' '[a-c[:digit:]x-z]'\n+wildtest 1 1 1 1 'y' '[a-c[:digit:]x-z]'\n+wildtest 0 0 0 0 'q' '[a-c[:digit:]x-z]'\n \n-# Test recursion and the abort code (use \"wildtest -i\" to see iteration counts)\n-match 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 1 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n-match 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n-match 0 foo '*/*/*'\n-match 0 foo/bar '*/*/*'\n-match 1 foo/bba/arr '*/*/*'\n-match 0 foo/bb/aa/rr '*/*/*'\n-match 1 foo/bb/aa/rr '**/**/**'\n-match 1 abcXdefXghi '*X*i'\n-match 0 ab/cXd/efXg/hi '*X*i'\n-match 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n-match 1 ab/cXd/efXg/hi '**/*X*/**/*i'\n+# Additional tests, including some malformed wildmatch patterns\n+wildtest 1 1 1 1 ']' '[\\\\-^]'\n+wildtest 0 0 0 0 '[' '[\\\\-^]'\n+wildtest 1 1 1 1 '-' '[\\-_]'\n+wildtest 1 1 1 1 ']' '[\\]]'\n+wildtest 0 0 0 0 '\\]' '[\\]]'\n+wildtest 0 0 0 0 '\\' '[\\]]'\n+wildtest 0 0 0 0 'ab' 'a[]b'\n+wildtest 0 0 0 0 'a[]b' 'a[]b'\n+wildtest 0 0 0 0 'ab[' 'ab['\n+wildtest 0 0 0 0 'ab' '[!'\n+wildtest 0 0 0 0 'ab' '[-'\n+wildtest 1 1 1 1 '-' '[-]'\n+wildtest 0 0 0 0 '-' '[a-'\n+wildtest 0 0 0 0 '-' '[!a-'\n+wildtest 1 1 1 1 '-' '[--A]'\n+wildtest 1 1 1 1 '5' '[--A]'\n+wildtest 1 1 1 1 ' ' '[ --]'\n+wildtest 1 1 1 1 '$' '[ --]'\n+wildtest 1 1 1 1 '-' '[ --]'\n+wildtest 0 0 0 0 '0' '[ --]'\n+wildtest 1 1 1 1 '-' '[---]'\n+wildtest 1 1 1 1 '-' '[------]'\n+wildtest 0 0 0 0 'j' '[a-e-n]'\n+wildtest 1 1 1 1 '-' '[a-e-n]'\n+wildtest 1 1 1 1 'a' '[!------]'\n+wildtest 0 0 0 0 '[' '[]-a]'\n+wildtest 1 1 1 1 '^' '[]-a]'\n+wildtest 0 0 0 0 '^' '[!]-a]'\n+wildtest 1 1 1 1 '[' '[!]-a]'\n+wildtest 1 1 1 1 '^' '[a^bc]'\n+wildtest 1 1 1 1 '-b]' '[a-]b]'\n+wildtest 0 0 0 0 '\\' '[\\]'\n+wildtest 1 1 1 1 '\\' '[\\\\]'\n+wildtest 0 0 0 0 '\\' '[!\\\\]'\n+wildtest 1 1 1 1 'G' '[A-\\\\]'\n+wildtest 0 0 0 0 'aaabbb' 'b*a'\n+wildtest 0 0 0 0 'aabcaa' '*ba*'\n+wildtest 1 1 1 1 ',' '[,]'\n+wildtest 1 1 1 1 ',' '[\\\\,]'\n+wildtest 1 1 1 1 '\\' '[\\\\,]'\n+wildtest 1 1 1 1 '-' '[,-.]'\n+wildtest 0 0 0 0 '+' '[,-.]'\n+wildtest 0 0 0 0 '-.]' '[,-.]'\n+wildtest 1 1 1 1 '2' '[\\1-\\3]'\n+wildtest 1 1 1 1 '3' '[\\1-\\3]'\n+wildtest 0 0 0 0 '4' '[\\1-\\3]'\n+wildtest 1 1 1 1 '\\' '[[-\\]]'\n+wildtest 1 1 1 1 '[' '[[-\\]]'\n+wildtest 1 1 1 1 ']' '[[-\\]]'\n+wildtest 0 0 0 0 '-' '[[-\\]]'\n \n-pathmatch 1 foo foo\n-pathmatch 0 foo fo\n-pathmatch 1 foo/bar foo/bar\n-pathmatch 1 foo/bar 'foo/*'\n-pathmatch 1 foo/bba/arr 'foo/*'\n-pathmatch 1 foo/bba/arr 'foo/**'\n-pathmatch 1 foo/bba/arr 'foo*'\n-pathmatch 1 foo/bba/arr 'foo**'\n-pathmatch 1 foo/bba/arr 'foo/*arr'\n-pathmatch 1 foo/bba/arr 'foo/**arr'\n-pathmatch 0 foo/bba/arr 'foo/*z'\n-pathmatch 0 foo/bba/arr 'foo/**z'\n-pathmatch 1 foo/bar 'foo?bar'\n-pathmatch 1 foo/bar 'foo[/]bar'\n-pathmatch 1 foo/bar 'foo[^a-z]bar'\n-pathmatch 0 foo '*/*/*'\n-pathmatch 0 foo/bar '*/*/*'\n-pathmatch 1 foo/bba/arr '*/*/*'\n-pathmatch 1 foo/bb/aa/rr '*/*/*'\n-pathmatch 1 abcXdefXghi '*X*i'\n-pathmatch 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n-pathmatch 1 ab/cXd/efXg/hi '*Xg*i'\n+# Test recursion\n+wildtest 1 1 1 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+wildtest 0 0 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+wildtest 0 0 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+wildtest 1 1 1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+wildtest 0 0 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+wildtest 1 1 1 1 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n+wildtest 0 0 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n+wildtest 0 0 0 0 foo '*/*/*'\n+wildtest 0 0 0 0 foo/bar '*/*/*'\n+wildtest 1 1 1 1 foo/bba/arr '*/*/*'\n+wildtest 0 0 1 1 foo/bb/aa/rr '*/*/*'\n+wildtest 1 1 1 1 foo/bb/aa/rr '**/**/**'\n+wildtest 1 1 1 1 abcXdefXghi '*X*i'\n+wildtest 0 0 1 1 ab/cXd/efXg/hi '*X*i'\n+wildtest 1 1 1 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n+wildtest 1 1 1 1 ab/cXd/efXg/hi '**/*X*/**/*i'\n \n-# Case-sensitivity features\n-match 0 'a' '[A-Z]'\n-match 1 'A' '[A-Z]'\n-match 0 'A' '[a-z]'\n-match 1 'a' '[a-z]'\n-match 0 'a' '[[:upper:]]'\n-match 1 'A' '[[:upper:]]'\n-match 0 'A' '[[:lower:]]'\n-match 1 'a' '[[:lower:]]'\n-match 0 'A' '[B-Za]'\n-match 1 'a' '[B-Za]'\n-match 0 'A' '[B-a]'\n-match 1 'a' '[B-a]'\n-match 0 'z' '[Z-y]'\n-match 1 'Z' '[Z-y]'\n+# Extra pathmatch tests\n+wildtest 0 0 0 0 foo fo\n+wildtest 1 1 1 1 foo/bar foo/bar\n+wildtest 1 1 1 1 foo/bar 'foo/*'\n+wildtest 0 0 1 1 foo/bba/arr 'foo/*'\n+wildtest 1 1 1 1 foo/bba/arr 'foo/**'\n+wildtest 0 0 1 1 foo/bba/arr 'foo*'\n+wildtest 0 0 1 1 foo/bba/arr 'foo**'\n+wildtest 0 0 1 1 foo/bba/arr 'foo/*arr'\n+wildtest 0 0 1 1 foo/bba/arr 'foo/**arr'\n+wildtest 0 0 0 0 foo/bba/arr 'foo/*z'\n+wildtest 0 0 0 0 foo/bba/arr 'foo/**z'\n+wildtest 0 0 1 1 foo/bar 'foo?bar'\n+wildtest 0 0 1 1 foo/bar 'foo[/]bar'\n+wildtest 0 0 1 1 foo/bar 'foo[^a-z]bar'\n+wildtest 0 0 1 1 ab/cXd/efXg/hi '*Xg*i'\n \n-imatch 1 'a' '[A-Z]'\n-imatch 1 'A' '[A-Z]'\n-imatch 1 'A' '[a-z]'\n-imatch 1 'a' '[a-z]'\n-imatch 1 'a' '[[:upper:]]'\n-imatch 1 'A' '[[:upper:]]'\n-imatch 1 'A' '[[:lower:]]'\n-imatch 1 'a' '[[:lower:]]'\n-imatch 1 'A' '[B-Za]'\n-imatch 1 'a' '[B-Za]'\n-imatch 1 'A' '[B-a]'\n-imatch 1 'a' '[B-a]'\n-imatch 1 'z' '[Z-y]'\n-imatch 1 'Z' '[Z-y]'\n+# Extra case-sensitivity tests\n+wildtest 0 1 0 1 'a' '[A-Z]'\n+wildtest 1 1 1 1 'A' '[A-Z]'\n+wildtest 0 1 0 1 'A' '[a-z]'\n+wildtest 1 1 1 1 'a' '[a-z]'\n+wildtest 0 1 0 1 'a' '[[:upper:]]'\n+wildtest 1 1 1 1 'A' '[[:upper:]]'\n+wildtest 0 1 0 1 'A' '[[:lower:]]'\n+wildtest 1 1 1 1 'a' '[[:lower:]]'\n+wildtest 0 1 0 1 'A' '[B-Za]'\n+wildtest 1 1 1 1 'a' '[B-Za]'\n+wildtest 0 1 0 1 'A' '[B-a]'\n+wildtest 1 1 1 1 'a' '[B-a]'\n+wildtest 0 1 0 1 'z' '[Z-y]'\n+wildtest 1 1 1 1 'Z' '[Z-y]'\n \n test_done\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335240","messageId":"20171223213012.1962-7-avarab@gmail.com","threadId":"47493","inReplyTo":"20171223213012.1962-1-avarab@gmail.com","subject":"[PATCH 6/6] wildmatch test: create & test files on disk in addition to in-memory","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-23T21:30:12Z","receivedAt":"2017-12-23T21:30:53Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"There has never been any full roundtrip testing of what git-ls-files\nand other functions that use wildmatch() actually do, rather we've\nbeen satisfied with just testing the underlying C function.\n\nDue to git-ls-files and friends having their own codepaths before they\ncall wildmatch() there's sometimes differences in the behavior between\nthe two, and even when we test for those (as with\n9e4e8a64c2 (\"pathspec: die on empty strings as pathspec\", 2017-06-06))\nthere was no one place where you can review how these two modes\ndiffer.\n\nNow there is. With this admittedly very verbose code that's mostly\ncopy-pasted (it doesn't look worth the effort to me in clarity to\nfactor this into functions) we now attempt to create a file called\n$haystack and match $needle against it for each pair of $needle and\n$haystack that we were passing to test-wildmatch.\n\nIf we can't create the file we skip the test. This ensures that we can\nrun this on all platforms and not maintain some infinitely growing\nwhitelist of e.g. platforms that don't support certain characters in\nfilenames.\n\nAs a result of doing this we can now see the cases where these two\nways of testing wildmatch differ:\n\n * Creating a file called 'a[]b' and running ls-files 'a[]b' will show\n   that file, but wildmatch(\"a[]b\", \"a[]b\") will not match\n\n * wildmatch() won't match a file called \\ against \\, but ls-files\n   will.\n\n * `git --glob-pathspecs ls-files 'foo**'` will match a file\n   'foo/bba/arr', but wildmatch won't, however pathmatch will.\n\n   This seems like a bug to me, the two are otherwise equivalent as\n   these tests show.\n\nThis also reveals the case discussed in 9e4e8a64c2 above, where '' is\nnow an error as far as ls-files is concerned, but wildmatch() itself\nhappily accepts it.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n a[]b                 |   0\n t/t3070-wildmatch.sh | 336 ++++++++++++++++++++++++++++++++++++++++++++++++---\n 2 files changed, 319 insertions(+), 17 deletions(-)\n create mode 100644 a[]b\n\ndiff --git a/a[]b b/a[]b\nnew file mode 100644\nindex 0000000000..e69de29bb2\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 47b479e423..d423bb01f3 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -4,31 +4,146 @@ test_description='wildmatch tests'\n \n . ./test-lib.sh\n \n+create_test_file() {\n+\tfile=$1\n+\n+\t# `touch .` will succeed but obviously not do what we intend\n+\t# here.\n+\ttest \"$file\" = \".\" && return 1\n+\t# We cannot create a file with an empty filename.\n+\ttest \"$file\" = \"\" && return 1\n+\t# The tests that are testing that e.g. foo//bar is matched by\n+\t# foo/*/bar can't be tested on filesystems since there's no\n+\t# way we're getting a double slash.\n+\techo \"$file\" | grep -q -F '//' && return 1\n+\t# When testing the difference between foo/bar and foo/bar/ we\n+\t# can't test the latter.\n+\techo \"$file\" | grep -q -E '/$' && return 1\n+\n+\tdirs=$(echo \"$file\" | sed -r 's!/[^/]+$!!')\n+\n+\t# We touch \"./$file\" instead of \"$file\" because even an\n+\t# escaped \"touch -- -\" means something different.\n+\tif test \"$file\" != \"$dirs\"\n+\tthen\n+\t\tmkdir -p -- \"$dirs\" 2>/dev/null &&\n+\t\ttouch -- \"./$file\" 2>/dev/null &&\n+\t\treturn 0\n+\telse\n+\t\ttouch -- \"./$file\" 2>/dev/null &&\n+\t\treturn 0\n+\tfi\n+\treturn 1\n+}\n+\n wildtest() {\n-\tmatch_w_glob=$1\n-\tmatch_w_globi=$2\n-\tmatch_w_pathmatch=$3\n-\tmatch_w_pathmatchi=$4\n-\ttext=$5\n-\tpattern=$6\n+\tif test \"$#\" = 6\n+\tthen\n+\t\t# When test-wildmatch and git ls-files produce the same\n+\t\t# result.\n+\t\tmatch_w_glob=$1\n+\t\tmatch_f_w_glob=$match_w_glob\n+\t\tmatch_w_globi=$2\n+\t\tmatch_f_w_globi=$match_w_globi\n+\t\tmatch_w_pathmatch=$3\n+\t\tmatch_f_w_pathmatch=$match_w_pathmatch\n+\t\tmatch_w_pathmatchi=$4\n+\t\tmatch_f_w_pathmatchi=$match_w_pathmatchi\n+\t\ttext=$5\n+\t\tpattern=$6\n+\telif test \"$#\" = 10\n+\tthen\n+\t\tmatch_w_glob=$1\n+\t\tmatch_w_globi=$2\n+\t\tmatch_w_pathmatch=$3\n+\t\tmatch_w_pathmatchi=$4\n+\t\tmatch_f_w_glob=$5\n+\t\tmatch_f_w_globi=$6\n+\t\tmatch_f_w_pathmatch=$7\n+\t\tmatch_f_w_pathmatchi=$8\n+\t\ttext=$9\n+\t\tpattern=$10\n+\tfi\n \n+\t# $1: Case sensitive glob match: test-wildmatch\n \tif test \"$match_w_glob\" = 1\n \tthen\n-\t\ttest_expect_success \"wildmatch:     match '$text' '$pattern'\" \"\n+\t\ttest_expect_success \"wildmatch: match '$text' '$pattern'\" \"\n \t\t\ttest-wildmatch wildmatch '$text' '$pattern'\n \t\t\"\n \telif test \"$match_w_glob\" = 0\n \tthen\n-\t\ttest_expect_success \"wildmatch:  no match '$text' '$pattern'\" \"\n+\t\ttest_expect_success \"wildmatch: no match '$text' '$pattern'\" \"\n \t\t\t! test-wildmatch wildmatch '$text' '$pattern'\n \t\t\"\n \telse\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_glob\" 'false'\n \tfi\n \n+\t# $1: Case sensitive glob match: ls-files\n+\tif test \"$match_f_w_glob\" = 'E'\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"wildmatch(ls): match dies on '$pattern' '$text'\" \"\n+\t\t\t\ttest_when_finished \\\"\n+\t\t\t\t\trm -rf -- * &&\n+\t\t\t\t\tgit reset\n+\t\t\t\t\\\" &&\n+\t\t\t\tgit add -A &&\n+\t\t\t\t>expect.err &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\ttest_must_fail git --glob-pathspecs ls-files -z -- '$pattern'\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_glob\" = 1\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"wildmatch(ls): match '$pattern' '$text'\" \"\n+\t\t\t\ttest_when_finished \\\"\n+\t\t\t\t\trm -rf -- * &&\n+\t\t\t\t\tgit reset\n+\t\t\t\t\\\" &&\n+\t\t\t\tgit add -A &&\n+\t\t\t\t>expect.err &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\tgit --glob-pathspecs ls-files -z -- '$pattern' 2>actual.err | tr -d '\\0' >actual &&\n+\t\t\t\ttest_cmp expect.err actual.err &&\n+\t\t\t\ttest_cmp expect actual\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_glob\" = 0\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"wildmatch(ls): no match '$pattern' '$text'\" \"\n+\t\t\t\ttest_when_finished \\\"\n+\t\t\t\t\trm -rf -- * &&\n+\t\t\t\t\tgit reset\n+\t\t\t\t\\\" &&\n+\t\t\t\tgit add -A &&\n+\t\t\t\t>expect.err &&\n+\t\t\t\t>expect &&\n+\t\t\t\tgit --glob-pathspecs ls-files -z -- '$pattern' 2>actual.err | tr -d '\\0' >actual &&\n+\t\t\t\ttest_cmp expect.err actual.err &&\n+\t\t\t\ttest_cmp expect actual\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): no match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_f_w_glob\" 'false'\n+\tfi\n+\n+\t# $2: Case insensitive glob match: test-wildmatch\n \tif test \"$match_w_globi\" = 1\n \tthen\n-\t\ttest_expect_success \"iwildmatch:    match '$text' '$pattern'\" \"\n+\t\ttest_expect_success \"iwildmatch: match '$text' '$pattern'\" \"\n \t\t\ttest-wildmatch iwildmatch '$text' '$pattern'\n \t\t\"\n \telif test \"$match_w_globi\" = 0\n@@ -40,23 +155,145 @@ wildtest() {\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_globi\" 'false'\n \tfi\n \n+\t# $2: Case insensitive glob match: ls-files\n+\tif test \"$match_f_w_globi\" = 'E'\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"wildmatch(ls): match dies on '$pattern' '$text'\" \"\n+\t\t\t\ttest_when_finished \\\"\n+\t\t\t\t\trm -rf -- * &&\n+\t\t\t\t\tgit reset\n+\t\t\t\t\\\" &&\n+\t\t\t\tgit add -A &&\n+\t\t\t\t>expect.err &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\ttest_must_fail git --glob-pathspecs --icase-pathspecs ls-files -z -- '$pattern'\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_globi\" = 1\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"wildmatch(ls): match '$pattern' '$text'\" \"\n+\t\t\t\ttest_when_finished \\\"\n+\t\t\t\t\trm -rf -- * &&\n+\t\t\t\t\tgit reset\n+\t\t\t\t\\\" &&\n+\t\t\t\tgit add -A &&\n+\t\t\t\t>expect.err &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\tgit --glob-pathspecs --icase-pathspecs ls-files -z -- '$pattern' 2>actual.err | tr -d '\\0' >actual &&\n+\t\t\t\ttest_cmp expect.err actual.err &&\n+\t\t\t\ttest_cmp expect actual\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_globi\" = 0\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"wildmatch(ls): no match '$pattern' '$text'\" \"\n+\t\t\t\ttest_when_finished \\\"\n+\t\t\t\t\trm -rf -- * &&\n+\t\t\t\t\tgit reset\n+\t\t\t\t\\\" &&\n+\t\t\t\tgit add -A &&\n+\t\t\t\t>expect.err &&\n+\t\t\t\t>expect &&\n+\t\t\t\tgit --glob-pathspecs --icase-pathspecs ls-files -z -- '$pattern' 2>actual.err | tr -d '\\0' >actual &&\n+\t\t\t\ttest_cmp expect.err actual.err &&\n+\t\t\t\ttest_cmp expect actual\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): no match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_f_w_globi\" 'false'\n+\tfi\n+\n+\t# $3: Case sensitive path match: test-wildmatch\n \tif test \"$match_w_pathmatch\" = 1\n \tthen\n-\t\ttest_expect_success \"pathmatch:     match '$text' '$pattern'\" \"\n+\t\ttest_expect_success \"pathmatch: match '$text' '$pattern'\" \"\n \t\t\ttest-wildmatch pathmatch '$text' '$pattern'\n \t\t\"\n \telif test \"$match_w_pathmatch\" = 0\n \tthen\n-\t\ttest_expect_success \"pathmatch:  no match '$text' '$pattern'\" \"\n+\t\ttest_expect_success \"pathmatch: no match '$text' '$pattern'\" \"\n \t\t\t! test-wildmatch pathmatch '$text' '$pattern'\n \t\t\"\n \telse\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_pathmatch\" 'false'\n \tfi\n \n+\t# $4: Case sensitive path match: ls-files\n+\tif test \"$match_f_w_pathmatch\" = 'E'\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"pathmatch(ls): match dies on '$pattern' '$text'\" \"\n+\t\t\t\ttest_when_finished \\\"\n+\t\t\t\t\trm -rf -- * &&\n+\t\t\t\t\tgit reset\n+\t\t\t\t\\\" &&\n+\t\t\t\tgit add -A &&\n+\t\t\t\t>expect.err &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\ttest_must_fail git ls-files -z -- '$pattern'\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_pathmatch\" = 1\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"pathmatch(ls): match '$pattern' '$text'\" \"\n+\t\t\t\ttest_when_finished \\\"\n+\t\t\t\t\trm -rf -- * &&\n+\t\t\t\t\tgit reset\n+\t\t\t\t\\\" &&\n+\t\t\t\tgit add -A &&\n+\t\t\t\t>expect.err &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\tgit ls-files -z -- '$pattern' 2>actual.err | tr -d '\\0' >actual &&\n+\t\t\t\ttest_cmp expect.err actual.err &&\n+\t\t\t\ttest_cmp expect actual\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_pathmatch\" = 0\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"pathmatch(ls): no match '$pattern' '$text'\" \"\n+\t\t\t\ttest_when_finished \\\"\n+\t\t\t\t\trm -rf -- * &&\n+\t\t\t\t\tgit reset\n+\t\t\t\t\\\" &&\n+\t\t\t\tgit add -A &&\n+\t\t\t\t>expect.err &&\n+\t\t\t\t>expect &&\n+\t\t\t\tgit ls-files -z -- '$pattern' 2>actual.err | tr -d '\\0' >actual &&\n+\t\t\t\ttest_cmp expect.err actual.err &&\n+\t\t\t\ttest_cmp expect actual\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): no match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_f_w_pathmatch\" 'false'\n+\tfi\n+\n+\t# $4: Case insensitive path match: test-wildmatch\n \tif test \"$match_w_pathmatchi\" = 1\n \tthen\n-\t\ttest_expect_success \"ipathmatch:    match '$text' '$pattern'\" \"\n+\t\ttest_expect_success \"ipathmatch: match '$text' '$pattern'\" \"\n \t\t\ttest-wildmatch ipathmatch '$text' '$pattern'\n \t\t\"\n \telif test \"$match_w_pathmatchi\" = 0\n@@ -67,6 +304,66 @@ wildtest() {\n \telse\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_pathmatchi\" 'false'\n \tfi\n+\n+\t# $4: Case insensitive path match: ls-files\n+\tif test \"$match_f_w_pathmatchi\" = 'E'\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"ipathmatch(ls): match dies on '$pattern' '$text'\" \"\n+\t\t\t\ttest_when_finished \\\"\n+\t\t\t\t\trm -rf -- * &&\n+\t\t\t\t\tgit reset\n+\t\t\t\t\\\" &&\n+\t\t\t\tgit add -A &&\n+\t\t\t\t>expect.err &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\ttest_must_fail git --icase-pathspecs ls-files -z -- '$pattern'\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_pathmatchi\" = 1\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"ipathmatch(ls): match '$pattern' '$text'\" \"\n+\t\t\t\ttest_when_finished \\\"\n+\t\t\t\t\trm -rf -- * &&\n+\t\t\t\t\tgit reset\n+\t\t\t\t\\\" &&\n+\t\t\t\tgit add -A &&\n+\t\t\t\t>expect.err &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\tgit --icase-pathspecs ls-files -z -- '$pattern' 2>actual.err | tr -d '\\0' >actual &&\n+\t\t\t\ttest_cmp expect.err actual.err &&\n+\t\t\t\ttest_cmp expect actual\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_pathmatchi\" = 0\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"ipathmatch(ls): no match '$pattern' '$text'\" \"\n+\t\t\t\ttest_when_finished \\\"\n+\t\t\t\t\trm -rf -- * &&\n+\t\t\t\t\tgit reset\n+\t\t\t\t\\\" &&\n+\t\t\t\tgit add -A &&\n+\t\t\t\t>expect.err &&\n+\t\t\t\t>expect &&\n+\t\t\t\tgit ls-files -z -- '$pattern' 2>actual.err | tr -d '\\0' >actual &&\n+\t\t\t\ttest_cmp expect.err actual.err &&\n+\t\t\t\ttest_cmp expect actual\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): no match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_f_w_pathmatchi\" 'false'\n+\tfi\n }\n \n # Basic wildmatch features\n@@ -135,7 +432,8 @@ wildtest 1 1 1 1 'acrt' 'a[c-c]rt'\n wildtest 0 0 0 0 ']' '[!]-]'\n wildtest 1 1 1 1 'a' '[!]-]'\n wildtest 0 0 0 0 '' '\\'\n-wildtest 0 0 0 0 '\\' '\\'\n+wildtest 0 0 0 0 \\\n+\t 1 1 1 1 '\\' '\\'\n wildtest 0 0 0 0 'XXX/\\' '*/\\'\n wildtest 1 1 1 1 'XXX/\\' '*/\\\\'\n wildtest 1 1 1 1 'foo' 'foo'\n@@ -149,7 +447,8 @@ wildtest 1 1 1 1 '[ab]' '[[:digit]ab]'\n wildtest 1 1 1 1 '[ab]' '[\\[:]ab]'\n wildtest 1 1 1 1 '?a?b' '\\??\\?b'\n wildtest 1 1 1 1 'abc' '\\a\\b\\c'\n-wildtest 0 0 0 0 'foo' ''\n+wildtest 0 0 0 0 \\\n+\t E E E E 'foo' ''\n wildtest 1 1 1 1 'foo/bar/baz/to' '**/t[o]'\n \n # Character class tests\n@@ -179,8 +478,10 @@ wildtest 1 1 1 1 ']' '[\\]]'\n wildtest 0 0 0 0 '\\]' '[\\]]'\n wildtest 0 0 0 0 '\\' '[\\]]'\n wildtest 0 0 0 0 'ab' 'a[]b'\n-wildtest 0 0 0 0 'a[]b' 'a[]b'\n-wildtest 0 0 0 0 'ab[' 'ab['\n+wildtest 0 0 0 0 \\\n+\t 1 1 1 1 'a[]b' 'a[]b'\n+wildtest 0 0 0 0 \\\n+\t 1 1 1 1 'ab[' 'ab['\n wildtest 0 0 0 0 'ab' '[!'\n wildtest 0 0 0 0 'ab' '[-'\n wildtest 1 1 1 1 '-' '[-]'\n@@ -248,7 +549,8 @@ wildtest 1 1 1 1 foo/bar 'foo/*'\n wildtest 0 0 1 1 foo/bba/arr 'foo/*'\n wildtest 1 1 1 1 foo/bba/arr 'foo/**'\n wildtest 0 0 1 1 foo/bba/arr 'foo*'\n-wildtest 0 0 1 1 foo/bba/arr 'foo**'\n+wildtest 0 0 1 1 \\\n+\t 1 1 1 1 foo/bba/arr 'foo**'\n wildtest 0 0 1 1 foo/bba/arr 'foo/*arr'\n wildtest 0 0 1 1 foo/bba/arr 'foo/**arr'\n wildtest 0 0 0 0 foo/bba/arr 'foo/*z'\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335248","messageId":"8f4cdb23-8e2e-144a-1f70-99776b027166@kdbg.org","threadId":"47493","inReplyTo":"20171223213012.1962-7-avarab@gmail.com","subject":"Re: [PATCH 6/6] wildmatch test: create & test files on disk in addition to in-memory","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2017-12-24T09:24:52Z","receivedAt":"2017-12-24T09:25:04Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 23.12.2017 um 22:30 schrieb Ævar Arnfjörð Bjarmason:\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>   a[]b                 |   0\n>   t/t3070-wildmatch.sh | 336 ++++++++++++++++++++++++++++++++++++++++++++++++---\n>   2 files changed, 319 insertions(+), 17 deletions(-)\n>   create mode 100644 a[]b\n> \n> diff --git a/a[]b b/a[]b\n> new file mode 100644\n> index 0000000000..e69de29bb2\n\nA big no-no! This file can't be created on Windows!\n\n> diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\n> index 47b479e423..d423bb01f3 100755\n> --- a/t/t3070-wildmatch.sh\n> +++ b/t/t3070-wildmatch.sh\n> @@ -4,31 +4,146 @@ test_description='wildmatch tests'\n>   \n>   . ./test-lib.sh\n>   \n> +create_test_file() {\n> +\tfile=$1\n> +\n> +\t# `touch .` will succeed but obviously not do what we intend\n> +\t# here.\n> +\ttest \"$file\" = \".\" && return 1\n> +\t# We cannot create a file with an empty filename.\n> +\ttest \"$file\" = \"\" && return 1\n> +\t# The tests that are testing that e.g. foo//bar is matched by\n> +\t# foo/*/bar can't be tested on filesystems since there's no\n> +\t# way we're getting a double slash.\n> +\techo \"$file\" | grep -q -F '//' && return 1\n> +\t# When testing the difference between foo/bar and foo/bar/ we\n> +\t# can't test the latter.\n> +\techo \"$file\" | grep -q -E '/$' && return 1\n> +\n> +\tdirs=$(echo \"$file\" | sed -r 's!/[^/]+$!!')\n\nBooh! Booh! So many fork()s! ;)\n\n\tcase \"$file\" in\n\t*//*)\n\t\t# The tests that are testing that e.g. foo//bar is matched by\n\t\t# foo/*/bar can't be tested on filesystems since there's no\n\t\t# way we're getting a double slash.\n\t\treturn 1;;\n\t*/)\n\t\t# When testing the difference between foo/bar and foo/bar/ we\n\t\t# can't test the latter.\n\t\treturn 1;;\n\tesac\n\n\tdirs=${file%/*}\n\n> +\n> +\t# We touch \"./$file\" instead of \"$file\" because even an\n> +\t# escaped \"touch -- -\" means something different.\n> +\tif test \"$file\" != \"$dirs\"\n> +\tthen\n> +\t\tmkdir -p -- \"$dirs\" 2>/dev/null &&\n> +\t\ttouch -- \"./$file\" 2>/dev/null &&\n> +\t\treturn 0\n> +\telse\n> +\t\ttouch -- \"./$file\" 2>/dev/null &&\n> +\t\treturn 0\n> +\tfi\n> +\treturn 1\n> +}\n> +\n>   wildtest() {\n> -\tmatch_w_glob=$1\n> -\tmatch_w_globi=$2\n> -\tmatch_w_pathmatch=$3\n> -\tmatch_w_pathmatchi=$4\n> -\ttext=$5\n> -\tpattern=$6\n> +\tif test \"$#\" = 6\n> +\tthen\n> +\t\t# When test-wildmatch and git ls-files produce the same\n> +\t\t# result.\n> +\t\tmatch_w_glob=$1\n> +\t\tmatch_f_w_glob=$match_w_glob\n> +\t\tmatch_w_globi=$2\n> +\t\tmatch_f_w_globi=$match_w_globi\n> +\t\tmatch_w_pathmatch=$3\n> +\t\tmatch_f_w_pathmatch=$match_w_pathmatch\n> +\t\tmatch_w_pathmatchi=$4\n> +\t\tmatch_f_w_pathmatchi=$match_w_pathmatchi\n> +\t\ttext=$5\n> +\t\tpattern=$6\n> +\telif test \"$#\" = 10\n> +\tthen\n> +\t\tmatch_w_glob=$1\n> +\t\tmatch_w_globi=$2\n> +\t\tmatch_w_pathmatch=$3\n> +\t\tmatch_w_pathmatchi=$4\n> +\t\tmatch_f_w_glob=$5\n> +\t\tmatch_f_w_globi=$6\n> +\t\tmatch_f_w_pathmatch=$7\n> +\t\tmatch_f_w_pathmatchi=$8\n> +\t\ttext=$9\n> +\t\tpattern=$10\n> +\tfi\n>   \n> +\t# $1: Case sensitive glob match: test-wildmatch\n>   \tif test \"$match_w_glob\" = 1\n>   \tthen\n> -\t\ttest_expect_success \"wildmatch:     match '$text' '$pattern'\" \"\n> +\t\ttest_expect_success \"wildmatch: match '$text' '$pattern'\" \"\n>   \t\t\ttest-wildmatch wildmatch '$text' '$pattern'\n>   \t\t\"\n>   \telif test \"$match_w_glob\" = 0\n>   \tthen\n> -\t\ttest_expect_success \"wildmatch:  no match '$text' '$pattern'\" \"\n> +\t\ttest_expect_success \"wildmatch: no match '$text' '$pattern'\" \"\n>   \t\t\t! test-wildmatch wildmatch '$text' '$pattern'\n>   \t\t\"\n>   \telse\n>   \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_glob\" 'false'\n\nI think you can write this as 'say ...; exit 1'. See t0000*.\n\n>   \tfi\n>   \n> +\t# $1: Case sensitive glob match: ls-files\n> +\tif test \"$match_f_w_glob\" = 'E'\n> +\tthen\n> +\t\tif create_test_file \"$text\"\n> +\t\tthen\n> +\t\t\ttest_expect_success \"wildmatch(ls): match dies on '$pattern' '$text'\" \"\n> +\t\t\t\ttest_when_finished \\\"\n> +\t\t\t\t\trm -rf -- * &&\n\nCan we be a bit more careful with this rm -rf, please?\nThere is only one similarly loose case in t/t7003-filter-branch.sh,\nand it is outside test_when_finished, i.e., it is well under control;\nthis instance here inside test_when_finished is not.\n\n> +\t\t\t\t\tgit reset\n> +\t\t\t\t\\\" &&\n> +\t\t\t\tgit add -A &&\n> +\t\t\t\t>expect.err &&\n> +\t\t\t\tprintf '%s' '$text' >expect &&\n> +\t\t\t\ttest_must_fail git --glob-pathspecs ls-files -z -- '$pattern'\n> +\t\t\t\"\n> +\t\telse\n> +\t\t\ttest_expect_failure \"wildmatch(ls): match skip '$pattern' '$text'\" 'false'\n> +\t\tfi\n> +\telif test \"$match_f_w_glob\" = 1\n> +\tthen\n> +\t\tif create_test_file \"$text\"\n> +\t\tthen\n> +\t\t\ttest_expect_success \"wildmatch(ls): match '$pattern' '$text'\" \"\n> +\t\t\t\ttest_when_finished \\\"\n> +\t\t\t\t\trm -rf -- * &&\n> +\t\t\t\t\tgit reset\n> +\t\t\t\t\\\" &&\n> +\t\t\t\tgit add -A &&\n> +\t\t\t\t>expect.err &&\n> +\t\t\t\tprintf '%s' '$text' >expect &&\n\nThere are no single-quotes in any $text instances, right?\n\n> +\t\t\t\tgit --glob-pathspecs ls-files -z -- '$pattern' 2>actual.err | tr -d '\\0' >actual &&\n\nIf possible, do not put git commands in the upstream of a pipe.\nIt does not detect failures.\n\nUnfortunately, printf '%s\\0' foo is not portable. If it were,\nyou could omit the tr invocation alltogether.\n\n> +\t\t\t\ttest_cmp expect.err actual.err &&\n> +\t\t\t\ttest_cmp expect actual\n> +\t\t\t\"\n> +\t\telse\n> +\t\t\ttest_expect_failure \"wildmatch(ls): match skip '$pattern' '$text'\" 'false'\n> +\t\tfi\n\n-- Hannes\n"},{"id":"335252","messageId":"874logs7vi.fsf@evledraar.gmail.com","threadId":"47493","inReplyTo":"8f4cdb23-8e2e-144a-1f70-99776b027166@kdbg.org","subject":"Re: [PATCH 6/6] wildmatch test: create & test files on disk in addition to in-memory","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-24T11:06:09Z","receivedAt":"2017-12-24T11:06:18Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Sun, Dec 24 2017, Johannes Sixt jotted:\n\n> Am 23.12.2017 um 22:30 schrieb Ævar Arnfjörð Bjarmason:\n>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>> ---\n>>   a[]b                 |   0\n>>   t/t3070-wildmatch.sh | 336 ++++++++++++++++++++++++++++++++++++++++++++++++---\n>>   2 files changed, 319 insertions(+), 17 deletions(-)\n>>   create mode 100644 a[]b\n>>\n>> diff --git a/a[]b b/a[]b\n>> new file mode 100644\n>> index 0000000000..e69de29bb2\n>\n> A big no-no! This file can't be created on Windows!\n\nUrgh, that was a mistake of mine. Will be gone in v2.\n\n>> diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\n>> index 47b479e423..d423bb01f3 100755\n>> --- a/t/t3070-wildmatch.sh\n>> +++ b/t/t3070-wildmatch.sh\n>> @@ -4,31 +4,146 @@ test_description='wildmatch tests'\n>>\n>>   . ./test-lib.sh\n>>\n>> +create_test_file() {\n>> +\tfile=$1\n>> +\n>> +\t# `touch .` will succeed but obviously not do what we intend\n>> +\t# here.\n>> +\ttest \"$file\" = \".\" && return 1\n>> +\t# We cannot create a file with an empty filename.\n>> +\ttest \"$file\" = \"\" && return 1\n>> +\t# The tests that are testing that e.g. foo//bar is matched by\n>> +\t# foo/*/bar can't be tested on filesystems since there's no\n>> +\t# way we're getting a double slash.\n>> +\techo \"$file\" | grep -q -F '//' && return 1\n>> +\t# When testing the difference between foo/bar and foo/bar/ we\n>> +\t# can't test the latter.\n>> +\techo \"$file\" | grep -q -E '/$' && return 1\n>> +\n>> +\tdirs=$(echo \"$file\" | sed -r 's!/[^/]+$!!')\n>\n> Booh! Booh! So many fork()s! ;)\n>\n> \tcase \"$file\" in\n> \t*//*)\n> \t\t# The tests that are testing that e.g. foo//bar is matched by\n> \t\t# foo/*/bar can't be tested on filesystems since there's no\n> \t\t# way we're getting a double slash.\n> \t\treturn 1;;\n> \t*/)\n> \t\t# When testing the difference between foo/bar and foo/bar/ we\n> \t\t# can't test the latter.\n> \t\treturn 1;;\n> \tesac\n>\n> \tdirs=${file%/*}\n\nThanks. Will fix.\n\n>> +\n>> +\t# We touch \"./$file\" instead of \"$file\" because even an\n>> +\t# escaped \"touch -- -\" means something different.\n>> +\tif test \"$file\" != \"$dirs\"\n>> +\tthen\n>> +\t\tmkdir -p -- \"$dirs\" 2>/dev/null &&\n>> +\t\ttouch -- \"./$file\" 2>/dev/null &&\n>> +\t\treturn 0\n>> +\telse\n>> +\t\ttouch -- \"./$file\" 2>/dev/null &&\n>> +\t\treturn 0\n>> +\tfi\n>> +\treturn 1\n>> +}\n>> +\n>>   wildtest() {\n>> -\tmatch_w_glob=$1\n>> -\tmatch_w_globi=$2\n>> -\tmatch_w_pathmatch=$3\n>> -\tmatch_w_pathmatchi=$4\n>> -\ttext=$5\n>> -\tpattern=$6\n>> +\tif test \"$#\" = 6\n>> +\tthen\n>> +\t\t# When test-wildmatch and git ls-files produce the same\n>> +\t\t# result.\n>> +\t\tmatch_w_glob=$1\n>> +\t\tmatch_f_w_glob=$match_w_glob\n>> +\t\tmatch_w_globi=$2\n>> +\t\tmatch_f_w_globi=$match_w_globi\n>> +\t\tmatch_w_pathmatch=$3\n>> +\t\tmatch_f_w_pathmatch=$match_w_pathmatch\n>> +\t\tmatch_w_pathmatchi=$4\n>> +\t\tmatch_f_w_pathmatchi=$match_w_pathmatchi\n>> +\t\ttext=$5\n>> +\t\tpattern=$6\n>> +\telif test \"$#\" = 10\n>> +\tthen\n>> +\t\tmatch_w_glob=$1\n>> +\t\tmatch_w_globi=$2\n>> +\t\tmatch_w_pathmatch=$3\n>> +\t\tmatch_w_pathmatchi=$4\n>> +\t\tmatch_f_w_glob=$5\n>> +\t\tmatch_f_w_globi=$6\n>> +\t\tmatch_f_w_pathmatch=$7\n>> +\t\tmatch_f_w_pathmatchi=$8\n>> +\t\ttext=$9\n>> +\t\tpattern=$10\n>> +\tfi\n>>\n>> +\t# $1: Case sensitive glob match: test-wildmatch\n>>   \tif test \"$match_w_glob\" = 1\n>>   \tthen\n>> -\t\ttest_expect_success \"wildmatch:     match '$text' '$pattern'\" \"\n>> +\t\ttest_expect_success \"wildmatch: match '$text' '$pattern'\" \"\n>>   \t\t\ttest-wildmatch wildmatch '$text' '$pattern'\n>>   \t\t\"\n>>   \telif test \"$match_w_glob\" = 0\n>>   \tthen\n>> -\t\ttest_expect_success \"wildmatch:  no match '$text' '$pattern'\" \"\n>> +\t\ttest_expect_success \"wildmatch: no match '$text' '$pattern'\" \"\n>>   \t\t\t! test-wildmatch wildmatch '$text' '$pattern'\n>>   \t\t\"\n>>   \telse\n>>   \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_glob\" 'false'\n>\n> I think you can write this as 'say ...; exit 1'. See t0000*.\n\nThanks. Didn't see an existing idiom for this, will use that.\n\n>>   \tfi\n>>\n>> +\t# $1: Case sensitive glob match: ls-files\n>> +\tif test \"$match_f_w_glob\" = 'E'\n>> +\tthen\n>> +\t\tif create_test_file \"$text\"\n>> +\t\tthen\n>> +\t\t\ttest_expect_success \"wildmatch(ls): match dies on '$pattern' '$text'\" \"\n>> +\t\t\t\ttest_when_finished \\\"\n>> +\t\t\t\t\trm -rf -- * &&\n>\n> Can we be a bit more careful with this rm -rf, please?\n> There is only one similarly loose case in t/t7003-filter-branch.sh,\n> and it is outside test_when_finished, i.e., it is well under control;\n> this instance here inside test_when_finished is not.\n\nI can create the files inside some subfolder, cd to that and then run\nthe ls-files there. It would also cover cases where we have pattern\nmatching text that starts with \".\".\n\n>> +\t\t\t\t\tgit reset\n>> +\t\t\t\t\\\" &&\n>> +\t\t\t\tgit add -A &&\n>> +\t\t\t\t>expect.err &&\n>> +\t\t\t\tprintf '%s' '$text' >expect &&\n>> +\t\t\t\ttest_must_fail git --glob-pathspecs ls-files -z -- '$pattern'\n>> +\t\t\t\"\n>> +\t\telse\n>> +\t\t\ttest_expect_failure \"wildmatch(ls): match skip '$pattern' '$text'\" 'false'\n>> +\t\tfi\n>> +\telif test \"$match_f_w_glob\" = 1\n>> +\tthen\n>> +\t\tif create_test_file \"$text\"\n>> +\t\tthen\n>> +\t\t\ttest_expect_success \"wildmatch(ls): match '$pattern' '$text'\" \"\n>> +\t\t\t\ttest_when_finished \\\"\n>> +\t\t\t\t\trm -rf -- * &&\n>> +\t\t\t\t\tgit reset\n>> +\t\t\t\t\\\" &&\n>> +\t\t\t\tgit add -A &&\n>> +\t\t\t\t>expect.err &&\n>> +\t\t\t\tprintf '%s' '$text' >expect &&\n>\n> There are no single-quotes in any $text instances, right?\n\nThere's not, but maybe we should be more careful here and use here-docs.\n\n>> +\t\t\t\tgit --glob-pathspecs ls-files -z -- '$pattern' 2>actual.err | tr -d '\\0' >actual &&\n>\n> If possible, do not put git commands in the upstream of a pipe.\n> It does not detect failures.\n\nThanks, will split these up.\n\n> Unfortunately, printf '%s\\0' foo is not portable. If it were,\n> you could omit the tr invocation alltogether.\n>\n>> +\t\t\t\ttest_cmp expect.err actual.err &&\n>> +\t\t\t\ttest_cmp expect actual\n>> +\t\t\t\"\n>> +\t\telse\n>> +\t\t\ttest_expect_failure \"wildmatch(ls): match skip '$pattern' '$text'\" 'false'\n>> +\t\tfi\n>\n> -- Hannes\n"},{"id":"335253","messageId":"9191ea80-2faf-b0d1-35c8-6e28e7b8324e@kdbg.org","threadId":"47493","inReplyTo":"874logs7vi.fsf@evledraar.gmail.com","subject":"Re: [PATCH 6/6] wildmatch test: create & test files on disk in addition to in-memory","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2017-12-24T11:51:12Z","receivedAt":"2017-12-24T11:51:18Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 24.12.2017 um 12:06 schrieb Ævar Arnfjörð Bjarmason:\n> On Sun, Dec 24 2017, Johannes Sixt jotted:\n>> Am 23.12.2017 um 22:30 schrieb Ævar Arnfjörð Bjarmason:\n>>> +\t\t\t\tprintf '%s' '$text' >expect &&\n>>\n>> There are no single-quotes in any $text instances, right?\n> \n> There's not, but maybe we should be more careful here and use here-docs.\n\nUnless it is essential to test the single-quote case, we need not \ncomplicate the code. I just wanted to rise awareness. If a problematic \ntest case is introduced, it will be noticed soon enough. It's not that \nwe deal with unknown input here.\n\n-- Hannes\n"},{"id":"335267","messageId":"20171225002835.29005-1-avarab@gmail.com","threadId":"47493","inReplyTo":"20171223213012.1962-1-avarab@gmail.com","subject":"[PATCH v2 0/7] increase wildmatch test coverage","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-25T00:28:28Z","receivedAt":"2017-12-25T00:28:59Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This v2 addresses comments by Johannes Sixt in\n<8f4cdb23-8e2e-144a-1f70-99776b027166@kdbg.org> and there's osme other\ncleanups as noted below.\n\nÆvar Arnfjörð Bjarmason (7):\n  wildmatch test: indent with tabs, not spaces\n  wildmatch test: use more standard shell style\n\nNo changes.\n\n  wildmatch test: don't try to vertically align our output\n\nNEW: Don't try to do whitespace alignment in the tests.\n\n  wildmatch test: use a paranoia pattern from nul_match()\n\nExplain in the commit message why we're not using say '...'; exit 1. I\nsaid I'd use this in <874logs7vi.fsf@evledraar.gmail.com>, but on\nfurther consideration it's a bad idea.\n\n  wildmatch test: remove dead fnmatch() test code\n  wildmatch test: perform all tests under all wildmatch() modes\n\nJust changes to rebase them on the changes above.\n\n  wildmatch test: create & test files on disk in addition to in-memory\n\nAvoid some forking by using a case statement instead of if .. grep &&\nreturn.\n\nAdd comments to the code to clarify what it's doing.\n\nFactoro out the repetitive part of the tests into functions, making\nthe patch shorter.\n\nI didn't change the \"rm -rf -- *\" pattern Johannes was concerned\nabout, because after looking at it it would be a pain to create\nsome-test-subdir/ and only if some-test-subdir/$our_file gets created\ncd to it and then remove it afterwards, it's much easier not to change\nthe directory. The test test_when_finished always runs in the\ndirectory the tests executed in, so I don't see how this is dangerous\nin practice.\n\nI didn't move the \"printf\" pattern to here-docs as discussed in the\nthread.\n\n t/helper/test-wildmatch.c |   2 +\n t/t3070-wildmatch.sh      | 759 +++++++++++++++++++++++++++++++---------------\n 2 files changed, 516 insertions(+), 245 deletions(-)\n\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335268","messageId":"20171225002835.29005-2-avarab@gmail.com","threadId":"47493","inReplyTo":"20171225002835.29005-1-avarab@gmail.com","subject":"[PATCH v2 1/7] wildmatch test: indent with tabs, not spaces","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-25T00:28:29Z","receivedAt":"2017-12-25T00:29:05Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Replace the 4-width mixed space & tab indentation in this file with\nindentation with tabs as we do in most of the rest of our tests.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 54 ++++++++++++++++++++++++++--------------------------\n 1 file changed, 27 insertions(+), 27 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 163a14a1c2..27fa878f6e 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -5,39 +5,39 @@ test_description='wildmatch tests'\n . ./test-lib.sh\n \n match() {\n-    if [ $1 = 1 ]; then\n-\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n-\t    test-wildmatch wildmatch '$3' '$4'\n-\t\"\n-    else\n-\ttest_expect_success \"wildmatch:  no match '$3' '$4'\" \"\n-\t    ! test-wildmatch wildmatch '$3' '$4'\n-\t\"\n-    fi\n+\tif [ $1 = 1 ]; then\n+\t\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n+\t\t\ttest-wildmatch wildmatch '$3' '$4'\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"wildmatch:  no match '$3' '$4'\" \"\n+\t\t\t! test-wildmatch wildmatch '$3' '$4'\n+\t\t\"\n+\tfi\n }\n \n imatch() {\n-    if [ $1 = 1 ]; then\n-\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n-\t    test-wildmatch iwildmatch '$2' '$3'\n-\t\"\n-    else\n-\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n-\t    ! test-wildmatch iwildmatch '$2' '$3'\n-\t\"\n-    fi\n+\tif [ $1 = 1 ]; then\n+\t\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n+\t\t\ttest-wildmatch iwildmatch '$2' '$3'\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n+\t\t\t! test-wildmatch iwildmatch '$2' '$3'\n+\t\t\"\n+\tfi\n }\n \n pathmatch() {\n-    if [ $1 = 1 ]; then\n-\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n-\t    test-wildmatch pathmatch '$2' '$3'\n-\t\"\n-    else\n-\ttest_expect_success \"pathmatch:  no match '$2' '$3'\" \"\n-\t    ! test-wildmatch pathmatch '$2' '$3'\n-\t\"\n-    fi\n+\tif [ $1 = 1 ]; then\n+\t\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n+\t\t\ttest-wildmatch pathmatch '$2' '$3'\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"pathmatch:  no match '$2' '$3'\" \"\n+\t\t\t! test-wildmatch pathmatch '$2' '$3'\n+\t\t\"\n+\tfi\n }\n \n # Basic wildmat features\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335269","messageId":"20171225002835.29005-3-avarab@gmail.com","threadId":"47493","inReplyTo":"20171225002835.29005-1-avarab@gmail.com","subject":"[PATCH v2 2/7] wildmatch test: use more standard shell style","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-25T00:28:30Z","receivedAt":"2017-12-25T00:29:06Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the wildmatch test to use more standard shell style, usually we\nuse \"if test\" not \"if [\".\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 9 ++++++---\n 1 file changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 27fa878f6e..4d589d1f9a 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -5,7 +5,8 @@ test_description='wildmatch tests'\n . ./test-lib.sh\n \n match() {\n-\tif [ $1 = 1 ]; then\n+\tif test \"$1\" = 1\n+\tthen\n \t\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n \t\t\ttest-wildmatch wildmatch '$3' '$4'\n \t\t\"\n@@ -17,7 +18,8 @@ match() {\n }\n \n imatch() {\n-\tif [ $1 = 1 ]; then\n+\tif test \"$1\" = 1\n+\tthen\n \t\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n \t\t\ttest-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n@@ -29,7 +31,8 @@ imatch() {\n }\n \n pathmatch() {\n-\tif [ $1 = 1 ]; then\n+\tif test \"$1\" = 1\n+\tthen\n \t\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n \t\t\ttest-wildmatch pathmatch '$2' '$3'\n \t\t\"\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335270","messageId":"20171225002835.29005-4-avarab@gmail.com","threadId":"47493","inReplyTo":"20171225002835.29005-1-avarab@gmail.com","subject":"[PATCH v2 3/7] wildmatch test: don't try to vertically align our output","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-25T00:28:31Z","receivedAt":"2017-12-25T00:29:11Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Don't try to vertically align the test output, which is futile anyway\nunder the TAP output where we're going to be emitting a number for\neach test without aligning the test count.\n\nThis makes subsequent changes of mine where I'm not going to be\naligning this output as I add new tests easier.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 4d589d1f9a..19ea64bba9 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -7,11 +7,11 @@ test_description='wildmatch tests'\n match() {\n \tif test \"$1\" = 1\n \tthen\n-\t\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n+\t\ttest_expect_success \"wildmatch: match '$3' '$4'\" \"\n \t\t\ttest-wildmatch wildmatch '$3' '$4'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"wildmatch:  no match '$3' '$4'\" \"\n+\t\ttest_expect_success \"wildmatch: no match '$3' '$4'\" \"\n \t\t\t! test-wildmatch wildmatch '$3' '$4'\n \t\t\"\n \tfi\n@@ -20,7 +20,7 @@ match() {\n imatch() {\n \tif test \"$1\" = 1\n \tthen\n-\t\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n+\t\ttest_expect_success \"iwildmatch: match '$2' '$3'\" \"\n \t\t\ttest-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n \telse\n@@ -33,11 +33,11 @@ imatch() {\n pathmatch() {\n \tif test \"$1\" = 1\n \tthen\n-\t\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n+\t\ttest_expect_success \"pathmatch: match '$2' '$3'\" \"\n \t\t\ttest-wildmatch pathmatch '$2' '$3'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"pathmatch:  no match '$2' '$3'\" \"\n+\t\ttest_expect_success \"pathmatch: no match '$2' '$3'\" \"\n \t\t\t! test-wildmatch pathmatch '$2' '$3'\n \t\t\"\n \tfi\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335271","messageId":"20171225002835.29005-5-avarab@gmail.com","threadId":"47493","inReplyTo":"20171225002835.29005-1-avarab@gmail.com","subject":"[PATCH v2 4/7] wildmatch test: use a paranoia pattern from nul_match()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-25T00:28:32Z","receivedAt":"2017-12-25T00:29:12Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Use a pattern from the nul_match() function in t7008-grep-binary.sh to\nmake sure that we don't just fall through to the \"else\" if there's an\nunknown parameter.\n\nThis is something I added in commit 77f6f4406f (\"grep: add a test\nhelper function for less verbose -f \\0 tests\", 2017-05-20) to grep\ntests, which were modeled on these wildmatch tests, and I'm now\nporting back to the original wildmatch tests.\n\nI am not using the \"say '...'; exit 1\" pattern from t0000-basic.sh\nbecause if I fail I want to run the rest of the tests (unless under\n-i), and doing this makes sure we do that and don't exit right away\nwithout fully reporting our errors.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 15 ++++++++++++---\n 1 file changed, 12 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 19ea64bba9..9691d8eda3 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -10,10 +10,13 @@ match() {\n \t\ttest_expect_success \"wildmatch: match '$3' '$4'\" \"\n \t\t\ttest-wildmatch wildmatch '$3' '$4'\n \t\t\"\n-\telse\n+\telif test \"$1\" = 0\n+\tthen\n \t\ttest_expect_success \"wildmatch: no match '$3' '$4'\" \"\n \t\t\t! test-wildmatch wildmatch '$3' '$4'\n \t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n \tfi\n }\n \n@@ -23,10 +26,13 @@ imatch() {\n \t\ttest_expect_success \"iwildmatch: match '$2' '$3'\" \"\n \t\t\ttest-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n-\telse\n+\telif test \"$1\" = 0\n+\tthen\n \t\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n \t\t\t! test-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n \tfi\n }\n \n@@ -36,10 +42,13 @@ pathmatch() {\n \t\ttest_expect_success \"pathmatch: match '$2' '$3'\" \"\n \t\t\ttest-wildmatch pathmatch '$2' '$3'\n \t\t\"\n-\telse\n+\telif test \"$1\" = 0\n+\tthen\n \t\ttest_expect_success \"pathmatch: no match '$2' '$3'\" \"\n \t\t\t! test-wildmatch pathmatch '$2' '$3'\n \t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n \tfi\n }\n \n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335272","messageId":"20171225002835.29005-6-avarab@gmail.com","threadId":"47493","inReplyTo":"20171225002835.29005-1-avarab@gmail.com","subject":"[PATCH v2 5/7] wildmatch test: remove dead fnmatch() test code","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-25T00:28:33Z","receivedAt":"2017-12-25T00:29:15Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the unused fnmatch() test parameter from the wildmatch\ntest. The code that used to test this was removed in 70a8fc999d (\"stop\nusing fnmatch (either native or compat)\", 2014-02-15).\n\nAs a --word-diff shows the only change to the body of the tests is the\nremoval of the second out of four parameters passed to match().\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 356 +++++++++++++++++++++++++--------------------------\n 1 file changed, 178 insertions(+), 178 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 9691d8eda3..2f8a681c72 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -7,13 +7,13 @@ test_description='wildmatch tests'\n match() {\n \tif test \"$1\" = 1\n \tthen\n-\t\ttest_expect_success \"wildmatch: match '$3' '$4'\" \"\n-\t\t\ttest-wildmatch wildmatch '$3' '$4'\n+\t\ttest_expect_success \"wildmatch: match '$2' '$3'\" \"\n+\t\t\ttest-wildmatch wildmatch '$2' '$3'\n \t\t\"\n \telif test \"$1\" = 0\n \tthen\n-\t\ttest_expect_success \"wildmatch: no match '$3' '$4'\" \"\n-\t\t\t! test-wildmatch wildmatch '$3' '$4'\n+\t\ttest_expect_success \"wildmatch: no match '$2' '$3'\" \"\n+\t\t\t! test-wildmatch wildmatch '$2' '$3'\n \t\t\"\n \telse\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n@@ -53,176 +53,176 @@ pathmatch() {\n }\n \n # Basic wildmat features\n-match 1 1 foo foo\n-match 0 0 foo bar\n-match 1 1 '' \"\"\n-match 1 1 foo '???'\n-match 0 0 foo '??'\n-match 1 1 foo '*'\n-match 1 1 foo 'f*'\n-match 0 0 foo '*f'\n-match 1 1 foo '*foo*'\n-match 1 1 foobar '*ob*a*r*'\n-match 1 1 aaaaaaabababab '*ab'\n-match 1 1 'foo*' 'foo\\*'\n-match 0 0 foobar 'foo\\*bar'\n-match 1 1 'f\\oo' 'f\\\\oo'\n-match 1 1 ball '*[al]?'\n-match 0 0 ten '[ten]'\n-match 0 1 ten '**[!te]'\n-match 0 0 ten '**[!ten]'\n-match 1 1 ten 't[a-g]n'\n-match 0 0 ten 't[!a-g]n'\n-match 1 1 ton 't[!a-g]n'\n-match 1 1 ton 't[^a-g]n'\n-match 1 x 'a]b' 'a[]]b'\n-match 1 x a-b 'a[]-]b'\n-match 1 x 'a]b' 'a[]-]b'\n-match 0 x aab 'a[]-]b'\n-match 1 x aab 'a[]a-]b'\n-match 1 1 ']' ']'\n+match 1 foo foo\n+match 0 foo bar\n+match 1 '' \"\"\n+match 1 foo '???'\n+match 0 foo '??'\n+match 1 foo '*'\n+match 1 foo 'f*'\n+match 0 foo '*f'\n+match 1 foo '*foo*'\n+match 1 foobar '*ob*a*r*'\n+match 1 aaaaaaabababab '*ab'\n+match 1 'foo*' 'foo\\*'\n+match 0 foobar 'foo\\*bar'\n+match 1 'f\\oo' 'f\\\\oo'\n+match 1 ball '*[al]?'\n+match 0 ten '[ten]'\n+match 0 ten '**[!te]'\n+match 0 ten '**[!ten]'\n+match 1 ten 't[a-g]n'\n+match 0 ten 't[!a-g]n'\n+match 1 ton 't[!a-g]n'\n+match 1 ton 't[^a-g]n'\n+match 1 'a]b' 'a[]]b'\n+match 1 a-b 'a[]-]b'\n+match 1 'a]b' 'a[]-]b'\n+match 0 aab 'a[]-]b'\n+match 1 aab 'a[]a-]b'\n+match 1 ']' ']'\n \n # Extended slash-matching features\n-match 0 0 'foo/baz/bar' 'foo*bar'\n-match 0 0 'foo/baz/bar' 'foo**bar'\n-match 0 1 'foobazbar' 'foo**bar'\n-match 1 1 'foo/baz/bar' 'foo/**/bar'\n-match 1 0 'foo/baz/bar' 'foo/**/**/bar'\n-match 1 0 'foo/b/a/z/bar' 'foo/**/bar'\n-match 1 0 'foo/b/a/z/bar' 'foo/**/**/bar'\n-match 1 0 'foo/bar' 'foo/**/bar'\n-match 1 0 'foo/bar' 'foo/**/**/bar'\n-match 0 0 'foo/bar' 'foo?bar'\n-match 0 0 'foo/bar' 'foo[/]bar'\n-match 0 0 'foo/bar' 'foo[^a-z]bar'\n-match 0 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 0 'foo' '**/foo'\n-match 1 x 'XXX/foo' '**/foo'\n-match 1 0 'bar/baz/foo' '**/foo'\n-match 0 0 'bar/baz/foo' '*/foo'\n-match 0 0 'foo/bar/baz' '**/bar*'\n-match 1 0 'deep/foo/bar/baz' '**/bar/*'\n-match 0 0 'deep/foo/bar/baz/' '**/bar/*'\n-match 1 0 'deep/foo/bar/baz/' '**/bar/**'\n-match 0 0 'deep/foo/bar' '**/bar/*'\n-match 1 0 'deep/foo/bar/' '**/bar/**'\n-match 0 0 'foo/bar/baz' '**/bar**'\n-match 1 0 'foo/bar/baz/x' '*/bar/**'\n-match 0 0 'deep/foo/bar/baz/x' '*/bar/**'\n-match 1 0 'deep/foo/bar/baz/x' '**/bar/*/*'\n+match 0 'foo/baz/bar' 'foo*bar'\n+match 0 'foo/baz/bar' 'foo**bar'\n+match 0 'foobazbar' 'foo**bar'\n+match 1 'foo/baz/bar' 'foo/**/bar'\n+match 1 'foo/baz/bar' 'foo/**/**/bar'\n+match 1 'foo/b/a/z/bar' 'foo/**/bar'\n+match 1 'foo/b/a/z/bar' 'foo/**/**/bar'\n+match 1 'foo/bar' 'foo/**/bar'\n+match 1 'foo/bar' 'foo/**/**/bar'\n+match 0 'foo/bar' 'foo?bar'\n+match 0 'foo/bar' 'foo[/]bar'\n+match 0 'foo/bar' 'foo[^a-z]bar'\n+match 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+match 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+match 1 'foo' '**/foo'\n+match 1 'XXX/foo' '**/foo'\n+match 1 'bar/baz/foo' '**/foo'\n+match 0 'bar/baz/foo' '*/foo'\n+match 0 'foo/bar/baz' '**/bar*'\n+match 1 'deep/foo/bar/baz' '**/bar/*'\n+match 0 'deep/foo/bar/baz/' '**/bar/*'\n+match 1 'deep/foo/bar/baz/' '**/bar/**'\n+match 0 'deep/foo/bar' '**/bar/*'\n+match 1 'deep/foo/bar/' '**/bar/**'\n+match 0 'foo/bar/baz' '**/bar**'\n+match 1 'foo/bar/baz/x' '*/bar/**'\n+match 0 'deep/foo/bar/baz/x' '*/bar/**'\n+match 1 'deep/foo/bar/baz/x' '**/bar/*/*'\n \n # Various additional tests\n-match 0 0 'acrt' 'a[c-c]st'\n-match 1 1 'acrt' 'a[c-c]rt'\n-match 0 0 ']' '[!]-]'\n-match 1 x 'a' '[!]-]'\n-match 0 0 '' '\\'\n-match 0 x '\\' '\\'\n-match 0 x 'XXX/\\' '*/\\'\n-match 1 x 'XXX/\\' '*/\\\\'\n-match 1 1 'foo' 'foo'\n-match 1 1 '@foo' '@foo'\n-match 0 0 'foo' '@foo'\n-match 1 1 '[ab]' '\\[ab]'\n-match 1 1 '[ab]' '[[]ab]'\n-match 1 x '[ab]' '[[:]ab]'\n-match 0 x '[ab]' '[[::]ab]'\n-match 1 x '[ab]' '[[:digit]ab]'\n-match 1 x '[ab]' '[\\[:]ab]'\n-match 1 1 '?a?b' '\\??\\?b'\n-match 1 1 'abc' '\\a\\b\\c'\n-match 0 0 'foo' ''\n-match 1 0 'foo/bar/baz/to' '**/t[o]'\n+match 0 'acrt' 'a[c-c]st'\n+match 1 'acrt' 'a[c-c]rt'\n+match 0 ']' '[!]-]'\n+match 1 'a' '[!]-]'\n+match 0 '' '\\'\n+match 0 '\\' '\\'\n+match 0 'XXX/\\' '*/\\'\n+match 1 'XXX/\\' '*/\\\\'\n+match 1 'foo' 'foo'\n+match 1 '@foo' '@foo'\n+match 0 'foo' '@foo'\n+match 1 '[ab]' '\\[ab]'\n+match 1 '[ab]' '[[]ab]'\n+match 1 '[ab]' '[[:]ab]'\n+match 0 '[ab]' '[[::]ab]'\n+match 1 '[ab]' '[[:digit]ab]'\n+match 1 '[ab]' '[\\[:]ab]'\n+match 1 '?a?b' '\\??\\?b'\n+match 1 'abc' '\\a\\b\\c'\n+match 0 'foo' ''\n+match 1 'foo/bar/baz/to' '**/t[o]'\n \n # Character class tests\n-match 1 x 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n-match 0 x 'a' '[[:digit:][:upper:][:space:]]'\n-match 1 x 'A' '[[:digit:][:upper:][:space:]]'\n-match 1 x '1' '[[:digit:][:upper:][:space:]]'\n-match 0 x '1' '[[:digit:][:upper:][:spaci:]]'\n-match 1 x ' ' '[[:digit:][:upper:][:space:]]'\n-match 0 x '.' '[[:digit:][:upper:][:space:]]'\n-match 1 x '.' '[[:digit:][:punct:][:space:]]'\n-match 1 x '5' '[[:xdigit:]]'\n-match 1 x 'f' '[[:xdigit:]]'\n-match 1 x 'D' '[[:xdigit:]]'\n-match 1 x '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n-match 1 x '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n-match 1 x '5' '[a-c[:digit:]x-z]'\n-match 1 x 'b' '[a-c[:digit:]x-z]'\n-match 1 x 'y' '[a-c[:digit:]x-z]'\n-match 0 x 'q' '[a-c[:digit:]x-z]'\n+match 1 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n+match 0 'a' '[[:digit:][:upper:][:space:]]'\n+match 1 'A' '[[:digit:][:upper:][:space:]]'\n+match 1 '1' '[[:digit:][:upper:][:space:]]'\n+match 0 '1' '[[:digit:][:upper:][:spaci:]]'\n+match 1 ' ' '[[:digit:][:upper:][:space:]]'\n+match 0 '.' '[[:digit:][:upper:][:space:]]'\n+match 1 '.' '[[:digit:][:punct:][:space:]]'\n+match 1 '5' '[[:xdigit:]]'\n+match 1 'f' '[[:xdigit:]]'\n+match 1 'D' '[[:xdigit:]]'\n+match 1 '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n+match 1 '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n+match 1 '5' '[a-c[:digit:]x-z]'\n+match 1 'b' '[a-c[:digit:]x-z]'\n+match 1 'y' '[a-c[:digit:]x-z]'\n+match 0 'q' '[a-c[:digit:]x-z]'\n \n # Additional tests, including some malformed wildmats\n-match 1 x ']' '[\\\\-^]'\n-match 0 0 '[' '[\\\\-^]'\n-match 1 x '-' '[\\-_]'\n-match 1 x ']' '[\\]]'\n-match 0 0 '\\]' '[\\]]'\n-match 0 0 '\\' '[\\]]'\n-match 0 0 'ab' 'a[]b'\n-match 0 x 'a[]b' 'a[]b'\n-match 0 x 'ab[' 'ab['\n-match 0 0 'ab' '[!'\n-match 0 0 'ab' '[-'\n-match 1 1 '-' '[-]'\n-match 0 0 '-' '[a-'\n-match 0 0 '-' '[!a-'\n-match 1 x '-' '[--A]'\n-match 1 x '5' '[--A]'\n-match 1 1 ' ' '[ --]'\n-match 1 1 '$' '[ --]'\n-match 1 1 '-' '[ --]'\n-match 0 0 '0' '[ --]'\n-match 1 x '-' '[---]'\n-match 1 x '-' '[------]'\n-match 0 0 'j' '[a-e-n]'\n-match 1 x '-' '[a-e-n]'\n-match 1 x 'a' '[!------]'\n-match 0 0 '[' '[]-a]'\n-match 1 x '^' '[]-a]'\n-match 0 0 '^' '[!]-a]'\n-match 1 x '[' '[!]-a]'\n-match 1 1 '^' '[a^bc]'\n-match 1 x '-b]' '[a-]b]'\n-match 0 0 '\\' '[\\]'\n-match 1 1 '\\' '[\\\\]'\n-match 0 0 '\\' '[!\\\\]'\n-match 1 1 'G' '[A-\\\\]'\n-match 0 0 'aaabbb' 'b*a'\n-match 0 0 'aabcaa' '*ba*'\n-match 1 1 ',' '[,]'\n-match 1 1 ',' '[\\\\,]'\n-match 1 1 '\\' '[\\\\,]'\n-match 1 1 '-' '[,-.]'\n-match 0 0 '+' '[,-.]'\n-match 0 0 '-.]' '[,-.]'\n-match 1 1 '2' '[\\1-\\3]'\n-match 1 1 '3' '[\\1-\\3]'\n-match 0 0 '4' '[\\1-\\3]'\n-match 1 1 '\\' '[[-\\]]'\n-match 1 1 '[' '[[-\\]]'\n-match 1 1 ']' '[[-\\]]'\n-match 0 0 '-' '[[-\\]]'\n+match 1 ']' '[\\\\-^]'\n+match 0 '[' '[\\\\-^]'\n+match 1 '-' '[\\-_]'\n+match 1 ']' '[\\]]'\n+match 0 '\\]' '[\\]]'\n+match 0 '\\' '[\\]]'\n+match 0 'ab' 'a[]b'\n+match 0 'a[]b' 'a[]b'\n+match 0 'ab[' 'ab['\n+match 0 'ab' '[!'\n+match 0 'ab' '[-'\n+match 1 '-' '[-]'\n+match 0 '-' '[a-'\n+match 0 '-' '[!a-'\n+match 1 '-' '[--A]'\n+match 1 '5' '[--A]'\n+match 1 ' ' '[ --]'\n+match 1 '$' '[ --]'\n+match 1 '-' '[ --]'\n+match 0 '0' '[ --]'\n+match 1 '-' '[---]'\n+match 1 '-' '[------]'\n+match 0 'j' '[a-e-n]'\n+match 1 '-' '[a-e-n]'\n+match 1 'a' '[!------]'\n+match 0 '[' '[]-a]'\n+match 1 '^' '[]-a]'\n+match 0 '^' '[!]-a]'\n+match 1 '[' '[!]-a]'\n+match 1 '^' '[a^bc]'\n+match 1 '-b]' '[a-]b]'\n+match 0 '\\' '[\\]'\n+match 1 '\\' '[\\\\]'\n+match 0 '\\' '[!\\\\]'\n+match 1 'G' '[A-\\\\]'\n+match 0 'aaabbb' 'b*a'\n+match 0 'aabcaa' '*ba*'\n+match 1 ',' '[,]'\n+match 1 ',' '[\\\\,]'\n+match 1 '\\' '[\\\\,]'\n+match 1 '-' '[,-.]'\n+match 0 '+' '[,-.]'\n+match 0 '-.]' '[,-.]'\n+match 1 '2' '[\\1-\\3]'\n+match 1 '3' '[\\1-\\3]'\n+match 0 '4' '[\\1-\\3]'\n+match 1 '\\' '[[-\\]]'\n+match 1 '[' '[[-\\]]'\n+match 1 ']' '[[-\\]]'\n+match 0 '-' '[[-\\]]'\n \n # Test recursion and the abort code (use \"wildtest -i\" to see iteration counts)\n-match 1 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 1 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n-match 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n-match 0 x foo '*/*/*'\n-match 0 x foo/bar '*/*/*'\n-match 1 x foo/bba/arr '*/*/*'\n-match 0 x foo/bb/aa/rr '*/*/*'\n-match 1 x foo/bb/aa/rr '**/**/**'\n-match 1 x abcXdefXghi '*X*i'\n-match 0 x ab/cXd/efXg/hi '*X*i'\n-match 1 x ab/cXd/efXg/hi '*/*X*/*/*i'\n-match 1 x ab/cXd/efXg/hi '**/*X*/**/*i'\n+match 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+match 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+match 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+match 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+match 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+match 1 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n+match 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n+match 0 foo '*/*/*'\n+match 0 foo/bar '*/*/*'\n+match 1 foo/bba/arr '*/*/*'\n+match 0 foo/bb/aa/rr '*/*/*'\n+match 1 foo/bb/aa/rr '**/**/**'\n+match 1 abcXdefXghi '*X*i'\n+match 0 ab/cXd/efXg/hi '*X*i'\n+match 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n+match 1 ab/cXd/efXg/hi '**/*X*/**/*i'\n \n pathmatch 1 foo foo\n pathmatch 0 foo fo\n@@ -248,20 +248,20 @@ pathmatch 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n pathmatch 1 ab/cXd/efXg/hi '*Xg*i'\n \n # Case-sensitivity features\n-match 0 x 'a' '[A-Z]'\n-match 1 x 'A' '[A-Z]'\n-match 0 x 'A' '[a-z]'\n-match 1 x 'a' '[a-z]'\n-match 0 x 'a' '[[:upper:]]'\n-match 1 x 'A' '[[:upper:]]'\n-match 0 x 'A' '[[:lower:]]'\n-match 1 x 'a' '[[:lower:]]'\n-match 0 x 'A' '[B-Za]'\n-match 1 x 'a' '[B-Za]'\n-match 0 x 'A' '[B-a]'\n-match 1 x 'a' '[B-a]'\n-match 0 x 'z' '[Z-y]'\n-match 1 x 'Z' '[Z-y]'\n+match 0 'a' '[A-Z]'\n+match 1 'A' '[A-Z]'\n+match 0 'A' '[a-z]'\n+match 1 'a' '[a-z]'\n+match 0 'a' '[[:upper:]]'\n+match 1 'A' '[[:upper:]]'\n+match 0 'A' '[[:lower:]]'\n+match 1 'a' '[[:lower:]]'\n+match 0 'A' '[B-Za]'\n+match 1 'a' '[B-Za]'\n+match 0 'A' '[B-a]'\n+match 1 'a' '[B-a]'\n+match 0 'z' '[Z-y]'\n+match 1 'Z' '[Z-y]'\n \n imatch 1 'a' '[A-Z]'\n imatch 1 'A' '[A-Z]'\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335273","messageId":"20171225002835.29005-7-avarab@gmail.com","threadId":"47493","inReplyTo":"20171225002835.29005-1-avarab@gmail.com","subject":"[PATCH v2 6/7] wildmatch test: perform all tests under all wildmatch() modes","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-25T00:28:34Z","receivedAt":"2017-12-25T00:29:19Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Rewrite the wildmatch() test suite so that each test now tests all\ncombinations of the wildmatch() WM_CASEFOLD and WM_PATHNAME flags.\n\nBefore this change some test inputs were not tested on\ne.g. WM_PATHNAME. Now the function is stress tested on all possible\ninputs, and for each input we declare what the result should be if the\nmode is case-insensitive, or pathname matching, or case-sensitive or\nnot matching pathnames.\n\nAlso before this change, nothing was testing case-insensitive\nnon-pathname matching, so I've added that to test-wildmatch.c and made\nuse of it.\n\nThis yields a rather scary patch, but there are no functional changes\nhere, just more test coverage. Some now-redundant tests were deleted\nas a result of this change, since they were now duplicating an earlier\ntest.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/helper/test-wildmatch.c |   2 +\n t/t3070-wildmatch.sh      | 478 +++++++++++++++++++++++-----------------------\n 2 files changed, 239 insertions(+), 241 deletions(-)\n\ndiff --git a/t/helper/test-wildmatch.c b/t/helper/test-wildmatch.c\nindex 921d7b3e7e..66d33dfcfd 100644\n--- a/t/helper/test-wildmatch.c\n+++ b/t/helper/test-wildmatch.c\n@@ -16,6 +16,8 @@ int cmd_main(int argc, const char **argv)\n \t\treturn !!wildmatch(argv[3], argv[2], WM_PATHNAME | WM_CASEFOLD);\n \telse if (!strcmp(argv[1], \"pathmatch\"))\n \t\treturn !!wildmatch(argv[3], argv[2], 0);\n+\telse if (!strcmp(argv[1], \"ipathmatch\"))\n+\t\treturn !!wildmatch(argv[3], argv[2], WM_CASEFOLD);\n \telse\n \t\treturn 1;\n }\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 2f8a681c72..593b25b278 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -4,278 +4,274 @@ test_description='wildmatch tests'\n \n . ./test-lib.sh\n \n-match() {\n-\tif test \"$1\" = 1\n+wildtest() {\n+\tmatch_w_glob=$1\n+\tmatch_w_globi=$2\n+\tmatch_w_pathmatch=$3\n+\tmatch_w_pathmatchi=$4\n+\ttext=$5\n+\tpattern=$6\n+\n+\tif test \"$match_w_glob\" = 1\n \tthen\n-\t\ttest_expect_success \"wildmatch: match '$2' '$3'\" \"\n-\t\t\ttest-wildmatch wildmatch '$2' '$3'\n+\t\ttest_expect_success \"wildmatch: match '$text' '$pattern'\" \"\n+\t\t\ttest-wildmatch wildmatch '$text' '$pattern'\n \t\t\"\n-\telif test \"$1\" = 0\n+\telif test \"$match_w_glob\" = 0\n \tthen\n-\t\ttest_expect_success \"wildmatch: no match '$2' '$3'\" \"\n-\t\t\t! test-wildmatch wildmatch '$2' '$3'\n+\t\ttest_expect_success \"wildmatch: no match '$text' '$pattern'\" \"\n+\t\t\t! test-wildmatch wildmatch '$text' '$pattern'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_glob\" 'false'\n \tfi\n-}\n \n-imatch() {\n-\tif test \"$1\" = 1\n+\tif test \"$match_w_globi\" = 1\n \tthen\n-\t\ttest_expect_success \"iwildmatch: match '$2' '$3'\" \"\n-\t\t\ttest-wildmatch iwildmatch '$2' '$3'\n+\t\ttest_expect_success \"iwildmatch: match '$text' '$pattern'\" \"\n+\t\t\ttest-wildmatch iwildmatch '$text' '$pattern'\n \t\t\"\n-\telif test \"$1\" = 0\n+\telif test \"$match_w_globi\" = 0\n \tthen\n-\t\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n-\t\t\t! test-wildmatch iwildmatch '$2' '$3'\n+\t\ttest_expect_success \"iwildmatch: no match '$text' '$pattern'\" \"\n+\t\t\t! test-wildmatch iwildmatch '$text' '$pattern'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_globi\" 'false'\n \tfi\n-}\n \n-pathmatch() {\n-\tif test \"$1\" = 1\n+\tif test \"$match_w_pathmatch\" = 1\n \tthen\n-\t\ttest_expect_success \"pathmatch: match '$2' '$3'\" \"\n-\t\t\ttest-wildmatch pathmatch '$2' '$3'\n+\t\ttest_expect_success \"pathmatch: match '$text' '$pattern'\" \"\n+\t\t\ttest-wildmatch pathmatch '$text' '$pattern'\n \t\t\"\n-\telif test \"$1\" = 0\n+\telif test \"$match_w_pathmatch\" = 0\n \tthen\n-\t\ttest_expect_success \"pathmatch: no match '$2' '$3'\" \"\n-\t\t\t! test-wildmatch pathmatch '$2' '$3'\n+\t\ttest_expect_success \"pathmatch: no match '$text' '$pattern'\" \"\n+\t\t\t! test-wildmatch pathmatch '$text' '$pattern'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_pathmatch\" 'false'\n+\tfi\n+\n+\tif test \"$match_w_pathmatchi\" = 1\n+\tthen\n+\t\ttest_expect_success \"ipathmatch:    match '$text' '$pattern'\" \"\n+\t\t\ttest-wildmatch ipathmatch '$text' '$pattern'\n+\t\t\"\n+\telif test \"$match_w_pathmatchi\" = 0\n+\tthen\n+\t\ttest_expect_success \"ipathmatch: no match '$text' '$pattern'\" \"\n+\t\t\t! test-wildmatch ipathmatch '$text' '$pattern'\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_pathmatchi\" 'false'\n \tfi\n }\n \n-# Basic wildmat features\n-match 1 foo foo\n-match 0 foo bar\n-match 1 '' \"\"\n-match 1 foo '???'\n-match 0 foo '??'\n-match 1 foo '*'\n-match 1 foo 'f*'\n-match 0 foo '*f'\n-match 1 foo '*foo*'\n-match 1 foobar '*ob*a*r*'\n-match 1 aaaaaaabababab '*ab'\n-match 1 'foo*' 'foo\\*'\n-match 0 foobar 'foo\\*bar'\n-match 1 'f\\oo' 'f\\\\oo'\n-match 1 ball '*[al]?'\n-match 0 ten '[ten]'\n-match 0 ten '**[!te]'\n-match 0 ten '**[!ten]'\n-match 1 ten 't[a-g]n'\n-match 0 ten 't[!a-g]n'\n-match 1 ton 't[!a-g]n'\n-match 1 ton 't[^a-g]n'\n-match 1 'a]b' 'a[]]b'\n-match 1 a-b 'a[]-]b'\n-match 1 'a]b' 'a[]-]b'\n-match 0 aab 'a[]-]b'\n-match 1 aab 'a[]a-]b'\n-match 1 ']' ']'\n+# Basic wildmatch features\n+wildtest 1 1 1 1 foo foo\n+wildtest 0 0 0 0 foo bar\n+wildtest 1 1 1 1 '' \"\"\n+wildtest 1 1 1 1 foo '???'\n+wildtest 0 0 0 0 foo '??'\n+wildtest 1 1 1 1 foo '*'\n+wildtest 1 1 1 1 foo 'f*'\n+wildtest 0 0 0 0 foo '*f'\n+wildtest 1 1 1 1 foo '*foo*'\n+wildtest 1 1 1 1 foobar '*ob*a*r*'\n+wildtest 1 1 1 1 aaaaaaabababab '*ab'\n+wildtest 1 1 1 1 'foo*' 'foo\\*'\n+wildtest 0 0 0 0 foobar 'foo\\*bar'\n+wildtest 1 1 1 1 'f\\oo' 'f\\\\oo'\n+wildtest 1 1 1 1 ball '*[al]?'\n+wildtest 0 0 0 0 ten '[ten]'\n+wildtest 0 0 1 1 ten '**[!te]'\n+wildtest 0 0 0 0 ten '**[!ten]'\n+wildtest 1 1 1 1 ten 't[a-g]n'\n+wildtest 0 0 0 0 ten 't[!a-g]n'\n+wildtest 1 1 1 1 ton 't[!a-g]n'\n+wildtest 1 1 1 1 ton 't[^a-g]n'\n+wildtest 1 1 1 1 'a]b' 'a[]]b'\n+wildtest 1 1 1 1 a-b 'a[]-]b'\n+wildtest 1 1 1 1 'a]b' 'a[]-]b'\n+wildtest 0 0 0 0 aab 'a[]-]b'\n+wildtest 1 1 1 1 aab 'a[]a-]b'\n+wildtest 1 1 1 1 ']' ']'\n \n # Extended slash-matching features\n-match 0 'foo/baz/bar' 'foo*bar'\n-match 0 'foo/baz/bar' 'foo**bar'\n-match 0 'foobazbar' 'foo**bar'\n-match 1 'foo/baz/bar' 'foo/**/bar'\n-match 1 'foo/baz/bar' 'foo/**/**/bar'\n-match 1 'foo/b/a/z/bar' 'foo/**/bar'\n-match 1 'foo/b/a/z/bar' 'foo/**/**/bar'\n-match 1 'foo/bar' 'foo/**/bar'\n-match 1 'foo/bar' 'foo/**/**/bar'\n-match 0 'foo/bar' 'foo?bar'\n-match 0 'foo/bar' 'foo[/]bar'\n-match 0 'foo/bar' 'foo[^a-z]bar'\n-match 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 'foo' '**/foo'\n-match 1 'XXX/foo' '**/foo'\n-match 1 'bar/baz/foo' '**/foo'\n-match 0 'bar/baz/foo' '*/foo'\n-match 0 'foo/bar/baz' '**/bar*'\n-match 1 'deep/foo/bar/baz' '**/bar/*'\n-match 0 'deep/foo/bar/baz/' '**/bar/*'\n-match 1 'deep/foo/bar/baz/' '**/bar/**'\n-match 0 'deep/foo/bar' '**/bar/*'\n-match 1 'deep/foo/bar/' '**/bar/**'\n-match 0 'foo/bar/baz' '**/bar**'\n-match 1 'foo/bar/baz/x' '*/bar/**'\n-match 0 'deep/foo/bar/baz/x' '*/bar/**'\n-match 1 'deep/foo/bar/baz/x' '**/bar/*/*'\n+wildtest 0 0 1 1 'foo/baz/bar' 'foo*bar'\n+wildtest 0 0 1 1 'foo/baz/bar' 'foo**bar'\n+wildtest 0 0 1 1 'foobazbar' 'foo**bar'\n+wildtest 1 1 1 1 'foo/baz/bar' 'foo/**/bar'\n+wildtest 1 1 0 0 'foo/baz/bar' 'foo/**/**/bar'\n+wildtest 1 1 1 1 'foo/b/a/z/bar' 'foo/**/bar'\n+wildtest 1 1 1 1 'foo/b/a/z/bar' 'foo/**/**/bar'\n+wildtest 1 1 0 0 'foo/bar' 'foo/**/bar'\n+wildtest 1 1 0 0 'foo/bar' 'foo/**/**/bar'\n+wildtest 0 0 1 1 'foo/bar' 'foo?bar'\n+wildtest 0 0 1 1 'foo/bar' 'foo[/]bar'\n+wildtest 0 0 1 1 'foo/bar' 'foo[^a-z]bar'\n+wildtest 0 0 1 1 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+wildtest 1 1 1 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+wildtest 1 1 0 0 'foo' '**/foo'\n+wildtest 1 1 1 1 'XXX/foo' '**/foo'\n+wildtest 1 1 1 1 'bar/baz/foo' '**/foo'\n+wildtest 0 0 1 1 'bar/baz/foo' '*/foo'\n+wildtest 0 0 1 1 'foo/bar/baz' '**/bar*'\n+wildtest 1 1 1 1 'deep/foo/bar/baz' '**/bar/*'\n+wildtest 0 0 1 1 'deep/foo/bar/baz/' '**/bar/*'\n+wildtest 1 1 1 1 'deep/foo/bar/baz/' '**/bar/**'\n+wildtest 0 0 0 0 'deep/foo/bar' '**/bar/*'\n+wildtest 1 1 1 1 'deep/foo/bar/' '**/bar/**'\n+wildtest 0 0 1 1 'foo/bar/baz' '**/bar**'\n+wildtest 1 1 1 1 'foo/bar/baz/x' '*/bar/**'\n+wildtest 0 0 1 1 'deep/foo/bar/baz/x' '*/bar/**'\n+wildtest 1 1 1 1 'deep/foo/bar/baz/x' '**/bar/*/*'\n \n # Various additional tests\n-match 0 'acrt' 'a[c-c]st'\n-match 1 'acrt' 'a[c-c]rt'\n-match 0 ']' '[!]-]'\n-match 1 'a' '[!]-]'\n-match 0 '' '\\'\n-match 0 '\\' '\\'\n-match 0 'XXX/\\' '*/\\'\n-match 1 'XXX/\\' '*/\\\\'\n-match 1 'foo' 'foo'\n-match 1 '@foo' '@foo'\n-match 0 'foo' '@foo'\n-match 1 '[ab]' '\\[ab]'\n-match 1 '[ab]' '[[]ab]'\n-match 1 '[ab]' '[[:]ab]'\n-match 0 '[ab]' '[[::]ab]'\n-match 1 '[ab]' '[[:digit]ab]'\n-match 1 '[ab]' '[\\[:]ab]'\n-match 1 '?a?b' '\\??\\?b'\n-match 1 'abc' '\\a\\b\\c'\n-match 0 'foo' ''\n-match 1 'foo/bar/baz/to' '**/t[o]'\n+wildtest 0 0 0 0 'acrt' 'a[c-c]st'\n+wildtest 1 1 1 1 'acrt' 'a[c-c]rt'\n+wildtest 0 0 0 0 ']' '[!]-]'\n+wildtest 1 1 1 1 'a' '[!]-]'\n+wildtest 0 0 0 0 '' '\\'\n+wildtest 0 0 0 0 '\\' '\\'\n+wildtest 0 0 0 0 'XXX/\\' '*/\\'\n+wildtest 1 1 1 1 'XXX/\\' '*/\\\\'\n+wildtest 1 1 1 1 'foo' 'foo'\n+wildtest 1 1 1 1 '@foo' '@foo'\n+wildtest 0 0 0 0 'foo' '@foo'\n+wildtest 1 1 1 1 '[ab]' '\\[ab]'\n+wildtest 1 1 1 1 '[ab]' '[[]ab]'\n+wildtest 1 1 1 1 '[ab]' '[[:]ab]'\n+wildtest 0 0 0 0 '[ab]' '[[::]ab]'\n+wildtest 1 1 1 1 '[ab]' '[[:digit]ab]'\n+wildtest 1 1 1 1 '[ab]' '[\\[:]ab]'\n+wildtest 1 1 1 1 '?a?b' '\\??\\?b'\n+wildtest 1 1 1 1 'abc' '\\a\\b\\c'\n+wildtest 0 0 0 0 'foo' ''\n+wildtest 1 1 1 1 'foo/bar/baz/to' '**/t[o]'\n \n # Character class tests\n-match 1 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n-match 0 'a' '[[:digit:][:upper:][:space:]]'\n-match 1 'A' '[[:digit:][:upper:][:space:]]'\n-match 1 '1' '[[:digit:][:upper:][:space:]]'\n-match 0 '1' '[[:digit:][:upper:][:spaci:]]'\n-match 1 ' ' '[[:digit:][:upper:][:space:]]'\n-match 0 '.' '[[:digit:][:upper:][:space:]]'\n-match 1 '.' '[[:digit:][:punct:][:space:]]'\n-match 1 '5' '[[:xdigit:]]'\n-match 1 'f' '[[:xdigit:]]'\n-match 1 'D' '[[:xdigit:]]'\n-match 1 '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n-match 1 '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n-match 1 '5' '[a-c[:digit:]x-z]'\n-match 1 'b' '[a-c[:digit:]x-z]'\n-match 1 'y' '[a-c[:digit:]x-z]'\n-match 0 'q' '[a-c[:digit:]x-z]'\n-\n-# Additional tests, including some malformed wildmats\n-match 1 ']' '[\\\\-^]'\n-match 0 '[' '[\\\\-^]'\n-match 1 '-' '[\\-_]'\n-match 1 ']' '[\\]]'\n-match 0 '\\]' '[\\]]'\n-match 0 '\\' '[\\]]'\n-match 0 'ab' 'a[]b'\n-match 0 'a[]b' 'a[]b'\n-match 0 'ab[' 'ab['\n-match 0 'ab' '[!'\n-match 0 'ab' '[-'\n-match 1 '-' '[-]'\n-match 0 '-' '[a-'\n-match 0 '-' '[!a-'\n-match 1 '-' '[--A]'\n-match 1 '5' '[--A]'\n-match 1 ' ' '[ --]'\n-match 1 '$' '[ --]'\n-match 1 '-' '[ --]'\n-match 0 '0' '[ --]'\n-match 1 '-' '[---]'\n-match 1 '-' '[------]'\n-match 0 'j' '[a-e-n]'\n-match 1 '-' '[a-e-n]'\n-match 1 'a' '[!------]'\n-match 0 '[' '[]-a]'\n-match 1 '^' '[]-a]'\n-match 0 '^' '[!]-a]'\n-match 1 '[' '[!]-a]'\n-match 1 '^' '[a^bc]'\n-match 1 '-b]' '[a-]b]'\n-match 0 '\\' '[\\]'\n-match 1 '\\' '[\\\\]'\n-match 0 '\\' '[!\\\\]'\n-match 1 'G' '[A-\\\\]'\n-match 0 'aaabbb' 'b*a'\n-match 0 'aabcaa' '*ba*'\n-match 1 ',' '[,]'\n-match 1 ',' '[\\\\,]'\n-match 1 '\\' '[\\\\,]'\n-match 1 '-' '[,-.]'\n-match 0 '+' '[,-.]'\n-match 0 '-.]' '[,-.]'\n-match 1 '2' '[\\1-\\3]'\n-match 1 '3' '[\\1-\\3]'\n-match 0 '4' '[\\1-\\3]'\n-match 1 '\\' '[[-\\]]'\n-match 1 '[' '[[-\\]]'\n-match 1 ']' '[[-\\]]'\n-match 0 '-' '[[-\\]]'\n+wildtest 1 1 1 1 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n+wildtest 0 1 0 1 'a' '[[:digit:][:upper:][:space:]]'\n+wildtest 1 1 1 1 'A' '[[:digit:][:upper:][:space:]]'\n+wildtest 1 1 1 1 '1' '[[:digit:][:upper:][:space:]]'\n+wildtest 0 0 0 0 '1' '[[:digit:][:upper:][:spaci:]]'\n+wildtest 1 1 1 1 ' ' '[[:digit:][:upper:][:space:]]'\n+wildtest 0 0 0 0 '.' '[[:digit:][:upper:][:space:]]'\n+wildtest 1 1 1 1 '.' '[[:digit:][:punct:][:space:]]'\n+wildtest 1 1 1 1 '5' '[[:xdigit:]]'\n+wildtest 1 1 1 1 'f' '[[:xdigit:]]'\n+wildtest 1 1 1 1 'D' '[[:xdigit:]]'\n+wildtest 1 1 1 1 '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n+wildtest 1 1 1 1 '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n+wildtest 1 1 1 1 '5' '[a-c[:digit:]x-z]'\n+wildtest 1 1 1 1 'b' '[a-c[:digit:]x-z]'\n+wildtest 1 1 1 1 'y' '[a-c[:digit:]x-z]'\n+wildtest 0 0 0 0 'q' '[a-c[:digit:]x-z]'\n \n-# Test recursion and the abort code (use \"wildtest -i\" to see iteration counts)\n-match 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 1 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n-match 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n-match 0 foo '*/*/*'\n-match 0 foo/bar '*/*/*'\n-match 1 foo/bba/arr '*/*/*'\n-match 0 foo/bb/aa/rr '*/*/*'\n-match 1 foo/bb/aa/rr '**/**/**'\n-match 1 abcXdefXghi '*X*i'\n-match 0 ab/cXd/efXg/hi '*X*i'\n-match 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n-match 1 ab/cXd/efXg/hi '**/*X*/**/*i'\n+# Additional tests, including some malformed wildmatch patterns\n+wildtest 1 1 1 1 ']' '[\\\\-^]'\n+wildtest 0 0 0 0 '[' '[\\\\-^]'\n+wildtest 1 1 1 1 '-' '[\\-_]'\n+wildtest 1 1 1 1 ']' '[\\]]'\n+wildtest 0 0 0 0 '\\]' '[\\]]'\n+wildtest 0 0 0 0 '\\' '[\\]]'\n+wildtest 0 0 0 0 'ab' 'a[]b'\n+wildtest 0 0 0 0 'a[]b' 'a[]b'\n+wildtest 0 0 0 0 'ab[' 'ab['\n+wildtest 0 0 0 0 'ab' '[!'\n+wildtest 0 0 0 0 'ab' '[-'\n+wildtest 1 1 1 1 '-' '[-]'\n+wildtest 0 0 0 0 '-' '[a-'\n+wildtest 0 0 0 0 '-' '[!a-'\n+wildtest 1 1 1 1 '-' '[--A]'\n+wildtest 1 1 1 1 '5' '[--A]'\n+wildtest 1 1 1 1 ' ' '[ --]'\n+wildtest 1 1 1 1 '$' '[ --]'\n+wildtest 1 1 1 1 '-' '[ --]'\n+wildtest 0 0 0 0 '0' '[ --]'\n+wildtest 1 1 1 1 '-' '[---]'\n+wildtest 1 1 1 1 '-' '[------]'\n+wildtest 0 0 0 0 'j' '[a-e-n]'\n+wildtest 1 1 1 1 '-' '[a-e-n]'\n+wildtest 1 1 1 1 'a' '[!------]'\n+wildtest 0 0 0 0 '[' '[]-a]'\n+wildtest 1 1 1 1 '^' '[]-a]'\n+wildtest 0 0 0 0 '^' '[!]-a]'\n+wildtest 1 1 1 1 '[' '[!]-a]'\n+wildtest 1 1 1 1 '^' '[a^bc]'\n+wildtest 1 1 1 1 '-b]' '[a-]b]'\n+wildtest 0 0 0 0 '\\' '[\\]'\n+wildtest 1 1 1 1 '\\' '[\\\\]'\n+wildtest 0 0 0 0 '\\' '[!\\\\]'\n+wildtest 1 1 1 1 'G' '[A-\\\\]'\n+wildtest 0 0 0 0 'aaabbb' 'b*a'\n+wildtest 0 0 0 0 'aabcaa' '*ba*'\n+wildtest 1 1 1 1 ',' '[,]'\n+wildtest 1 1 1 1 ',' '[\\\\,]'\n+wildtest 1 1 1 1 '\\' '[\\\\,]'\n+wildtest 1 1 1 1 '-' '[,-.]'\n+wildtest 0 0 0 0 '+' '[,-.]'\n+wildtest 0 0 0 0 '-.]' '[,-.]'\n+wildtest 1 1 1 1 '2' '[\\1-\\3]'\n+wildtest 1 1 1 1 '3' '[\\1-\\3]'\n+wildtest 0 0 0 0 '4' '[\\1-\\3]'\n+wildtest 1 1 1 1 '\\' '[[-\\]]'\n+wildtest 1 1 1 1 '[' '[[-\\]]'\n+wildtest 1 1 1 1 ']' '[[-\\]]'\n+wildtest 0 0 0 0 '-' '[[-\\]]'\n \n-pathmatch 1 foo foo\n-pathmatch 0 foo fo\n-pathmatch 1 foo/bar foo/bar\n-pathmatch 1 foo/bar 'foo/*'\n-pathmatch 1 foo/bba/arr 'foo/*'\n-pathmatch 1 foo/bba/arr 'foo/**'\n-pathmatch 1 foo/bba/arr 'foo*'\n-pathmatch 1 foo/bba/arr 'foo**'\n-pathmatch 1 foo/bba/arr 'foo/*arr'\n-pathmatch 1 foo/bba/arr 'foo/**arr'\n-pathmatch 0 foo/bba/arr 'foo/*z'\n-pathmatch 0 foo/bba/arr 'foo/**z'\n-pathmatch 1 foo/bar 'foo?bar'\n-pathmatch 1 foo/bar 'foo[/]bar'\n-pathmatch 1 foo/bar 'foo[^a-z]bar'\n-pathmatch 0 foo '*/*/*'\n-pathmatch 0 foo/bar '*/*/*'\n-pathmatch 1 foo/bba/arr '*/*/*'\n-pathmatch 1 foo/bb/aa/rr '*/*/*'\n-pathmatch 1 abcXdefXghi '*X*i'\n-pathmatch 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n-pathmatch 1 ab/cXd/efXg/hi '*Xg*i'\n+# Test recursion\n+wildtest 1 1 1 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+wildtest 0 0 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+wildtest 0 0 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+wildtest 1 1 1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+wildtest 0 0 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+wildtest 1 1 1 1 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n+wildtest 0 0 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n+wildtest 0 0 0 0 foo '*/*/*'\n+wildtest 0 0 0 0 foo/bar '*/*/*'\n+wildtest 1 1 1 1 foo/bba/arr '*/*/*'\n+wildtest 0 0 1 1 foo/bb/aa/rr '*/*/*'\n+wildtest 1 1 1 1 foo/bb/aa/rr '**/**/**'\n+wildtest 1 1 1 1 abcXdefXghi '*X*i'\n+wildtest 0 0 1 1 ab/cXd/efXg/hi '*X*i'\n+wildtest 1 1 1 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n+wildtest 1 1 1 1 ab/cXd/efXg/hi '**/*X*/**/*i'\n \n-# Case-sensitivity features\n-match 0 'a' '[A-Z]'\n-match 1 'A' '[A-Z]'\n-match 0 'A' '[a-z]'\n-match 1 'a' '[a-z]'\n-match 0 'a' '[[:upper:]]'\n-match 1 'A' '[[:upper:]]'\n-match 0 'A' '[[:lower:]]'\n-match 1 'a' '[[:lower:]]'\n-match 0 'A' '[B-Za]'\n-match 1 'a' '[B-Za]'\n-match 0 'A' '[B-a]'\n-match 1 'a' '[B-a]'\n-match 0 'z' '[Z-y]'\n-match 1 'Z' '[Z-y]'\n+# Extra pathmatch tests\n+wildtest 0 0 0 0 foo fo\n+wildtest 1 1 1 1 foo/bar foo/bar\n+wildtest 1 1 1 1 foo/bar 'foo/*'\n+wildtest 0 0 1 1 foo/bba/arr 'foo/*'\n+wildtest 1 1 1 1 foo/bba/arr 'foo/**'\n+wildtest 0 0 1 1 foo/bba/arr 'foo*'\n+wildtest 0 0 1 1 foo/bba/arr 'foo**'\n+wildtest 0 0 1 1 foo/bba/arr 'foo/*arr'\n+wildtest 0 0 1 1 foo/bba/arr 'foo/**arr'\n+wildtest 0 0 0 0 foo/bba/arr 'foo/*z'\n+wildtest 0 0 0 0 foo/bba/arr 'foo/**z'\n+wildtest 0 0 1 1 foo/bar 'foo?bar'\n+wildtest 0 0 1 1 foo/bar 'foo[/]bar'\n+wildtest 0 0 1 1 foo/bar 'foo[^a-z]bar'\n+wildtest 0 0 1 1 ab/cXd/efXg/hi '*Xg*i'\n \n-imatch 1 'a' '[A-Z]'\n-imatch 1 'A' '[A-Z]'\n-imatch 1 'A' '[a-z]'\n-imatch 1 'a' '[a-z]'\n-imatch 1 'a' '[[:upper:]]'\n-imatch 1 'A' '[[:upper:]]'\n-imatch 1 'A' '[[:lower:]]'\n-imatch 1 'a' '[[:lower:]]'\n-imatch 1 'A' '[B-Za]'\n-imatch 1 'a' '[B-Za]'\n-imatch 1 'A' '[B-a]'\n-imatch 1 'a' '[B-a]'\n-imatch 1 'z' '[Z-y]'\n-imatch 1 'Z' '[Z-y]'\n+# Extra case-sensitivity tests\n+wildtest 0 1 0 1 'a' '[A-Z]'\n+wildtest 1 1 1 1 'A' '[A-Z]'\n+wildtest 0 1 0 1 'A' '[a-z]'\n+wildtest 1 1 1 1 'a' '[a-z]'\n+wildtest 0 1 0 1 'a' '[[:upper:]]'\n+wildtest 1 1 1 1 'A' '[[:upper:]]'\n+wildtest 0 1 0 1 'A' '[[:lower:]]'\n+wildtest 1 1 1 1 'a' '[[:lower:]]'\n+wildtest 0 1 0 1 'A' '[B-Za]'\n+wildtest 1 1 1 1 'a' '[B-Za]'\n+wildtest 0 1 0 1 'A' '[B-a]'\n+wildtest 1 1 1 1 'a' '[B-a]'\n+wildtest 0 1 0 1 'z' '[Z-y]'\n+wildtest 1 1 1 1 'Z' '[Z-y]'\n \n test_done\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335274","messageId":"20171225002835.29005-8-avarab@gmail.com","threadId":"47493","inReplyTo":"20171225002835.29005-1-avarab@gmail.com","subject":"[PATCH v2 7/7] wildmatch test: create & test files on disk in addition to in-memory","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-25T00:28:35Z","receivedAt":"2017-12-25T00:29:22Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"There has never been any full roundtrip testing of what git-ls-files\nand other functions that use wildmatch() actually do, rather we've\nbeen satisfied with just testing the underlying C function.\n\nDue to git-ls-files and friends having their own codepaths before they\ncall wildmatch() there's sometimes differences in the behavior between\nthe two, and even when we test for those (as with\n9e4e8a64c2 (\"pathspec: die on empty strings as pathspec\", 2017-06-06))\nthere was no one place where you can review how these two modes\ndiffer.\n\nNow there is. We now attempt to create a file called $haystack and\nmatch $needle against it for each pair of $needle and $haystack that\nwe were passing to test-wildmatch.\n\nIf we can't create the file we skip the test. This ensures that we can\nrun this on all platforms and not maintain some infinitely growing\nwhitelist of e.g. platforms that don't support certain characters in\nfilenames.\n\nAs a result of doing this we can now see the cases where these two\nways of testing wildmatch differ:\n\n * Creating a file called 'a[]b' and running ls-files 'a[]b' will show\n   that file, but wildmatch(\"a[]b\", \"a[]b\") will not match\n\n * wildmatch() won't match a file called \\ against \\, but ls-files\n   will.\n\n * `git --glob-pathspecs ls-files 'foo**'` will match a file\n   'foo/bba/arr', but wildmatch won't, however pathmatch will.\n\n   This seems like a bug to me, the two are otherwise equivalent as\n   these tests show.\n\nThis also reveals the case discussed in 9e4e8a64c2 above, where '' is\nnow an error as far as ls-files is concerned, but wildmatch() itself\nhappily accepts it.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 285 ++++++++++++++++++++++++++++++++++++++++++++++++---\n 1 file changed, 273 insertions(+), 12 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 593b25b278..80d13b5b60 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -4,14 +4,95 @@ test_description='wildmatch tests'\n \n . ./test-lib.sh\n \n+create_test_file() {\n+\tfile=$1\n+\n+\tcase $file in\n+\t# `touch .` will succeed but obviously not do what we intend\n+\t# here.\n+\t\".\")\n+\t\treturn 1\n+\t\t;;\n+\t# We cannot create a file with an empty filename.\n+\t\"\")\n+\t\treturn 1\n+\t\t;;\n+\t# The tests that are testing that e.g. foo//bar is matched by\n+\t# foo/*/bar can't be tested on filesystems since there's no\n+\t# way we're getting a double slash.\n+\t*//*)\n+\t\treturn 1\n+\t\t;;\n+\t# When testing the difference between foo/bar and foo/bar/ we\n+\t# can't test the latter.\n+\t*/)\n+\t\treturn 1\n+\t\t;;\n+\tesac\n+\n+\t# Turn foo/bar/baz into foo/bar to create foo/bar as a\n+\t# directory structure.\n+\tdirs=$(echo \"$file\" | sed -r 's!/[^/]+$!!')\n+\n+\t# We touch \"./$file\" instead of \"$file\" because even an\n+\t# escaped \"touch -- -\" means get arguments from stdin.\n+\tif test \"$file\" != \"$dirs\"\n+\tthen\n+\t\tmkdir -p -- \"$dirs\" &&\n+\t\ttouch -- \"./$file\" &&\n+\t\treturn 0\n+\telse\n+\t\ttouch -- \"./$file\" &&\n+\t\treturn 0\n+\tfi\n+\treturn 1\n+}\n+\n+wildtest_file_setup() {\n+\ttest_when_finished \"\n+\t\trm -rf -- * &&\n+\t\tgit reset\n+\t\" &&\n+\tgit add -A &&\n+\t>expect.err\n+}\n+\n+wildtest_stdout_stderr_cmp() {\n+\ttr -d '\\0' <actual.raw >actual &&\n+\ttest_cmp expect.err actual.err &&\n+\ttest_cmp expect actual\n+}\n+\n wildtest() {\n-\tmatch_w_glob=$1\n-\tmatch_w_globi=$2\n-\tmatch_w_pathmatch=$3\n-\tmatch_w_pathmatchi=$4\n-\ttext=$5\n-\tpattern=$6\n+\tif test \"$#\" = 6\n+\tthen\n+\t\t# When test-wildmatch and git ls-files produce the same\n+\t\t# result.\n+\t\tmatch_w_glob=$1\n+\t\tmatch_f_w_glob=$match_w_glob\n+\t\tmatch_w_globi=$2\n+\t\tmatch_f_w_globi=$match_w_globi\n+\t\tmatch_w_pathmatch=$3\n+\t\tmatch_f_w_pathmatch=$match_w_pathmatch\n+\t\tmatch_w_pathmatchi=$4\n+\t\tmatch_f_w_pathmatchi=$match_w_pathmatchi\n+\t\ttext=$5\n+\t\tpattern=$6\n+\telif test \"$#\" = 10\n+\tthen\n+\t\tmatch_w_glob=$1\n+\t\tmatch_w_globi=$2\n+\t\tmatch_w_pathmatch=$3\n+\t\tmatch_w_pathmatchi=$4\n+\t\tmatch_f_w_glob=$5\n+\t\tmatch_f_w_globi=$6\n+\t\tmatch_f_w_pathmatch=$7\n+\t\tmatch_f_w_pathmatchi=$8\n+\t\ttext=$9\n+\t\tpattern=$10\n+\tfi\n \n+\t# $1: Case sensitive glob match: test-wildmatch\n \tif test \"$match_w_glob\" = 1\n \tthen\n \t\ttest_expect_success \"wildmatch: match '$text' '$pattern'\" \"\n@@ -26,6 +107,50 @@ wildtest() {\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_glob\" 'false'\n \tfi\n \n+\t# $1: Case sensitive glob match: ls-files\n+\tif test \"$match_f_w_glob\" = 'E'\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"wildmatch(ls): match dies on '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\ttest_must_fail git --glob-pathspecs ls-files -z -- '$pattern'\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_glob\" = 1\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"wildmatch(ls): match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\tgit --glob-pathspecs ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_glob\" = 0\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"wildmatch(ls): no match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\t>expect &&\n+\t\t\t\tgit --glob-pathspecs ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): no match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_f_w_glob\" 'false'\n+\tfi\n+\n+\t# $2: Case insensitive glob match: test-wildmatch\n \tif test \"$match_w_globi\" = 1\n \tthen\n \t\ttest_expect_success \"iwildmatch: match '$text' '$pattern'\" \"\n@@ -40,6 +165,50 @@ wildtest() {\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_globi\" 'false'\n \tfi\n \n+\t# $2: Case insensitive glob match: ls-files\n+\tif test \"$match_f_w_globi\" = 'E'\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"wildmatch(ls): match dies on '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\ttest_must_fail git --glob-pathspecs --icase-pathspecs ls-files -z -- '$pattern'\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_globi\" = 1\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"wildmatch(ls): match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\tgit --glob-pathspecs --icase-pathspecs ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_globi\" = 0\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"wildmatch(ls): no match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\t>expect &&\n+\t\t\t\tgit --glob-pathspecs --icase-pathspecs ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): no match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_f_w_globi\" 'false'\n+\tfi\n+\n+\t# $3: Case sensitive path match: test-wildmatch\n \tif test \"$match_w_pathmatch\" = 1\n \tthen\n \t\ttest_expect_success \"pathmatch: match '$text' '$pattern'\" \"\n@@ -54,9 +223,53 @@ wildtest() {\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_pathmatch\" 'false'\n \tfi\n \n+\t# $4: Case sensitive path match: ls-files\n+\tif test \"$match_f_w_pathmatch\" = 'E'\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"pathmatch(ls): match dies on '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\ttest_must_fail git ls-files -z -- '$pattern'\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_pathmatch\" = 1\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"pathmatch(ls): match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\tgit ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_pathmatch\" = 0\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"pathmatch(ls): no match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\t>expect &&\n+\t\t\t\tgit ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): no match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_f_w_pathmatch\" 'false'\n+\tfi\n+\n+\t# $4: Case insensitive path match: test-wildmatch\n \tif test \"$match_w_pathmatchi\" = 1\n \tthen\n-\t\ttest_expect_success \"ipathmatch:    match '$text' '$pattern'\" \"\n+\t\ttest_expect_success \"ipathmatch: match '$text' '$pattern'\" \"\n \t\t\ttest-wildmatch ipathmatch '$text' '$pattern'\n \t\t\"\n \telif test \"$match_w_pathmatchi\" = 0\n@@ -67,6 +280,49 @@ wildtest() {\n \telse\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_pathmatchi\" 'false'\n \tfi\n+\n+\t# $4: Case insensitive path match: ls-files\n+\tif test \"$match_f_w_pathmatchi\" = 'E'\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"ipathmatch(ls): match dies on '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\ttest_must_fail git --icase-pathspecs ls-files -z -- '$pattern'\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_pathmatchi\" = 1\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"ipathmatch(ls): match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\tgit --icase-pathspecs ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_pathmatchi\" = 0\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"ipathmatch(ls): no match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\t>expect &&\n+\t\t\t\tgit ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): no match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_f_w_pathmatchi\" 'false'\n+\tfi\n }\n \n # Basic wildmatch features\n@@ -135,7 +391,8 @@ wildtest 1 1 1 1 'acrt' 'a[c-c]rt'\n wildtest 0 0 0 0 ']' '[!]-]'\n wildtest 1 1 1 1 'a' '[!]-]'\n wildtest 0 0 0 0 '' '\\'\n-wildtest 0 0 0 0 '\\' '\\'\n+wildtest 0 0 0 0 \\\n+\t 1 1 1 1 '\\' '\\'\n wildtest 0 0 0 0 'XXX/\\' '*/\\'\n wildtest 1 1 1 1 'XXX/\\' '*/\\\\'\n wildtest 1 1 1 1 'foo' 'foo'\n@@ -149,7 +406,8 @@ wildtest 1 1 1 1 '[ab]' '[[:digit]ab]'\n wildtest 1 1 1 1 '[ab]' '[\\[:]ab]'\n wildtest 1 1 1 1 '?a?b' '\\??\\?b'\n wildtest 1 1 1 1 'abc' '\\a\\b\\c'\n-wildtest 0 0 0 0 'foo' ''\n+wildtest 0 0 0 0 \\\n+\t E E E E 'foo' ''\n wildtest 1 1 1 1 'foo/bar/baz/to' '**/t[o]'\n \n # Character class tests\n@@ -179,8 +437,10 @@ wildtest 1 1 1 1 ']' '[\\]]'\n wildtest 0 0 0 0 '\\]' '[\\]]'\n wildtest 0 0 0 0 '\\' '[\\]]'\n wildtest 0 0 0 0 'ab' 'a[]b'\n-wildtest 0 0 0 0 'a[]b' 'a[]b'\n-wildtest 0 0 0 0 'ab[' 'ab['\n+wildtest 0 0 0 0 \\\n+\t 1 1 1 1 'a[]b' 'a[]b'\n+wildtest 0 0 0 0 \\\n+\t 1 1 1 1 'ab[' 'ab['\n wildtest 0 0 0 0 'ab' '[!'\n wildtest 0 0 0 0 'ab' '[-'\n wildtest 1 1 1 1 '-' '[-]'\n@@ -248,7 +508,8 @@ wildtest 1 1 1 1 foo/bar 'foo/*'\n wildtest 0 0 1 1 foo/bba/arr 'foo/*'\n wildtest 1 1 1 1 foo/bba/arr 'foo/**'\n wildtest 0 0 1 1 foo/bba/arr 'foo*'\n-wildtest 0 0 1 1 foo/bba/arr 'foo**'\n+wildtest 0 0 1 1 \\\n+\t 1 1 1 1 foo/bba/arr 'foo**'\n wildtest 0 0 1 1 foo/bba/arr 'foo/*arr'\n wildtest 0 0 1 1 foo/bba/arr 'foo/**arr'\n wildtest 0 0 0 0 foo/bba/arr 'foo/*z'\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335279","messageId":"e9a248f9-2caa-693d-3300-b86247fbf76a@kdbg.org","threadId":"47493","inReplyTo":"20171225002835.29005-8-avarab@gmail.com","subject":"Re: [PATCH v2 7/7] wildmatch test: create & test files on disk in addition to in-memory","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2017-12-25T09:26:27Z","receivedAt":"2017-12-25T09:26:36Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 25.12.2017 um 01:28 schrieb Ævar Arnfjörð Bjarmason:\n> +create_test_file() {\n> +\tfile=$1\n> +\n> +\tcase $file in\n> +\t# `touch .` will succeed but obviously not do what we intend\n> +\t# here.\n> +\t\".\")\n> +\t\treturn 1\n> +\t\t;;\n> +\t# We cannot create a file with an empty filename.\n> +\t\"\")\n> +\t\treturn 1\n> +\t\t;;\n> +\t# The tests that are testing that e.g. foo//bar is matched by\n> +\t# foo/*/bar can't be tested on filesystems since there's no\n> +\t# way we're getting a double slash.\n> +\t*//*)\n> +\t\treturn 1\n> +\t\t;;\n> +\t# When testing the difference between foo/bar and foo/bar/ we\n> +\t# can't test the latter.\n> +\t*/)\n> +\t\treturn 1\n> +\t\t;;\n> +\tesac\n\nNice!\n\n> +\n> +\t# Turn foo/bar/baz into foo/bar to create foo/bar as a\n> +\t# directory structure.\n> +\tdirs=$(echo \"$file\" | sed -r 's!/[^/]+$!!')\n\n\tdirs=${file%/*}\n\nshould do the same without forking processes, no?\n\n-- Hannes\n"},{"id":"335384","messageId":"xmqqr2rgm1kv.fsf@gitster.mtv.corp.google.com","threadId":"47493","inReplyTo":"20171225002835.29005-8-avarab@gmail.com","subject":"Re: [PATCH v2 7/7] wildmatch test: create & test files on disk in addition to in-memory","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-12-27T19:07:44Z","receivedAt":"2017-12-27T19:07:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> +\t# Turn foo/bar/baz into foo/bar to create foo/bar as a\n> +\t# directory structure.\n> +\tdirs=$(echo \"$file\" | sed -r 's!/[^/]+$!!')\n\nLet's not limit this script to GNUism systems.\n\nYou want to see if $file has a slash followed by one or more non-slash\nletters to the end and strip the whole thing.  We further know that\nat this point $file does not end with a slash.  So perhaps\n\n\tdirs=${file%/*}\n\nis sufficient?\n\nThanks.\n"},{"id":"335486","messageId":"xmqqh8sak360.fsf@gitster.mtv.corp.google.com","threadId":"47493","inReplyTo":"20171225002835.29005-7-avarab@gmail.com","subject":"Re: [PATCH v2 6/7] wildmatch test: perform all tests under all wildmatch() modes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-12-28T20:28:39Z","receivedAt":"2017-12-28T20:28:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> +\tif test \"$match_w_pathmatchi\" = 1\n> +\tthen\n> +\t\ttest_expect_success \"ipathmatch:    match '$text' '$pattern'\" \"\n> +\t\t\ttest-wildmatch ipathmatch '$text' '$pattern'\n> +\t\t\"\n> +\telif test \"$match_w_pathmatchi\" = 0\n> +\tthen\n> +\t\ttest_expect_success \"ipathmatch: no match '$text' '$pattern'\" \"\n\nI somehow thought that you earlier decided not to SP align the test titles?\n\nNot a big deal but aligning this one alone stood out and I ended up\nnoticing it, so... ;-)\n\n"},{"id":"335500","messageId":"xmqqr2reii4u.fsf@gitster.mtv.corp.google.com","threadId":"47493","inReplyTo":"20171225002835.29005-1-avarab@gmail.com","subject":"Re: [PATCH v2 0/7] increase wildmatch test coverage","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-12-28T22:48:17Z","receivedAt":"2017-12-28T22:48:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> This v2 addresses comments by Johannes Sixt in\n> <8f4cdb23-8e2e-144a-1f70-99776b027166@kdbg.org> and there's osme other\n> cleanups as noted below.\n\nOne thing I found \"interesting\" (because it is usually the other way\naround) is that about two dozens of the tests in this fail when your\nshell is bash and all of them pass when your shell is dash.\n\n"},{"id":"335501","messageId":"20171228232823.14450-1-avarab@gmail.com","threadId":"47493","inReplyTo":"20171225002835.29005-1-avarab@gmail.com","subject":"[PATCH v3 0/7] increase wildmatch test coverage","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-28T23:28:16Z","receivedAt":"2017-12-28T23:28:41Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Fixes issues noted since v2 and one I spotted myself, notes below:\n\nÆvar Arnfjörð Bjarmason (7):\n  wildmatch test: indent with tabs, not spaces\n  wildmatch test: use more standard shell style\n  wildmatch test: don't try to vertically align our output\n  wildmatch test: use a paranoia pattern from nul_match()\n  wildmatch test: remove dead fnmatch() test code\n\nNo changes.\n\n  wildmatch test: perform all tests under all wildmatch() modes\n\nFix vertical alignment of new test (that was just changed back later\nin v2).\n\n  wildmatch test: create & test files on disk in addition to in-memory\n\n* Use ${file%/*} instead of forking for finding the dir part of a path\n\n* Consistently name tests, e.g. I had some called wildmatch and\n  wildmatch(ls), but then iwildmatch and wildmatch(ls) again, now it's\n  iwildmatch(ls) in the second case.\n\n t/helper/test-wildmatch.c |   2 +\n t/t3070-wildmatch.sh      | 759 +++++++++++++++++++++++++++++++---------------\n 2 files changed, 516 insertions(+), 245 deletions(-)\n\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335502","messageId":"20171228232823.14450-2-avarab@gmail.com","threadId":"47493","inReplyTo":"20171228232823.14450-1-avarab@gmail.com","subject":"[PATCH v3 1/7] wildmatch test: indent with tabs, not spaces","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-28T23:28:17Z","receivedAt":"2017-12-28T23:28:44Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Replace the 4-width mixed space & tab indentation in this file with\nindentation with tabs as we do in most of the rest of our tests.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 54 ++++++++++++++++++++++++++--------------------------\n 1 file changed, 27 insertions(+), 27 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 163a14a1c2..27fa878f6e 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -5,39 +5,39 @@ test_description='wildmatch tests'\n . ./test-lib.sh\n \n match() {\n-    if [ $1 = 1 ]; then\n-\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n-\t    test-wildmatch wildmatch '$3' '$4'\n-\t\"\n-    else\n-\ttest_expect_success \"wildmatch:  no match '$3' '$4'\" \"\n-\t    ! test-wildmatch wildmatch '$3' '$4'\n-\t\"\n-    fi\n+\tif [ $1 = 1 ]; then\n+\t\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n+\t\t\ttest-wildmatch wildmatch '$3' '$4'\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"wildmatch:  no match '$3' '$4'\" \"\n+\t\t\t! test-wildmatch wildmatch '$3' '$4'\n+\t\t\"\n+\tfi\n }\n \n imatch() {\n-    if [ $1 = 1 ]; then\n-\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n-\t    test-wildmatch iwildmatch '$2' '$3'\n-\t\"\n-    else\n-\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n-\t    ! test-wildmatch iwildmatch '$2' '$3'\n-\t\"\n-    fi\n+\tif [ $1 = 1 ]; then\n+\t\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n+\t\t\ttest-wildmatch iwildmatch '$2' '$3'\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n+\t\t\t! test-wildmatch iwildmatch '$2' '$3'\n+\t\t\"\n+\tfi\n }\n \n pathmatch() {\n-    if [ $1 = 1 ]; then\n-\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n-\t    test-wildmatch pathmatch '$2' '$3'\n-\t\"\n-    else\n-\ttest_expect_success \"pathmatch:  no match '$2' '$3'\" \"\n-\t    ! test-wildmatch pathmatch '$2' '$3'\n-\t\"\n-    fi\n+\tif [ $1 = 1 ]; then\n+\t\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n+\t\t\ttest-wildmatch pathmatch '$2' '$3'\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"pathmatch:  no match '$2' '$3'\" \"\n+\t\t\t! test-wildmatch pathmatch '$2' '$3'\n+\t\t\"\n+\tfi\n }\n \n # Basic wildmat features\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335503","messageId":"20171228232823.14450-4-avarab@gmail.com","threadId":"47493","inReplyTo":"20171228232823.14450-1-avarab@gmail.com","subject":"[PATCH v3 3/7] wildmatch test: don't try to vertically align our output","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-28T23:28:19Z","receivedAt":"2017-12-28T23:28:47Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Don't try to vertically align the test output, which is futile anyway\nunder the TAP output where we're going to be emitting a number for\neach test without aligning the test count.\n\nThis makes subsequent changes of mine where I'm not going to be\naligning this output as I add new tests easier.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 4d589d1f9a..19ea64bba9 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -7,11 +7,11 @@ test_description='wildmatch tests'\n match() {\n \tif test \"$1\" = 1\n \tthen\n-\t\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n+\t\ttest_expect_success \"wildmatch: match '$3' '$4'\" \"\n \t\t\ttest-wildmatch wildmatch '$3' '$4'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"wildmatch:  no match '$3' '$4'\" \"\n+\t\ttest_expect_success \"wildmatch: no match '$3' '$4'\" \"\n \t\t\t! test-wildmatch wildmatch '$3' '$4'\n \t\t\"\n \tfi\n@@ -20,7 +20,7 @@ match() {\n imatch() {\n \tif test \"$1\" = 1\n \tthen\n-\t\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n+\t\ttest_expect_success \"iwildmatch: match '$2' '$3'\" \"\n \t\t\ttest-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n \telse\n@@ -33,11 +33,11 @@ imatch() {\n pathmatch() {\n \tif test \"$1\" = 1\n \tthen\n-\t\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n+\t\ttest_expect_success \"pathmatch: match '$2' '$3'\" \"\n \t\t\ttest-wildmatch pathmatch '$2' '$3'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"pathmatch:  no match '$2' '$3'\" \"\n+\t\ttest_expect_success \"pathmatch: no match '$2' '$3'\" \"\n \t\t\t! test-wildmatch pathmatch '$2' '$3'\n \t\t\"\n \tfi\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335504","messageId":"20171228232823.14450-3-avarab@gmail.com","threadId":"47493","inReplyTo":"20171228232823.14450-1-avarab@gmail.com","subject":"[PATCH v3 2/7] wildmatch test: use more standard shell style","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-28T23:28:18Z","receivedAt":"2017-12-28T23:28:51Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the wildmatch test to use more standard shell style, usually we\nuse \"if test\" not \"if [\".\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 9 ++++++---\n 1 file changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 27fa878f6e..4d589d1f9a 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -5,7 +5,8 @@ test_description='wildmatch tests'\n . ./test-lib.sh\n \n match() {\n-\tif [ $1 = 1 ]; then\n+\tif test \"$1\" = 1\n+\tthen\n \t\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n \t\t\ttest-wildmatch wildmatch '$3' '$4'\n \t\t\"\n@@ -17,7 +18,8 @@ match() {\n }\n \n imatch() {\n-\tif [ $1 = 1 ]; then\n+\tif test \"$1\" = 1\n+\tthen\n \t\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n \t\t\ttest-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n@@ -29,7 +31,8 @@ imatch() {\n }\n \n pathmatch() {\n-\tif [ $1 = 1 ]; then\n+\tif test \"$1\" = 1\n+\tthen\n \t\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n \t\t\ttest-wildmatch pathmatch '$2' '$3'\n \t\t\"\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335505","messageId":"20171228232823.14450-7-avarab@gmail.com","threadId":"47493","inReplyTo":"20171228232823.14450-1-avarab@gmail.com","subject":"[PATCH v3 6/7] wildmatch test: perform all tests under all wildmatch() modes","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-28T23:28:22Z","receivedAt":"2017-12-28T23:28:55Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Rewrite the wildmatch() test suite so that each test now tests all\ncombinations of the wildmatch() WM_CASEFOLD and WM_PATHNAME flags.\n\nBefore this change some test inputs were not tested on\ne.g. WM_PATHNAME. Now the function is stress tested on all possible\ninputs, and for each input we declare what the result should be if the\nmode is case-insensitive, or pathname matching, or case-sensitive or\nnot matching pathnames.\n\nAlso before this change, nothing was testing case-insensitive\nnon-pathname matching, so I've added that to test-wildmatch.c and made\nuse of it.\n\nThis yields a rather scary patch, but there are no functional changes\nhere, just more test coverage. Some now-redundant tests were deleted\nas a result of this change, since they were now duplicating an earlier\ntest.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/helper/test-wildmatch.c |   2 +\n t/t3070-wildmatch.sh      | 478 +++++++++++++++++++++++-----------------------\n 2 files changed, 239 insertions(+), 241 deletions(-)\n\ndiff --git a/t/helper/test-wildmatch.c b/t/helper/test-wildmatch.c\nindex 921d7b3e7e..66d33dfcfd 100644\n--- a/t/helper/test-wildmatch.c\n+++ b/t/helper/test-wildmatch.c\n@@ -16,6 +16,8 @@ int cmd_main(int argc, const char **argv)\n \t\treturn !!wildmatch(argv[3], argv[2], WM_PATHNAME | WM_CASEFOLD);\n \telse if (!strcmp(argv[1], \"pathmatch\"))\n \t\treturn !!wildmatch(argv[3], argv[2], 0);\n+\telse if (!strcmp(argv[1], \"ipathmatch\"))\n+\t\treturn !!wildmatch(argv[3], argv[2], WM_CASEFOLD);\n \telse\n \t\treturn 1;\n }\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 2f8a681c72..06db053ae2 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -4,278 +4,274 @@ test_description='wildmatch tests'\n \n . ./test-lib.sh\n \n-match() {\n-\tif test \"$1\" = 1\n+wildtest() {\n+\tmatch_w_glob=$1\n+\tmatch_w_globi=$2\n+\tmatch_w_pathmatch=$3\n+\tmatch_w_pathmatchi=$4\n+\ttext=$5\n+\tpattern=$6\n+\n+\tif test \"$match_w_glob\" = 1\n \tthen\n-\t\ttest_expect_success \"wildmatch: match '$2' '$3'\" \"\n-\t\t\ttest-wildmatch wildmatch '$2' '$3'\n+\t\ttest_expect_success \"wildmatch: match '$text' '$pattern'\" \"\n+\t\t\ttest-wildmatch wildmatch '$text' '$pattern'\n \t\t\"\n-\telif test \"$1\" = 0\n+\telif test \"$match_w_glob\" = 0\n \tthen\n-\t\ttest_expect_success \"wildmatch: no match '$2' '$3'\" \"\n-\t\t\t! test-wildmatch wildmatch '$2' '$3'\n+\t\ttest_expect_success \"wildmatch: no match '$text' '$pattern'\" \"\n+\t\t\t! test-wildmatch wildmatch '$text' '$pattern'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_glob\" 'false'\n \tfi\n-}\n \n-imatch() {\n-\tif test \"$1\" = 1\n+\tif test \"$match_w_globi\" = 1\n \tthen\n-\t\ttest_expect_success \"iwildmatch: match '$2' '$3'\" \"\n-\t\t\ttest-wildmatch iwildmatch '$2' '$3'\n+\t\ttest_expect_success \"iwildmatch: match '$text' '$pattern'\" \"\n+\t\t\ttest-wildmatch iwildmatch '$text' '$pattern'\n \t\t\"\n-\telif test \"$1\" = 0\n+\telif test \"$match_w_globi\" = 0\n \tthen\n-\t\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n-\t\t\t! test-wildmatch iwildmatch '$2' '$3'\n+\t\ttest_expect_success \"iwildmatch: no match '$text' '$pattern'\" \"\n+\t\t\t! test-wildmatch iwildmatch '$text' '$pattern'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_globi\" 'false'\n \tfi\n-}\n \n-pathmatch() {\n-\tif test \"$1\" = 1\n+\tif test \"$match_w_pathmatch\" = 1\n \tthen\n-\t\ttest_expect_success \"pathmatch: match '$2' '$3'\" \"\n-\t\t\ttest-wildmatch pathmatch '$2' '$3'\n+\t\ttest_expect_success \"pathmatch: match '$text' '$pattern'\" \"\n+\t\t\ttest-wildmatch pathmatch '$text' '$pattern'\n \t\t\"\n-\telif test \"$1\" = 0\n+\telif test \"$match_w_pathmatch\" = 0\n \tthen\n-\t\ttest_expect_success \"pathmatch: no match '$2' '$3'\" \"\n-\t\t\t! test-wildmatch pathmatch '$2' '$3'\n+\t\ttest_expect_success \"pathmatch: no match '$text' '$pattern'\" \"\n+\t\t\t! test-wildmatch pathmatch '$text' '$pattern'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_pathmatch\" 'false'\n+\tfi\n+\n+\tif test \"$match_w_pathmatchi\" = 1\n+\tthen\n+\t\ttest_expect_success \"ipathmatch: match '$text' '$pattern'\" \"\n+\t\t\ttest-wildmatch ipathmatch '$text' '$pattern'\n+\t\t\"\n+\telif test \"$match_w_pathmatchi\" = 0\n+\tthen\n+\t\ttest_expect_success \"ipathmatch: no match '$text' '$pattern'\" \"\n+\t\t\t! test-wildmatch ipathmatch '$text' '$pattern'\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_pathmatchi\" 'false'\n \tfi\n }\n \n-# Basic wildmat features\n-match 1 foo foo\n-match 0 foo bar\n-match 1 '' \"\"\n-match 1 foo '???'\n-match 0 foo '??'\n-match 1 foo '*'\n-match 1 foo 'f*'\n-match 0 foo '*f'\n-match 1 foo '*foo*'\n-match 1 foobar '*ob*a*r*'\n-match 1 aaaaaaabababab '*ab'\n-match 1 'foo*' 'foo\\*'\n-match 0 foobar 'foo\\*bar'\n-match 1 'f\\oo' 'f\\\\oo'\n-match 1 ball '*[al]?'\n-match 0 ten '[ten]'\n-match 0 ten '**[!te]'\n-match 0 ten '**[!ten]'\n-match 1 ten 't[a-g]n'\n-match 0 ten 't[!a-g]n'\n-match 1 ton 't[!a-g]n'\n-match 1 ton 't[^a-g]n'\n-match 1 'a]b' 'a[]]b'\n-match 1 a-b 'a[]-]b'\n-match 1 'a]b' 'a[]-]b'\n-match 0 aab 'a[]-]b'\n-match 1 aab 'a[]a-]b'\n-match 1 ']' ']'\n+# Basic wildmatch features\n+wildtest 1 1 1 1 foo foo\n+wildtest 0 0 0 0 foo bar\n+wildtest 1 1 1 1 '' \"\"\n+wildtest 1 1 1 1 foo '???'\n+wildtest 0 0 0 0 foo '??'\n+wildtest 1 1 1 1 foo '*'\n+wildtest 1 1 1 1 foo 'f*'\n+wildtest 0 0 0 0 foo '*f'\n+wildtest 1 1 1 1 foo '*foo*'\n+wildtest 1 1 1 1 foobar '*ob*a*r*'\n+wildtest 1 1 1 1 aaaaaaabababab '*ab'\n+wildtest 1 1 1 1 'foo*' 'foo\\*'\n+wildtest 0 0 0 0 foobar 'foo\\*bar'\n+wildtest 1 1 1 1 'f\\oo' 'f\\\\oo'\n+wildtest 1 1 1 1 ball '*[al]?'\n+wildtest 0 0 0 0 ten '[ten]'\n+wildtest 0 0 1 1 ten '**[!te]'\n+wildtest 0 0 0 0 ten '**[!ten]'\n+wildtest 1 1 1 1 ten 't[a-g]n'\n+wildtest 0 0 0 0 ten 't[!a-g]n'\n+wildtest 1 1 1 1 ton 't[!a-g]n'\n+wildtest 1 1 1 1 ton 't[^a-g]n'\n+wildtest 1 1 1 1 'a]b' 'a[]]b'\n+wildtest 1 1 1 1 a-b 'a[]-]b'\n+wildtest 1 1 1 1 'a]b' 'a[]-]b'\n+wildtest 0 0 0 0 aab 'a[]-]b'\n+wildtest 1 1 1 1 aab 'a[]a-]b'\n+wildtest 1 1 1 1 ']' ']'\n \n # Extended slash-matching features\n-match 0 'foo/baz/bar' 'foo*bar'\n-match 0 'foo/baz/bar' 'foo**bar'\n-match 0 'foobazbar' 'foo**bar'\n-match 1 'foo/baz/bar' 'foo/**/bar'\n-match 1 'foo/baz/bar' 'foo/**/**/bar'\n-match 1 'foo/b/a/z/bar' 'foo/**/bar'\n-match 1 'foo/b/a/z/bar' 'foo/**/**/bar'\n-match 1 'foo/bar' 'foo/**/bar'\n-match 1 'foo/bar' 'foo/**/**/bar'\n-match 0 'foo/bar' 'foo?bar'\n-match 0 'foo/bar' 'foo[/]bar'\n-match 0 'foo/bar' 'foo[^a-z]bar'\n-match 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 'foo' '**/foo'\n-match 1 'XXX/foo' '**/foo'\n-match 1 'bar/baz/foo' '**/foo'\n-match 0 'bar/baz/foo' '*/foo'\n-match 0 'foo/bar/baz' '**/bar*'\n-match 1 'deep/foo/bar/baz' '**/bar/*'\n-match 0 'deep/foo/bar/baz/' '**/bar/*'\n-match 1 'deep/foo/bar/baz/' '**/bar/**'\n-match 0 'deep/foo/bar' '**/bar/*'\n-match 1 'deep/foo/bar/' '**/bar/**'\n-match 0 'foo/bar/baz' '**/bar**'\n-match 1 'foo/bar/baz/x' '*/bar/**'\n-match 0 'deep/foo/bar/baz/x' '*/bar/**'\n-match 1 'deep/foo/bar/baz/x' '**/bar/*/*'\n+wildtest 0 0 1 1 'foo/baz/bar' 'foo*bar'\n+wildtest 0 0 1 1 'foo/baz/bar' 'foo**bar'\n+wildtest 0 0 1 1 'foobazbar' 'foo**bar'\n+wildtest 1 1 1 1 'foo/baz/bar' 'foo/**/bar'\n+wildtest 1 1 0 0 'foo/baz/bar' 'foo/**/**/bar'\n+wildtest 1 1 1 1 'foo/b/a/z/bar' 'foo/**/bar'\n+wildtest 1 1 1 1 'foo/b/a/z/bar' 'foo/**/**/bar'\n+wildtest 1 1 0 0 'foo/bar' 'foo/**/bar'\n+wildtest 1 1 0 0 'foo/bar' 'foo/**/**/bar'\n+wildtest 0 0 1 1 'foo/bar' 'foo?bar'\n+wildtest 0 0 1 1 'foo/bar' 'foo[/]bar'\n+wildtest 0 0 1 1 'foo/bar' 'foo[^a-z]bar'\n+wildtest 0 0 1 1 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+wildtest 1 1 1 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+wildtest 1 1 0 0 'foo' '**/foo'\n+wildtest 1 1 1 1 'XXX/foo' '**/foo'\n+wildtest 1 1 1 1 'bar/baz/foo' '**/foo'\n+wildtest 0 0 1 1 'bar/baz/foo' '*/foo'\n+wildtest 0 0 1 1 'foo/bar/baz' '**/bar*'\n+wildtest 1 1 1 1 'deep/foo/bar/baz' '**/bar/*'\n+wildtest 0 0 1 1 'deep/foo/bar/baz/' '**/bar/*'\n+wildtest 1 1 1 1 'deep/foo/bar/baz/' '**/bar/**'\n+wildtest 0 0 0 0 'deep/foo/bar' '**/bar/*'\n+wildtest 1 1 1 1 'deep/foo/bar/' '**/bar/**'\n+wildtest 0 0 1 1 'foo/bar/baz' '**/bar**'\n+wildtest 1 1 1 1 'foo/bar/baz/x' '*/bar/**'\n+wildtest 0 0 1 1 'deep/foo/bar/baz/x' '*/bar/**'\n+wildtest 1 1 1 1 'deep/foo/bar/baz/x' '**/bar/*/*'\n \n # Various additional tests\n-match 0 'acrt' 'a[c-c]st'\n-match 1 'acrt' 'a[c-c]rt'\n-match 0 ']' '[!]-]'\n-match 1 'a' '[!]-]'\n-match 0 '' '\\'\n-match 0 '\\' '\\'\n-match 0 'XXX/\\' '*/\\'\n-match 1 'XXX/\\' '*/\\\\'\n-match 1 'foo' 'foo'\n-match 1 '@foo' '@foo'\n-match 0 'foo' '@foo'\n-match 1 '[ab]' '\\[ab]'\n-match 1 '[ab]' '[[]ab]'\n-match 1 '[ab]' '[[:]ab]'\n-match 0 '[ab]' '[[::]ab]'\n-match 1 '[ab]' '[[:digit]ab]'\n-match 1 '[ab]' '[\\[:]ab]'\n-match 1 '?a?b' '\\??\\?b'\n-match 1 'abc' '\\a\\b\\c'\n-match 0 'foo' ''\n-match 1 'foo/bar/baz/to' '**/t[o]'\n+wildtest 0 0 0 0 'acrt' 'a[c-c]st'\n+wildtest 1 1 1 1 'acrt' 'a[c-c]rt'\n+wildtest 0 0 0 0 ']' '[!]-]'\n+wildtest 1 1 1 1 'a' '[!]-]'\n+wildtest 0 0 0 0 '' '\\'\n+wildtest 0 0 0 0 '\\' '\\'\n+wildtest 0 0 0 0 'XXX/\\' '*/\\'\n+wildtest 1 1 1 1 'XXX/\\' '*/\\\\'\n+wildtest 1 1 1 1 'foo' 'foo'\n+wildtest 1 1 1 1 '@foo' '@foo'\n+wildtest 0 0 0 0 'foo' '@foo'\n+wildtest 1 1 1 1 '[ab]' '\\[ab]'\n+wildtest 1 1 1 1 '[ab]' '[[]ab]'\n+wildtest 1 1 1 1 '[ab]' '[[:]ab]'\n+wildtest 0 0 0 0 '[ab]' '[[::]ab]'\n+wildtest 1 1 1 1 '[ab]' '[[:digit]ab]'\n+wildtest 1 1 1 1 '[ab]' '[\\[:]ab]'\n+wildtest 1 1 1 1 '?a?b' '\\??\\?b'\n+wildtest 1 1 1 1 'abc' '\\a\\b\\c'\n+wildtest 0 0 0 0 'foo' ''\n+wildtest 1 1 1 1 'foo/bar/baz/to' '**/t[o]'\n \n # Character class tests\n-match 1 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n-match 0 'a' '[[:digit:][:upper:][:space:]]'\n-match 1 'A' '[[:digit:][:upper:][:space:]]'\n-match 1 '1' '[[:digit:][:upper:][:space:]]'\n-match 0 '1' '[[:digit:][:upper:][:spaci:]]'\n-match 1 ' ' '[[:digit:][:upper:][:space:]]'\n-match 0 '.' '[[:digit:][:upper:][:space:]]'\n-match 1 '.' '[[:digit:][:punct:][:space:]]'\n-match 1 '5' '[[:xdigit:]]'\n-match 1 'f' '[[:xdigit:]]'\n-match 1 'D' '[[:xdigit:]]'\n-match 1 '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n-match 1 '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n-match 1 '5' '[a-c[:digit:]x-z]'\n-match 1 'b' '[a-c[:digit:]x-z]'\n-match 1 'y' '[a-c[:digit:]x-z]'\n-match 0 'q' '[a-c[:digit:]x-z]'\n-\n-# Additional tests, including some malformed wildmats\n-match 1 ']' '[\\\\-^]'\n-match 0 '[' '[\\\\-^]'\n-match 1 '-' '[\\-_]'\n-match 1 ']' '[\\]]'\n-match 0 '\\]' '[\\]]'\n-match 0 '\\' '[\\]]'\n-match 0 'ab' 'a[]b'\n-match 0 'a[]b' 'a[]b'\n-match 0 'ab[' 'ab['\n-match 0 'ab' '[!'\n-match 0 'ab' '[-'\n-match 1 '-' '[-]'\n-match 0 '-' '[a-'\n-match 0 '-' '[!a-'\n-match 1 '-' '[--A]'\n-match 1 '5' '[--A]'\n-match 1 ' ' '[ --]'\n-match 1 '$' '[ --]'\n-match 1 '-' '[ --]'\n-match 0 '0' '[ --]'\n-match 1 '-' '[---]'\n-match 1 '-' '[------]'\n-match 0 'j' '[a-e-n]'\n-match 1 '-' '[a-e-n]'\n-match 1 'a' '[!------]'\n-match 0 '[' '[]-a]'\n-match 1 '^' '[]-a]'\n-match 0 '^' '[!]-a]'\n-match 1 '[' '[!]-a]'\n-match 1 '^' '[a^bc]'\n-match 1 '-b]' '[a-]b]'\n-match 0 '\\' '[\\]'\n-match 1 '\\' '[\\\\]'\n-match 0 '\\' '[!\\\\]'\n-match 1 'G' '[A-\\\\]'\n-match 0 'aaabbb' 'b*a'\n-match 0 'aabcaa' '*ba*'\n-match 1 ',' '[,]'\n-match 1 ',' '[\\\\,]'\n-match 1 '\\' '[\\\\,]'\n-match 1 '-' '[,-.]'\n-match 0 '+' '[,-.]'\n-match 0 '-.]' '[,-.]'\n-match 1 '2' '[\\1-\\3]'\n-match 1 '3' '[\\1-\\3]'\n-match 0 '4' '[\\1-\\3]'\n-match 1 '\\' '[[-\\]]'\n-match 1 '[' '[[-\\]]'\n-match 1 ']' '[[-\\]]'\n-match 0 '-' '[[-\\]]'\n+wildtest 1 1 1 1 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n+wildtest 0 1 0 1 'a' '[[:digit:][:upper:][:space:]]'\n+wildtest 1 1 1 1 'A' '[[:digit:][:upper:][:space:]]'\n+wildtest 1 1 1 1 '1' '[[:digit:][:upper:][:space:]]'\n+wildtest 0 0 0 0 '1' '[[:digit:][:upper:][:spaci:]]'\n+wildtest 1 1 1 1 ' ' '[[:digit:][:upper:][:space:]]'\n+wildtest 0 0 0 0 '.' '[[:digit:][:upper:][:space:]]'\n+wildtest 1 1 1 1 '.' '[[:digit:][:punct:][:space:]]'\n+wildtest 1 1 1 1 '5' '[[:xdigit:]]'\n+wildtest 1 1 1 1 'f' '[[:xdigit:]]'\n+wildtest 1 1 1 1 'D' '[[:xdigit:]]'\n+wildtest 1 1 1 1 '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n+wildtest 1 1 1 1 '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n+wildtest 1 1 1 1 '5' '[a-c[:digit:]x-z]'\n+wildtest 1 1 1 1 'b' '[a-c[:digit:]x-z]'\n+wildtest 1 1 1 1 'y' '[a-c[:digit:]x-z]'\n+wildtest 0 0 0 0 'q' '[a-c[:digit:]x-z]'\n \n-# Test recursion and the abort code (use \"wildtest -i\" to see iteration counts)\n-match 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 1 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n-match 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n-match 0 foo '*/*/*'\n-match 0 foo/bar '*/*/*'\n-match 1 foo/bba/arr '*/*/*'\n-match 0 foo/bb/aa/rr '*/*/*'\n-match 1 foo/bb/aa/rr '**/**/**'\n-match 1 abcXdefXghi '*X*i'\n-match 0 ab/cXd/efXg/hi '*X*i'\n-match 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n-match 1 ab/cXd/efXg/hi '**/*X*/**/*i'\n+# Additional tests, including some malformed wildmatch patterns\n+wildtest 1 1 1 1 ']' '[\\\\-^]'\n+wildtest 0 0 0 0 '[' '[\\\\-^]'\n+wildtest 1 1 1 1 '-' '[\\-_]'\n+wildtest 1 1 1 1 ']' '[\\]]'\n+wildtest 0 0 0 0 '\\]' '[\\]]'\n+wildtest 0 0 0 0 '\\' '[\\]]'\n+wildtest 0 0 0 0 'ab' 'a[]b'\n+wildtest 0 0 0 0 'a[]b' 'a[]b'\n+wildtest 0 0 0 0 'ab[' 'ab['\n+wildtest 0 0 0 0 'ab' '[!'\n+wildtest 0 0 0 0 'ab' '[-'\n+wildtest 1 1 1 1 '-' '[-]'\n+wildtest 0 0 0 0 '-' '[a-'\n+wildtest 0 0 0 0 '-' '[!a-'\n+wildtest 1 1 1 1 '-' '[--A]'\n+wildtest 1 1 1 1 '5' '[--A]'\n+wildtest 1 1 1 1 ' ' '[ --]'\n+wildtest 1 1 1 1 '$' '[ --]'\n+wildtest 1 1 1 1 '-' '[ --]'\n+wildtest 0 0 0 0 '0' '[ --]'\n+wildtest 1 1 1 1 '-' '[---]'\n+wildtest 1 1 1 1 '-' '[------]'\n+wildtest 0 0 0 0 'j' '[a-e-n]'\n+wildtest 1 1 1 1 '-' '[a-e-n]'\n+wildtest 1 1 1 1 'a' '[!------]'\n+wildtest 0 0 0 0 '[' '[]-a]'\n+wildtest 1 1 1 1 '^' '[]-a]'\n+wildtest 0 0 0 0 '^' '[!]-a]'\n+wildtest 1 1 1 1 '[' '[!]-a]'\n+wildtest 1 1 1 1 '^' '[a^bc]'\n+wildtest 1 1 1 1 '-b]' '[a-]b]'\n+wildtest 0 0 0 0 '\\' '[\\]'\n+wildtest 1 1 1 1 '\\' '[\\\\]'\n+wildtest 0 0 0 0 '\\' '[!\\\\]'\n+wildtest 1 1 1 1 'G' '[A-\\\\]'\n+wildtest 0 0 0 0 'aaabbb' 'b*a'\n+wildtest 0 0 0 0 'aabcaa' '*ba*'\n+wildtest 1 1 1 1 ',' '[,]'\n+wildtest 1 1 1 1 ',' '[\\\\,]'\n+wildtest 1 1 1 1 '\\' '[\\\\,]'\n+wildtest 1 1 1 1 '-' '[,-.]'\n+wildtest 0 0 0 0 '+' '[,-.]'\n+wildtest 0 0 0 0 '-.]' '[,-.]'\n+wildtest 1 1 1 1 '2' '[\\1-\\3]'\n+wildtest 1 1 1 1 '3' '[\\1-\\3]'\n+wildtest 0 0 0 0 '4' '[\\1-\\3]'\n+wildtest 1 1 1 1 '\\' '[[-\\]]'\n+wildtest 1 1 1 1 '[' '[[-\\]]'\n+wildtest 1 1 1 1 ']' '[[-\\]]'\n+wildtest 0 0 0 0 '-' '[[-\\]]'\n \n-pathmatch 1 foo foo\n-pathmatch 0 foo fo\n-pathmatch 1 foo/bar foo/bar\n-pathmatch 1 foo/bar 'foo/*'\n-pathmatch 1 foo/bba/arr 'foo/*'\n-pathmatch 1 foo/bba/arr 'foo/**'\n-pathmatch 1 foo/bba/arr 'foo*'\n-pathmatch 1 foo/bba/arr 'foo**'\n-pathmatch 1 foo/bba/arr 'foo/*arr'\n-pathmatch 1 foo/bba/arr 'foo/**arr'\n-pathmatch 0 foo/bba/arr 'foo/*z'\n-pathmatch 0 foo/bba/arr 'foo/**z'\n-pathmatch 1 foo/bar 'foo?bar'\n-pathmatch 1 foo/bar 'foo[/]bar'\n-pathmatch 1 foo/bar 'foo[^a-z]bar'\n-pathmatch 0 foo '*/*/*'\n-pathmatch 0 foo/bar '*/*/*'\n-pathmatch 1 foo/bba/arr '*/*/*'\n-pathmatch 1 foo/bb/aa/rr '*/*/*'\n-pathmatch 1 abcXdefXghi '*X*i'\n-pathmatch 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n-pathmatch 1 ab/cXd/efXg/hi '*Xg*i'\n+# Test recursion\n+wildtest 1 1 1 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+wildtest 0 0 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+wildtest 0 0 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+wildtest 1 1 1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+wildtest 0 0 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+wildtest 1 1 1 1 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n+wildtest 0 0 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n+wildtest 0 0 0 0 foo '*/*/*'\n+wildtest 0 0 0 0 foo/bar '*/*/*'\n+wildtest 1 1 1 1 foo/bba/arr '*/*/*'\n+wildtest 0 0 1 1 foo/bb/aa/rr '*/*/*'\n+wildtest 1 1 1 1 foo/bb/aa/rr '**/**/**'\n+wildtest 1 1 1 1 abcXdefXghi '*X*i'\n+wildtest 0 0 1 1 ab/cXd/efXg/hi '*X*i'\n+wildtest 1 1 1 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n+wildtest 1 1 1 1 ab/cXd/efXg/hi '**/*X*/**/*i'\n \n-# Case-sensitivity features\n-match 0 'a' '[A-Z]'\n-match 1 'A' '[A-Z]'\n-match 0 'A' '[a-z]'\n-match 1 'a' '[a-z]'\n-match 0 'a' '[[:upper:]]'\n-match 1 'A' '[[:upper:]]'\n-match 0 'A' '[[:lower:]]'\n-match 1 'a' '[[:lower:]]'\n-match 0 'A' '[B-Za]'\n-match 1 'a' '[B-Za]'\n-match 0 'A' '[B-a]'\n-match 1 'a' '[B-a]'\n-match 0 'z' '[Z-y]'\n-match 1 'Z' '[Z-y]'\n+# Extra pathmatch tests\n+wildtest 0 0 0 0 foo fo\n+wildtest 1 1 1 1 foo/bar foo/bar\n+wildtest 1 1 1 1 foo/bar 'foo/*'\n+wildtest 0 0 1 1 foo/bba/arr 'foo/*'\n+wildtest 1 1 1 1 foo/bba/arr 'foo/**'\n+wildtest 0 0 1 1 foo/bba/arr 'foo*'\n+wildtest 0 0 1 1 foo/bba/arr 'foo**'\n+wildtest 0 0 1 1 foo/bba/arr 'foo/*arr'\n+wildtest 0 0 1 1 foo/bba/arr 'foo/**arr'\n+wildtest 0 0 0 0 foo/bba/arr 'foo/*z'\n+wildtest 0 0 0 0 foo/bba/arr 'foo/**z'\n+wildtest 0 0 1 1 foo/bar 'foo?bar'\n+wildtest 0 0 1 1 foo/bar 'foo[/]bar'\n+wildtest 0 0 1 1 foo/bar 'foo[^a-z]bar'\n+wildtest 0 0 1 1 ab/cXd/efXg/hi '*Xg*i'\n \n-imatch 1 'a' '[A-Z]'\n-imatch 1 'A' '[A-Z]'\n-imatch 1 'A' '[a-z]'\n-imatch 1 'a' '[a-z]'\n-imatch 1 'a' '[[:upper:]]'\n-imatch 1 'A' '[[:upper:]]'\n-imatch 1 'A' '[[:lower:]]'\n-imatch 1 'a' '[[:lower:]]'\n-imatch 1 'A' '[B-Za]'\n-imatch 1 'a' '[B-Za]'\n-imatch 1 'A' '[B-a]'\n-imatch 1 'a' '[B-a]'\n-imatch 1 'z' '[Z-y]'\n-imatch 1 'Z' '[Z-y]'\n+# Extra case-sensitivity tests\n+wildtest 0 1 0 1 'a' '[A-Z]'\n+wildtest 1 1 1 1 'A' '[A-Z]'\n+wildtest 0 1 0 1 'A' '[a-z]'\n+wildtest 1 1 1 1 'a' '[a-z]'\n+wildtest 0 1 0 1 'a' '[[:upper:]]'\n+wildtest 1 1 1 1 'A' '[[:upper:]]'\n+wildtest 0 1 0 1 'A' '[[:lower:]]'\n+wildtest 1 1 1 1 'a' '[[:lower:]]'\n+wildtest 0 1 0 1 'A' '[B-Za]'\n+wildtest 1 1 1 1 'a' '[B-Za]'\n+wildtest 0 1 0 1 'A' '[B-a]'\n+wildtest 1 1 1 1 'a' '[B-a]'\n+wildtest 0 1 0 1 'z' '[Z-y]'\n+wildtest 1 1 1 1 'Z' '[Z-y]'\n \n test_done\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335506","messageId":"20171228232823.14450-5-avarab@gmail.com","threadId":"47493","inReplyTo":"20171228232823.14450-1-avarab@gmail.com","subject":"[PATCH v3 4/7] wildmatch test: use a paranoia pattern from nul_match()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-28T23:28:20Z","receivedAt":"2017-12-28T23:28:58Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Use a pattern from the nul_match() function in t7008-grep-binary.sh to\nmake sure that we don't just fall through to the \"else\" if there's an\nunknown parameter.\n\nThis is something I added in commit 77f6f4406f (\"grep: add a test\nhelper function for less verbose -f \\0 tests\", 2017-05-20) to grep\ntests, which were modeled on these wildmatch tests, and I'm now\nporting back to the original wildmatch tests.\n\nI am not using the \"say '...'; exit 1\" pattern from t0000-basic.sh\nbecause if I fail I want to run the rest of the tests (unless under\n-i), and doing this makes sure we do that and don't exit right away\nwithout fully reporting our errors.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 15 ++++++++++++---\n 1 file changed, 12 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 19ea64bba9..9691d8eda3 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -10,10 +10,13 @@ match() {\n \t\ttest_expect_success \"wildmatch: match '$3' '$4'\" \"\n \t\t\ttest-wildmatch wildmatch '$3' '$4'\n \t\t\"\n-\telse\n+\telif test \"$1\" = 0\n+\tthen\n \t\ttest_expect_success \"wildmatch: no match '$3' '$4'\" \"\n \t\t\t! test-wildmatch wildmatch '$3' '$4'\n \t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n \tfi\n }\n \n@@ -23,10 +26,13 @@ imatch() {\n \t\ttest_expect_success \"iwildmatch: match '$2' '$3'\" \"\n \t\t\ttest-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n-\telse\n+\telif test \"$1\" = 0\n+\tthen\n \t\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n \t\t\t! test-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n \tfi\n }\n \n@@ -36,10 +42,13 @@ pathmatch() {\n \t\ttest_expect_success \"pathmatch: match '$2' '$3'\" \"\n \t\t\ttest-wildmatch pathmatch '$2' '$3'\n \t\t\"\n-\telse\n+\telif test \"$1\" = 0\n+\tthen\n \t\ttest_expect_success \"pathmatch: no match '$2' '$3'\" \"\n \t\t\t! test-wildmatch pathmatch '$2' '$3'\n \t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n \tfi\n }\n \n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335507","messageId":"20171228232823.14450-6-avarab@gmail.com","threadId":"47493","inReplyTo":"20171228232823.14450-1-avarab@gmail.com","subject":"[PATCH v3 5/7] wildmatch test: remove dead fnmatch() test code","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-28T23:28:21Z","receivedAt":"2017-12-28T23:29:00Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the unused fnmatch() test parameter from the wildmatch\ntest. The code that used to test this was removed in 70a8fc999d (\"stop\nusing fnmatch (either native or compat)\", 2014-02-15).\n\nAs a --word-diff shows the only change to the body of the tests is the\nremoval of the second out of four parameters passed to match().\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 356 +++++++++++++++++++++++++--------------------------\n 1 file changed, 178 insertions(+), 178 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 9691d8eda3..2f8a681c72 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -7,13 +7,13 @@ test_description='wildmatch tests'\n match() {\n \tif test \"$1\" = 1\n \tthen\n-\t\ttest_expect_success \"wildmatch: match '$3' '$4'\" \"\n-\t\t\ttest-wildmatch wildmatch '$3' '$4'\n+\t\ttest_expect_success \"wildmatch: match '$2' '$3'\" \"\n+\t\t\ttest-wildmatch wildmatch '$2' '$3'\n \t\t\"\n \telif test \"$1\" = 0\n \tthen\n-\t\ttest_expect_success \"wildmatch: no match '$3' '$4'\" \"\n-\t\t\t! test-wildmatch wildmatch '$3' '$4'\n+\t\ttest_expect_success \"wildmatch: no match '$2' '$3'\" \"\n+\t\t\t! test-wildmatch wildmatch '$2' '$3'\n \t\t\"\n \telse\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n@@ -53,176 +53,176 @@ pathmatch() {\n }\n \n # Basic wildmat features\n-match 1 1 foo foo\n-match 0 0 foo bar\n-match 1 1 '' \"\"\n-match 1 1 foo '???'\n-match 0 0 foo '??'\n-match 1 1 foo '*'\n-match 1 1 foo 'f*'\n-match 0 0 foo '*f'\n-match 1 1 foo '*foo*'\n-match 1 1 foobar '*ob*a*r*'\n-match 1 1 aaaaaaabababab '*ab'\n-match 1 1 'foo*' 'foo\\*'\n-match 0 0 foobar 'foo\\*bar'\n-match 1 1 'f\\oo' 'f\\\\oo'\n-match 1 1 ball '*[al]?'\n-match 0 0 ten '[ten]'\n-match 0 1 ten '**[!te]'\n-match 0 0 ten '**[!ten]'\n-match 1 1 ten 't[a-g]n'\n-match 0 0 ten 't[!a-g]n'\n-match 1 1 ton 't[!a-g]n'\n-match 1 1 ton 't[^a-g]n'\n-match 1 x 'a]b' 'a[]]b'\n-match 1 x a-b 'a[]-]b'\n-match 1 x 'a]b' 'a[]-]b'\n-match 0 x aab 'a[]-]b'\n-match 1 x aab 'a[]a-]b'\n-match 1 1 ']' ']'\n+match 1 foo foo\n+match 0 foo bar\n+match 1 '' \"\"\n+match 1 foo '???'\n+match 0 foo '??'\n+match 1 foo '*'\n+match 1 foo 'f*'\n+match 0 foo '*f'\n+match 1 foo '*foo*'\n+match 1 foobar '*ob*a*r*'\n+match 1 aaaaaaabababab '*ab'\n+match 1 'foo*' 'foo\\*'\n+match 0 foobar 'foo\\*bar'\n+match 1 'f\\oo' 'f\\\\oo'\n+match 1 ball '*[al]?'\n+match 0 ten '[ten]'\n+match 0 ten '**[!te]'\n+match 0 ten '**[!ten]'\n+match 1 ten 't[a-g]n'\n+match 0 ten 't[!a-g]n'\n+match 1 ton 't[!a-g]n'\n+match 1 ton 't[^a-g]n'\n+match 1 'a]b' 'a[]]b'\n+match 1 a-b 'a[]-]b'\n+match 1 'a]b' 'a[]-]b'\n+match 0 aab 'a[]-]b'\n+match 1 aab 'a[]a-]b'\n+match 1 ']' ']'\n \n # Extended slash-matching features\n-match 0 0 'foo/baz/bar' 'foo*bar'\n-match 0 0 'foo/baz/bar' 'foo**bar'\n-match 0 1 'foobazbar' 'foo**bar'\n-match 1 1 'foo/baz/bar' 'foo/**/bar'\n-match 1 0 'foo/baz/bar' 'foo/**/**/bar'\n-match 1 0 'foo/b/a/z/bar' 'foo/**/bar'\n-match 1 0 'foo/b/a/z/bar' 'foo/**/**/bar'\n-match 1 0 'foo/bar' 'foo/**/bar'\n-match 1 0 'foo/bar' 'foo/**/**/bar'\n-match 0 0 'foo/bar' 'foo?bar'\n-match 0 0 'foo/bar' 'foo[/]bar'\n-match 0 0 'foo/bar' 'foo[^a-z]bar'\n-match 0 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 0 'foo' '**/foo'\n-match 1 x 'XXX/foo' '**/foo'\n-match 1 0 'bar/baz/foo' '**/foo'\n-match 0 0 'bar/baz/foo' '*/foo'\n-match 0 0 'foo/bar/baz' '**/bar*'\n-match 1 0 'deep/foo/bar/baz' '**/bar/*'\n-match 0 0 'deep/foo/bar/baz/' '**/bar/*'\n-match 1 0 'deep/foo/bar/baz/' '**/bar/**'\n-match 0 0 'deep/foo/bar' '**/bar/*'\n-match 1 0 'deep/foo/bar/' '**/bar/**'\n-match 0 0 'foo/bar/baz' '**/bar**'\n-match 1 0 'foo/bar/baz/x' '*/bar/**'\n-match 0 0 'deep/foo/bar/baz/x' '*/bar/**'\n-match 1 0 'deep/foo/bar/baz/x' '**/bar/*/*'\n+match 0 'foo/baz/bar' 'foo*bar'\n+match 0 'foo/baz/bar' 'foo**bar'\n+match 0 'foobazbar' 'foo**bar'\n+match 1 'foo/baz/bar' 'foo/**/bar'\n+match 1 'foo/baz/bar' 'foo/**/**/bar'\n+match 1 'foo/b/a/z/bar' 'foo/**/bar'\n+match 1 'foo/b/a/z/bar' 'foo/**/**/bar'\n+match 1 'foo/bar' 'foo/**/bar'\n+match 1 'foo/bar' 'foo/**/**/bar'\n+match 0 'foo/bar' 'foo?bar'\n+match 0 'foo/bar' 'foo[/]bar'\n+match 0 'foo/bar' 'foo[^a-z]bar'\n+match 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+match 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+match 1 'foo' '**/foo'\n+match 1 'XXX/foo' '**/foo'\n+match 1 'bar/baz/foo' '**/foo'\n+match 0 'bar/baz/foo' '*/foo'\n+match 0 'foo/bar/baz' '**/bar*'\n+match 1 'deep/foo/bar/baz' '**/bar/*'\n+match 0 'deep/foo/bar/baz/' '**/bar/*'\n+match 1 'deep/foo/bar/baz/' '**/bar/**'\n+match 0 'deep/foo/bar' '**/bar/*'\n+match 1 'deep/foo/bar/' '**/bar/**'\n+match 0 'foo/bar/baz' '**/bar**'\n+match 1 'foo/bar/baz/x' '*/bar/**'\n+match 0 'deep/foo/bar/baz/x' '*/bar/**'\n+match 1 'deep/foo/bar/baz/x' '**/bar/*/*'\n \n # Various additional tests\n-match 0 0 'acrt' 'a[c-c]st'\n-match 1 1 'acrt' 'a[c-c]rt'\n-match 0 0 ']' '[!]-]'\n-match 1 x 'a' '[!]-]'\n-match 0 0 '' '\\'\n-match 0 x '\\' '\\'\n-match 0 x 'XXX/\\' '*/\\'\n-match 1 x 'XXX/\\' '*/\\\\'\n-match 1 1 'foo' 'foo'\n-match 1 1 '@foo' '@foo'\n-match 0 0 'foo' '@foo'\n-match 1 1 '[ab]' '\\[ab]'\n-match 1 1 '[ab]' '[[]ab]'\n-match 1 x '[ab]' '[[:]ab]'\n-match 0 x '[ab]' '[[::]ab]'\n-match 1 x '[ab]' '[[:digit]ab]'\n-match 1 x '[ab]' '[\\[:]ab]'\n-match 1 1 '?a?b' '\\??\\?b'\n-match 1 1 'abc' '\\a\\b\\c'\n-match 0 0 'foo' ''\n-match 1 0 'foo/bar/baz/to' '**/t[o]'\n+match 0 'acrt' 'a[c-c]st'\n+match 1 'acrt' 'a[c-c]rt'\n+match 0 ']' '[!]-]'\n+match 1 'a' '[!]-]'\n+match 0 '' '\\'\n+match 0 '\\' '\\'\n+match 0 'XXX/\\' '*/\\'\n+match 1 'XXX/\\' '*/\\\\'\n+match 1 'foo' 'foo'\n+match 1 '@foo' '@foo'\n+match 0 'foo' '@foo'\n+match 1 '[ab]' '\\[ab]'\n+match 1 '[ab]' '[[]ab]'\n+match 1 '[ab]' '[[:]ab]'\n+match 0 '[ab]' '[[::]ab]'\n+match 1 '[ab]' '[[:digit]ab]'\n+match 1 '[ab]' '[\\[:]ab]'\n+match 1 '?a?b' '\\??\\?b'\n+match 1 'abc' '\\a\\b\\c'\n+match 0 'foo' ''\n+match 1 'foo/bar/baz/to' '**/t[o]'\n \n # Character class tests\n-match 1 x 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n-match 0 x 'a' '[[:digit:][:upper:][:space:]]'\n-match 1 x 'A' '[[:digit:][:upper:][:space:]]'\n-match 1 x '1' '[[:digit:][:upper:][:space:]]'\n-match 0 x '1' '[[:digit:][:upper:][:spaci:]]'\n-match 1 x ' ' '[[:digit:][:upper:][:space:]]'\n-match 0 x '.' '[[:digit:][:upper:][:space:]]'\n-match 1 x '.' '[[:digit:][:punct:][:space:]]'\n-match 1 x '5' '[[:xdigit:]]'\n-match 1 x 'f' '[[:xdigit:]]'\n-match 1 x 'D' '[[:xdigit:]]'\n-match 1 x '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n-match 1 x '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n-match 1 x '5' '[a-c[:digit:]x-z]'\n-match 1 x 'b' '[a-c[:digit:]x-z]'\n-match 1 x 'y' '[a-c[:digit:]x-z]'\n-match 0 x 'q' '[a-c[:digit:]x-z]'\n+match 1 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n+match 0 'a' '[[:digit:][:upper:][:space:]]'\n+match 1 'A' '[[:digit:][:upper:][:space:]]'\n+match 1 '1' '[[:digit:][:upper:][:space:]]'\n+match 0 '1' '[[:digit:][:upper:][:spaci:]]'\n+match 1 ' ' '[[:digit:][:upper:][:space:]]'\n+match 0 '.' '[[:digit:][:upper:][:space:]]'\n+match 1 '.' '[[:digit:][:punct:][:space:]]'\n+match 1 '5' '[[:xdigit:]]'\n+match 1 'f' '[[:xdigit:]]'\n+match 1 'D' '[[:xdigit:]]'\n+match 1 '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n+match 1 '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n+match 1 '5' '[a-c[:digit:]x-z]'\n+match 1 'b' '[a-c[:digit:]x-z]'\n+match 1 'y' '[a-c[:digit:]x-z]'\n+match 0 'q' '[a-c[:digit:]x-z]'\n \n # Additional tests, including some malformed wildmats\n-match 1 x ']' '[\\\\-^]'\n-match 0 0 '[' '[\\\\-^]'\n-match 1 x '-' '[\\-_]'\n-match 1 x ']' '[\\]]'\n-match 0 0 '\\]' '[\\]]'\n-match 0 0 '\\' '[\\]]'\n-match 0 0 'ab' 'a[]b'\n-match 0 x 'a[]b' 'a[]b'\n-match 0 x 'ab[' 'ab['\n-match 0 0 'ab' '[!'\n-match 0 0 'ab' '[-'\n-match 1 1 '-' '[-]'\n-match 0 0 '-' '[a-'\n-match 0 0 '-' '[!a-'\n-match 1 x '-' '[--A]'\n-match 1 x '5' '[--A]'\n-match 1 1 ' ' '[ --]'\n-match 1 1 '$' '[ --]'\n-match 1 1 '-' '[ --]'\n-match 0 0 '0' '[ --]'\n-match 1 x '-' '[---]'\n-match 1 x '-' '[------]'\n-match 0 0 'j' '[a-e-n]'\n-match 1 x '-' '[a-e-n]'\n-match 1 x 'a' '[!------]'\n-match 0 0 '[' '[]-a]'\n-match 1 x '^' '[]-a]'\n-match 0 0 '^' '[!]-a]'\n-match 1 x '[' '[!]-a]'\n-match 1 1 '^' '[a^bc]'\n-match 1 x '-b]' '[a-]b]'\n-match 0 0 '\\' '[\\]'\n-match 1 1 '\\' '[\\\\]'\n-match 0 0 '\\' '[!\\\\]'\n-match 1 1 'G' '[A-\\\\]'\n-match 0 0 'aaabbb' 'b*a'\n-match 0 0 'aabcaa' '*ba*'\n-match 1 1 ',' '[,]'\n-match 1 1 ',' '[\\\\,]'\n-match 1 1 '\\' '[\\\\,]'\n-match 1 1 '-' '[,-.]'\n-match 0 0 '+' '[,-.]'\n-match 0 0 '-.]' '[,-.]'\n-match 1 1 '2' '[\\1-\\3]'\n-match 1 1 '3' '[\\1-\\3]'\n-match 0 0 '4' '[\\1-\\3]'\n-match 1 1 '\\' '[[-\\]]'\n-match 1 1 '[' '[[-\\]]'\n-match 1 1 ']' '[[-\\]]'\n-match 0 0 '-' '[[-\\]]'\n+match 1 ']' '[\\\\-^]'\n+match 0 '[' '[\\\\-^]'\n+match 1 '-' '[\\-_]'\n+match 1 ']' '[\\]]'\n+match 0 '\\]' '[\\]]'\n+match 0 '\\' '[\\]]'\n+match 0 'ab' 'a[]b'\n+match 0 'a[]b' 'a[]b'\n+match 0 'ab[' 'ab['\n+match 0 'ab' '[!'\n+match 0 'ab' '[-'\n+match 1 '-' '[-]'\n+match 0 '-' '[a-'\n+match 0 '-' '[!a-'\n+match 1 '-' '[--A]'\n+match 1 '5' '[--A]'\n+match 1 ' ' '[ --]'\n+match 1 '$' '[ --]'\n+match 1 '-' '[ --]'\n+match 0 '0' '[ --]'\n+match 1 '-' '[---]'\n+match 1 '-' '[------]'\n+match 0 'j' '[a-e-n]'\n+match 1 '-' '[a-e-n]'\n+match 1 'a' '[!------]'\n+match 0 '[' '[]-a]'\n+match 1 '^' '[]-a]'\n+match 0 '^' '[!]-a]'\n+match 1 '[' '[!]-a]'\n+match 1 '^' '[a^bc]'\n+match 1 '-b]' '[a-]b]'\n+match 0 '\\' '[\\]'\n+match 1 '\\' '[\\\\]'\n+match 0 '\\' '[!\\\\]'\n+match 1 'G' '[A-\\\\]'\n+match 0 'aaabbb' 'b*a'\n+match 0 'aabcaa' '*ba*'\n+match 1 ',' '[,]'\n+match 1 ',' '[\\\\,]'\n+match 1 '\\' '[\\\\,]'\n+match 1 '-' '[,-.]'\n+match 0 '+' '[,-.]'\n+match 0 '-.]' '[,-.]'\n+match 1 '2' '[\\1-\\3]'\n+match 1 '3' '[\\1-\\3]'\n+match 0 '4' '[\\1-\\3]'\n+match 1 '\\' '[[-\\]]'\n+match 1 '[' '[[-\\]]'\n+match 1 ']' '[[-\\]]'\n+match 0 '-' '[[-\\]]'\n \n # Test recursion and the abort code (use \"wildtest -i\" to see iteration counts)\n-match 1 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 1 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n-match 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n-match 0 x foo '*/*/*'\n-match 0 x foo/bar '*/*/*'\n-match 1 x foo/bba/arr '*/*/*'\n-match 0 x foo/bb/aa/rr '*/*/*'\n-match 1 x foo/bb/aa/rr '**/**/**'\n-match 1 x abcXdefXghi '*X*i'\n-match 0 x ab/cXd/efXg/hi '*X*i'\n-match 1 x ab/cXd/efXg/hi '*/*X*/*/*i'\n-match 1 x ab/cXd/efXg/hi '**/*X*/**/*i'\n+match 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+match 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+match 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+match 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+match 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+match 1 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n+match 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n+match 0 foo '*/*/*'\n+match 0 foo/bar '*/*/*'\n+match 1 foo/bba/arr '*/*/*'\n+match 0 foo/bb/aa/rr '*/*/*'\n+match 1 foo/bb/aa/rr '**/**/**'\n+match 1 abcXdefXghi '*X*i'\n+match 0 ab/cXd/efXg/hi '*X*i'\n+match 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n+match 1 ab/cXd/efXg/hi '**/*X*/**/*i'\n \n pathmatch 1 foo foo\n pathmatch 0 foo fo\n@@ -248,20 +248,20 @@ pathmatch 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n pathmatch 1 ab/cXd/efXg/hi '*Xg*i'\n \n # Case-sensitivity features\n-match 0 x 'a' '[A-Z]'\n-match 1 x 'A' '[A-Z]'\n-match 0 x 'A' '[a-z]'\n-match 1 x 'a' '[a-z]'\n-match 0 x 'a' '[[:upper:]]'\n-match 1 x 'A' '[[:upper:]]'\n-match 0 x 'A' '[[:lower:]]'\n-match 1 x 'a' '[[:lower:]]'\n-match 0 x 'A' '[B-Za]'\n-match 1 x 'a' '[B-Za]'\n-match 0 x 'A' '[B-a]'\n-match 1 x 'a' '[B-a]'\n-match 0 x 'z' '[Z-y]'\n-match 1 x 'Z' '[Z-y]'\n+match 0 'a' '[A-Z]'\n+match 1 'A' '[A-Z]'\n+match 0 'A' '[a-z]'\n+match 1 'a' '[a-z]'\n+match 0 'a' '[[:upper:]]'\n+match 1 'A' '[[:upper:]]'\n+match 0 'A' '[[:lower:]]'\n+match 1 'a' '[[:lower:]]'\n+match 0 'A' '[B-Za]'\n+match 1 'a' '[B-Za]'\n+match 0 'A' '[B-a]'\n+match 1 'a' '[B-a]'\n+match 0 'z' '[Z-y]'\n+match 1 'Z' '[Z-y]'\n \n imatch 1 'a' '[A-Z]'\n imatch 1 'A' '[A-Z]'\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335508","messageId":"20171228232823.14450-8-avarab@gmail.com","threadId":"47493","inReplyTo":"20171228232823.14450-1-avarab@gmail.com","subject":"[PATCH v3 7/7] wildmatch test: create & test files on disk in addition to in-memory","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-28T23:28:23Z","receivedAt":"2017-12-28T23:29:02Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"There has never been any full roundtrip testing of what git-ls-files\nand other functions that use wildmatch() actually do, rather we've\nbeen satisfied with just testing the underlying C function.\n\nDue to git-ls-files and friends having their own codepaths before they\ncall wildmatch() there's sometimes differences in the behavior between\nthe two, and even when we test for those (as with\n9e4e8a64c2 (\"pathspec: die on empty strings as pathspec\", 2017-06-06))\nthere was no one place where you can review how these two modes\ndiffer.\n\nNow there is. We now attempt to create a file called $haystack and\nmatch $needle against it for each pair of $needle and $haystack that\nwe were passing to test-wildmatch.\n\nIf we can't create the file we skip the test. This ensures that we can\nrun this on all platforms and not maintain some infinitely growing\nwhitelist of e.g. platforms that don't support certain characters in\nfilenames.\n\nAs a result of doing this we can now see the cases where these two\nways of testing wildmatch differ:\n\n * Creating a file called 'a[]b' and running ls-files 'a[]b' will show\n   that file, but wildmatch(\"a[]b\", \"a[]b\") will not match\n\n * wildmatch() won't match a file called \\ against \\, but ls-files\n   will.\n\n * `git --glob-pathspecs ls-files 'foo**'` will match a file\n   'foo/bba/arr', but wildmatch won't, however pathmatch will.\n\n   This seems like a bug to me, the two are otherwise equivalent as\n   these tests show.\n\nThis also reveals the case discussed in 9e4e8a64c2 above, where '' is\nnow an error as far as ls-files is concerned, but wildmatch() itself\nhappily accepts it.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 283 +++++++++++++++++++++++++++++++++++++++++++++++++--\n 1 file changed, 272 insertions(+), 11 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 06db053ae2..d7aa7eb5fe 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -4,14 +4,95 @@ test_description='wildmatch tests'\n \n . ./test-lib.sh\n \n+create_test_file() {\n+\tfile=$1\n+\n+\tcase $file in\n+\t# `touch .` will succeed but obviously not do what we intend\n+\t# here.\n+\t\".\")\n+\t\treturn 1\n+\t\t;;\n+\t# We cannot create a file with an empty filename.\n+\t\"\")\n+\t\treturn 1\n+\t\t;;\n+\t# The tests that are testing that e.g. foo//bar is matched by\n+\t# foo/*/bar can't be tested on filesystems since there's no\n+\t# way we're getting a double slash.\n+\t*//*)\n+\t\treturn 1\n+\t\t;;\n+\t# When testing the difference between foo/bar and foo/bar/ we\n+\t# can't test the latter.\n+\t*/)\n+\t\treturn 1\n+\t\t;;\n+\tesac\n+\n+\t# Turn foo/bar/baz into foo/bar to create foo/bar as a\n+\t# directory structure.\n+\tdirs=${file%/*}\n+\n+\t# We touch \"./$file\" instead of \"$file\" because even an\n+\t# escaped \"touch -- -\" means get arguments from stdin.\n+\tif test \"$file\" != \"$dirs\"\n+\tthen\n+\t\tmkdir -p -- \"$dirs\" &&\n+\t\ttouch -- \"./$file\" &&\n+\t\treturn 0\n+\telse\n+\t\ttouch -- \"./$file\" &&\n+\t\treturn 0\n+\tfi\n+\treturn 1\n+}\n+\n+wildtest_file_setup() {\n+\ttest_when_finished \"\n+\t\trm -rf -- * &&\n+\t\tgit reset\n+\t\" &&\n+\tgit add -A &&\n+\t>expect.err\n+}\n+\n+wildtest_stdout_stderr_cmp() {\n+\ttr -d '\\0' <actual.raw >actual &&\n+\ttest_cmp expect.err actual.err &&\n+\ttest_cmp expect actual\n+}\n+\n wildtest() {\n-\tmatch_w_glob=$1\n-\tmatch_w_globi=$2\n-\tmatch_w_pathmatch=$3\n-\tmatch_w_pathmatchi=$4\n-\ttext=$5\n-\tpattern=$6\n+\tif test \"$#\" = 6\n+\tthen\n+\t\t# When test-wildmatch and git ls-files produce the same\n+\t\t# result.\n+\t\tmatch_w_glob=$1\n+\t\tmatch_f_w_glob=$match_w_glob\n+\t\tmatch_w_globi=$2\n+\t\tmatch_f_w_globi=$match_w_globi\n+\t\tmatch_w_pathmatch=$3\n+\t\tmatch_f_w_pathmatch=$match_w_pathmatch\n+\t\tmatch_w_pathmatchi=$4\n+\t\tmatch_f_w_pathmatchi=$match_w_pathmatchi\n+\t\ttext=$5\n+\t\tpattern=$6\n+\telif test \"$#\" = 10\n+\tthen\n+\t\tmatch_w_glob=$1\n+\t\tmatch_w_globi=$2\n+\t\tmatch_w_pathmatch=$3\n+\t\tmatch_w_pathmatchi=$4\n+\t\tmatch_f_w_glob=$5\n+\t\tmatch_f_w_globi=$6\n+\t\tmatch_f_w_pathmatch=$7\n+\t\tmatch_f_w_pathmatchi=$8\n+\t\ttext=$9\n+\t\tpattern=$10\n+\tfi\n \n+\t# $1: Case sensitive glob match: test-wildmatch\n \tif test \"$match_w_glob\" = 1\n \tthen\n \t\ttest_expect_success \"wildmatch: match '$text' '$pattern'\" \"\n@@ -26,6 +107,50 @@ wildtest() {\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_glob\" 'false'\n \tfi\n \n+\t# $1: Case sensitive glob match: ls-files\n+\tif test \"$match_f_w_glob\" = 'E'\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"wildmatch(ls): match dies on '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\ttest_must_fail git --glob-pathspecs ls-files -z -- '$pattern'\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_glob\" = 1\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"wildmatch(ls): match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\tgit --glob-pathspecs ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_glob\" = 0\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"wildmatch(ls): no match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\t>expect &&\n+\t\t\t\tgit --glob-pathspecs ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): no match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_f_w_glob\" 'false'\n+\tfi\n+\n+\t# $2: Case insensitive glob match: test-wildmatch\n \tif test \"$match_w_globi\" = 1\n \tthen\n \t\ttest_expect_success \"iwildmatch: match '$text' '$pattern'\" \"\n@@ -40,6 +165,50 @@ wildtest() {\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_globi\" 'false'\n \tfi\n \n+\t# $2: Case insensitive glob match: ls-files\n+\tif test \"$match_f_w_globi\" = 'E'\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"iwildmatch(ls): match dies on '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\ttest_must_fail git --glob-pathspecs --icase-pathspecs ls-files -z -- '$pattern'\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_globi\" = 1\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"iwildmatch(ls): match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\tgit --glob-pathspecs --icase-pathspecs ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"iwildmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_globi\" = 0\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"iwildmatch(ls): no match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\t>expect &&\n+\t\t\t\tgit --glob-pathspecs --icase-pathspecs ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"iwildmatch(ls): no match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_f_w_globi\" 'false'\n+\tfi\n+\n+\t# $3: Case sensitive path match: test-wildmatch\n \tif test \"$match_w_pathmatch\" = 1\n \tthen\n \t\ttest_expect_success \"pathmatch: match '$text' '$pattern'\" \"\n@@ -54,6 +223,50 @@ wildtest() {\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_pathmatch\" 'false'\n \tfi\n \n+\t# $4: Case sensitive path match: ls-files\n+\tif test \"$match_f_w_pathmatch\" = 'E'\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"pathmatch(ls): match dies on '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\ttest_must_fail git ls-files -z -- '$pattern'\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_pathmatch\" = 1\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"pathmatch(ls): match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\tgit ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_pathmatch\" = 0\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"pathmatch(ls): no match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\t>expect &&\n+\t\t\t\tgit ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): no match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_f_w_pathmatch\" 'false'\n+\tfi\n+\n+\t# $4: Case insensitive path match: test-wildmatch\n \tif test \"$match_w_pathmatchi\" = 1\n \tthen\n \t\ttest_expect_success \"ipathmatch: match '$text' '$pattern'\" \"\n@@ -67,6 +280,49 @@ wildtest() {\n \telse\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_pathmatchi\" 'false'\n \tfi\n+\n+\t# $4: Case insensitive path match: ls-files\n+\tif test \"$match_f_w_pathmatchi\" = 'E'\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"ipathmatch(ls): match dies on '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\ttest_must_fail git --icase-pathspecs ls-files -z -- '$pattern'\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_pathmatchi\" = 1\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"ipathmatch(ls): match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\tgit --icase-pathspecs ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"ipathmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_pathmatchi\" = 0\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"ipathmatch(ls): no match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\t>expect &&\n+\t\t\t\tgit ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"ipathmatch(ls): no match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_f_w_pathmatchi\" 'false'\n+\tfi\n }\n \n # Basic wildmatch features\n@@ -135,7 +391,8 @@ wildtest 1 1 1 1 'acrt' 'a[c-c]rt'\n wildtest 0 0 0 0 ']' '[!]-]'\n wildtest 1 1 1 1 'a' '[!]-]'\n wildtest 0 0 0 0 '' '\\'\n-wildtest 0 0 0 0 '\\' '\\'\n+wildtest 0 0 0 0 \\\n+\t 1 1 1 1 '\\' '\\'\n wildtest 0 0 0 0 'XXX/\\' '*/\\'\n wildtest 1 1 1 1 'XXX/\\' '*/\\\\'\n wildtest 1 1 1 1 'foo' 'foo'\n@@ -149,7 +406,8 @@ wildtest 1 1 1 1 '[ab]' '[[:digit]ab]'\n wildtest 1 1 1 1 '[ab]' '[\\[:]ab]'\n wildtest 1 1 1 1 '?a?b' '\\??\\?b'\n wildtest 1 1 1 1 'abc' '\\a\\b\\c'\n-wildtest 0 0 0 0 'foo' ''\n+wildtest 0 0 0 0 \\\n+\t E E E E 'foo' ''\n wildtest 1 1 1 1 'foo/bar/baz/to' '**/t[o]'\n \n # Character class tests\n@@ -179,8 +437,10 @@ wildtest 1 1 1 1 ']' '[\\]]'\n wildtest 0 0 0 0 '\\]' '[\\]]'\n wildtest 0 0 0 0 '\\' '[\\]]'\n wildtest 0 0 0 0 'ab' 'a[]b'\n-wildtest 0 0 0 0 'a[]b' 'a[]b'\n-wildtest 0 0 0 0 'ab[' 'ab['\n+wildtest 0 0 0 0 \\\n+\t 1 1 1 1 'a[]b' 'a[]b'\n+wildtest 0 0 0 0 \\\n+\t 1 1 1 1 'ab[' 'ab['\n wildtest 0 0 0 0 'ab' '[!'\n wildtest 0 0 0 0 'ab' '[-'\n wildtest 1 1 1 1 '-' '[-]'\n@@ -248,7 +508,8 @@ wildtest 1 1 1 1 foo/bar 'foo/*'\n wildtest 0 0 1 1 foo/bba/arr 'foo/*'\n wildtest 1 1 1 1 foo/bba/arr 'foo/**'\n wildtest 0 0 1 1 foo/bba/arr 'foo*'\n-wildtest 0 0 1 1 foo/bba/arr 'foo**'\n+wildtest 0 0 1 1 \\\n+\t 1 1 1 1 foo/bba/arr 'foo**'\n wildtest 0 0 1 1 foo/bba/arr 'foo/*arr'\n wildtest 0 0 1 1 foo/bba/arr 'foo/**arr'\n wildtest 0 0 0 0 foo/bba/arr 'foo/*z'\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335509","messageId":"87a7y28lch.fsf@evledraar.gmail.com","threadId":"47493","inReplyTo":"xmqqr2reii4u.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2 0/7] increase wildmatch test coverage","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-28T23:49:02Z","receivedAt":"2017-12-28T23:49:11Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Thu, Dec 28 2017, Junio C. Hamano jotted:\n\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>\n>> This v2 addresses comments by Johannes Sixt in\n>> <8f4cdb23-8e2e-144a-1f70-99776b027166@kdbg.org> and there's osme other\n>> cleanups as noted below.\n>\n> One thing I found \"interesting\" (because it is usually the other way\n> around) is that about two dozens of the tests in this fail when your\n> shell is bash and all of them pass when your shell is dash.\n\nI sent out v3 before seeing this. I can reproduce this and will send a\nv4 with a fix.\n"},{"id":"335510","messageId":"878tdm8k2d.fsf@evledraar.gmail.com","threadId":"47493","inReplyTo":"20171228232823.14450-8-avarab@gmail.com","subject":"Re: [PATCH v3 7/7] wildmatch test: create & test files on disk in addition to in-memory","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-12-29T00:16:42Z","receivedAt":"2017-12-29T00:16:49Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Thu, Dec 28 2017, Ævar Arnfjörð Bjarmason jotted:\n\n> +\t\tpattern=$10\n\nJunio, in lie of me spamming the list too much, do you mind squashing\nthis into this (if no further issues arise):\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex d7aa7eb5fe..f985139b6f 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -89,7 +89,7 @@ wildtest() {\n                match_f_w_pathmatch=$7\n                match_f_w_pathmatchi=$8\n                text=$9\n-               pattern=$10\n+               pattern=${10}\n        fi\n\n        # $1: Case sensitive glob match: test-wildmatch\n\nWith this the tests pass on both bash & dash.\n"},{"id":"335714","messageId":"20180103130232.GD29210@dinwoodie.org","threadId":"47493","inReplyTo":"20171225002835.29005-8-avarab@gmail.com","subject":"Re: [PATCH v2 7/7] wildmatch test: create & test files on disk in addition to in-memory","fromName":"Adam Dinwoodie","fromEmail":"adam@dinwoodie.org","sentAt":"2018-01-03T13:02:32Z","receivedAt":"2018-01-03T13:02:42Z","isPatch":true,"sender":{"key":"adam@dinwoodie.org","avatar":"https://avatars.githubusercontent.com/u/1397507?v=4"},"body":"On Monday 25 December 2017 at 12:28 am +0000, Ævar Arnfjörð Bjarmason wrote:\n> There has never been any full roundtrip testing of what git-ls-files\n> and other functions that use wildmatch() actually do, rather we've\n> been satisfied with just testing the underlying C function.\n> \n> Due to git-ls-files and friends having their own codepaths before they\n> call wildmatch() there's sometimes differences in the behavior between\n> the two, and even when we test for those (as with\n> 9e4e8a64c2 (\"pathspec: die on empty strings as pathspec\", 2017-06-06))\n> there was no one place where you can review how these two modes\n> differ.\n> \n> Now there is. We now attempt to create a file called $haystack and\n> match $needle against it for each pair of $needle and $haystack that\n> we were passing to test-wildmatch.\n> \n> If we can't create the file we skip the test. This ensures that we can\n> run this on all platforms and not maintain some infinitely growing\n> whitelist of e.g. platforms that don't support certain characters in\n> filenames.\n> \n> As a result of doing this we can now see the cases where these two\n> ways of testing wildmatch differ:\n> \n>  * Creating a file called 'a[]b' and running ls-files 'a[]b' will show\n>    that file, but wildmatch(\"a[]b\", \"a[]b\") will not match\n> \n>  * wildmatch() won't match a file called \\ against \\, but ls-files\n>    will.\n> \n>  * `git --glob-pathspecs ls-files 'foo**'` will match a file\n>    'foo/bba/arr', but wildmatch won't, however pathmatch will.\n> \n>    This seems like a bug to me, the two are otherwise equivalent as\n>    these tests show.\n> \n> This also reveals the case discussed in 9e4e8a64c2 above, where '' is\n> now an error as far as ls-files is concerned, but wildmatch() itself\n> happily accepts it.\n> \n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n\nI'm seeing this test script failing on the pu branch as a result of this\ncommit when building on Cygwin.  Specifically, the test fails at\n9d45e1ca4 (\"Merge branch 'bw/oidmap-autoinit' into pu\", 2017-12-28), and\nbisecting points the blame at 2ee0c785a (\"wildmatch test: create & test\nfiles on disk in addition to in-memory\", 2017-12-25).\n\nI've copied the verbose error output for the first error below, and\nuploaded the full output, including verbose and trace output for the\nunexpectedly failing tests, at [0].  (With 42 failures among 1512 tests,\nthere's a lot of it, so I didn't want to include it in an email.)\n\n    expecting success:\n                                    wildtest_file_setup &&\n                                    printf '%s' '\\' >expect &&\n                                    git --glob-pathspecs ls-files -z -- '00' >actual.raw 2>actual.err &&\n                                    wildtest_stdout_stderr_cmp\n    \n    ++ wildtest_file_setup\n    ++ test_when_finished '\n                    rm -rf -- * &&\n                    git reset\n            '\n    ++ test 0 = 0\n    ++ test_cleanup='{\n                    rm -rf -- * &&\n                    git reset\n    \n                    } && (exit \"$eval_ret\"); eval_ret=$?; :'\n    ++ git add -A\n    ++ printf %s '\\'\n    ++ git --glob-pathspecs ls-files -z -- 00\n    ++ wildtest_stdout_stderr_cmp\n    ++ tr -d '\\0'\n    ++ test_cmp expect.err actual.err\n    ++ diff -u expect.err actual.err\n    ++ test_cmp expect actual\n    ++ diff -u expect actual\n    --- expect      2018-01-03 12:43:11.116611200 +0000\n    +++ actual      2018-01-03 12:43:11.216180400 +0000\n    @@ -1 +0,0 @@\n    -\\\n    \\ No newline at end of file\n    + test_eval_ret_=1\n    + want_trace\n    + test t = t\n    + test t = t\n    + set +x\n    error: last command exited with $?=1\n    ++ rm -rf -- actual actual.err actual.raw expect expect.err\n    ++ git reset\n    ++ exit 1\n    ++ eval_ret=1\n    ++ :\n    + test_eval_ret_=0\n    + want_trace\n    + test t = t\n    + test t = t\n    + set +x\n    not ok 490 - wildmatch(ls): match '00' '\\'\n    #\n    #                                       wildtest_file_setup &&\n    #                                       printf '%s' '\\' >expect &&\n    #                                       git --glob-pathspecs ls-files -z -- '00' >actual.raw 2>actual.err &&\n    #                                       wildtest_stdout_stderr_cmp\n    #\n\nI'm digging into the failures myself now, but wanted to report the\nproblem in the name of getting more eyes on it.\n\nAdam\n\n[0]: https://gist.github.com/me-and/04443bcb00e12436f0eacce079b56d02\n"},{"id":"335715","messageId":"87h8s3cbmn.fsf@evledraar.gmail.com","threadId":"47493","inReplyTo":"20180103130232.GD29210@dinwoodie.org","subject":"Re: [PATCH v2 7/7] wildmatch test: create & test files on disk in addition to in-memory","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-03T13:31:12Z","receivedAt":"2018-01-03T13:31:25Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Jan 03 2018, Adam Dinwoodie jotted:\n\n> On Monday 25 December 2017 at 12:28 am +0000, Ævar Arnfjörð Bjarmason wrote:\n>> There has never been any full roundtrip testing of what git-ls-files\n>> and other functions that use wildmatch() actually do, rather we've\n>> been satisfied with just testing the underlying C function.\n>>\n>> Due to git-ls-files and friends having their own codepaths before they\n>> call wildmatch() there's sometimes differences in the behavior between\n>> the two, and even when we test for those (as with\n>> 9e4e8a64c2 (\"pathspec: die on empty strings as pathspec\", 2017-06-06))\n>> there was no one place where you can review how these two modes\n>> differ.\n>>\n>> Now there is. We now attempt to create a file called $haystack and\n>> match $needle against it for each pair of $needle and $haystack that\n>> we were passing to test-wildmatch.\n>>\n>> If we can't create the file we skip the test. This ensures that we can\n>> run this on all platforms and not maintain some infinitely growing\n>> whitelist of e.g. platforms that don't support certain characters in\n>> filenames.\n>>\n>> As a result of doing this we can now see the cases where these two\n>> ways of testing wildmatch differ:\n>>\n>>  * Creating a file called 'a[]b' and running ls-files 'a[]b' will show\n>>    that file, but wildmatch(\"a[]b\", \"a[]b\") will not match\n>>\n>>  * wildmatch() won't match a file called \\ against \\, but ls-files\n>>    will.\n>>\n>>  * `git --glob-pathspecs ls-files 'foo**'` will match a file\n>>    'foo/bba/arr', but wildmatch won't, however pathmatch will.\n>>\n>>    This seems like a bug to me, the two are otherwise equivalent as\n>>    these tests show.\n>>\n>> This also reveals the case discussed in 9e4e8a64c2 above, where '' is\n>> now an error as far as ls-files is concerned, but wildmatch() itself\n>> happily accepts it.\n>>\n>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>\n> I'm seeing this test script failing on the pu branch as a result of this\n> commit when building on Cygwin.  Specifically, the test fails at\n> 9d45e1ca4 (\"Merge branch 'bw/oidmap-autoinit' into pu\", 2017-12-28), and\n> bisecting points the blame at 2ee0c785a (\"wildmatch test: create & test\n> files on disk in addition to in-memory\", 2017-12-25).\n>\n> I've copied the verbose error output for the first error below, and\n> uploaded the full output, including verbose and trace output for the\n> unexpectedly failing tests, at [0].  (With 42 failures among 1512 tests,\n> there's a lot of it, so I didn't want to include it in an email.)\n\nDoes the fixup above in <878tdm8k2d.fsf@evledraar.gmail.com> work for\nyou, i.e. changing $10 in the script to ${10}?\n\nI was waiting on Junio to see if he'd like to just squash that or if I\nshould re-send.\n\n>     expecting success:\n>                                     wildtest_file_setup &&\n>                                     printf '%s' '\\' >expect &&\n>                                     git --glob-pathspecs ls-files -z -- '00' >actual.raw 2>actual.err &&\n>                                     wildtest_stdout_stderr_cmp\n>\n>     ++ wildtest_file_setup\n>     ++ test_when_finished '\n>                     rm -rf -- * &&\n>                     git reset\n>             '\n>     ++ test 0 = 0\n>     ++ test_cleanup='{\n>                     rm -rf -- * &&\n>                     git reset\n>\n>                     } && (exit \"$eval_ret\"); eval_ret=$?; :'\n>     ++ git add -A\n>     ++ printf %s '\\'\n>     ++ git --glob-pathspecs ls-files -z -- 00\n>     ++ wildtest_stdout_stderr_cmp\n>     ++ tr -d '\\0'\n>     ++ test_cmp expect.err actual.err\n>     ++ diff -u expect.err actual.err\n>     ++ test_cmp expect actual\n>     ++ diff -u expect actual\n>     --- expect      2018-01-03 12:43:11.116611200 +0000\n>     +++ actual      2018-01-03 12:43:11.216180400 +0000\n>     @@ -1 +0,0 @@\n>     -\\\n>     \\ No newline at end of file\n>     + test_eval_ret_=1\n>     + want_trace\n>     + test t = t\n>     + test t = t\n>     + set +x\n>     error: last command exited with $?=1\n>     ++ rm -rf -- actual actual.err actual.raw expect expect.err\n>     ++ git reset\n>     ++ exit 1\n>     ++ eval_ret=1\n>     ++ :\n>     + test_eval_ret_=0\n>     + want_trace\n>     + test t = t\n>     + test t = t\n>     + set +x\n>     not ok 490 - wildmatch(ls): match '00' '\\'\n>     #\n>     #                                       wildtest_file_setup &&\n>     #                                       printf '%s' '\\' >expect &&\n>     #                                       git --glob-pathspecs ls-files -z -- '00' >actual.raw 2>actual.err &&\n>     #                                       wildtest_stdout_stderr_cmp\n>     #\n>\n> I'm digging into the failures myself now, but wanted to report the\n> problem in the name of getting more eyes on it.\n>\n> Adam\n>\n> [0]: https://gist.github.com/me-and/04443bcb00e12436f0eacce079b56d02\n"},{"id":"335717","messageId":"20180103144149.GE29210@dinwoodie.org","threadId":"47493","inReplyTo":"87h8s3cbmn.fsf@evledraar.gmail.com","subject":"Re: [PATCH v2 7/7] wildmatch test: create & test files on disk in addition to in-memory","fromName":"Adam Dinwoodie","fromEmail":"adam@dinwoodie.org","sentAt":"2018-01-03T14:41:49Z","receivedAt":"2018-01-03T14:42:00Z","isPatch":true,"sender":{"key":"adam@dinwoodie.org","avatar":"https://avatars.githubusercontent.com/u/1397507?v=4"},"body":"On Wednesday 03 January 2018 at 02:31 pm +0100, Ævar Arnfjörð Bjarmason wrote:\n> \n> On Wed, Jan 03 2018, Adam Dinwoodie jotted:\n> \n> > On Monday 25 December 2017 at 12:28 am +0000, Ævar Arnfjörð Bjarmason wrote:\n> >> There has never been any full roundtrip testing of what git-ls-files\n> >> and other functions that use wildmatch() actually do, rather we've\n> >> been satisfied with just testing the underlying C function.\n> >>\n> >> Due to git-ls-files and friends having their own codepaths before they\n> >> call wildmatch() there's sometimes differences in the behavior between\n> >> the two, and even when we test for those (as with\n> >> 9e4e8a64c2 (\"pathspec: die on empty strings as pathspec\", 2017-06-06))\n> >> there was no one place where you can review how these two modes\n> >> differ.\n> >>\n> >> Now there is. We now attempt to create a file called $haystack and\n> >> match $needle against it for each pair of $needle and $haystack that\n> >> we were passing to test-wildmatch.\n> >>\n> >> If we can't create the file we skip the test. This ensures that we can\n> >> run this on all platforms and not maintain some infinitely growing\n> >> whitelist of e.g. platforms that don't support certain characters in\n> >> filenames.\n> >>\n> >> As a result of doing this we can now see the cases where these two\n> >> ways of testing wildmatch differ:\n> >>\n> >>  * Creating a file called 'a[]b' and running ls-files 'a[]b' will show\n> >>    that file, but wildmatch(\"a[]b\", \"a[]b\") will not match\n> >>\n> >>  * wildmatch() won't match a file called \\ against \\, but ls-files\n> >>    will.\n> >>\n> >>  * `git --glob-pathspecs ls-files 'foo**'` will match a file\n> >>    'foo/bba/arr', but wildmatch won't, however pathmatch will.\n> >>\n> >>    This seems like a bug to me, the two are otherwise equivalent as\n> >>    these tests show.\n> >>\n> >> This also reveals the case discussed in 9e4e8a64c2 above, where '' is\n> >> now an error as far as ls-files is concerned, but wildmatch() itself\n> >> happily accepts it.\n> >>\n> >> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> >\n> > I'm seeing this test script failing on the pu branch as a result of this\n> > commit when building on Cygwin.  Specifically, the test fails at\n> > 9d45e1ca4 (\"Merge branch 'bw/oidmap-autoinit' into pu\", 2017-12-28), and\n> > bisecting points the blame at 2ee0c785a (\"wildmatch test: create & test\n> > files on disk in addition to in-memory\", 2017-12-25).\n> >\n> > I've copied the verbose error output for the first error below, and\n> > uploaded the full output, including verbose and trace output for the\n> > unexpectedly failing tests, at [0].  (With 42 failures among 1512 tests,\n> > there's a lot of it, so I didn't want to include it in an email.)\n> \n> Does the fixup above in <878tdm8k2d.fsf@evledraar.gmail.com> work for\n> you, i.e. changing $10 in the script to ${10}?\n\nThis fixes some but not all of the failures: I'm now down from 42 to 24\nfailures.\n\nUpdated verbose test output is at\nhttps://gist.github.com/me-and/04443bcb00e12436f0eacce079b56d02\n\nThanks!\n\nAdam\n"},{"id":"335768","messageId":"87d12qdaa5.fsf@evledraar.gmail.com","threadId":"47493","inReplyTo":"20180103144149.GE29210@dinwoodie.org","subject":"Re: [PATCH v2 7/7] wildmatch test: create & test files on disk in addition to in-memory","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-03T19:14:58Z","receivedAt":"2018-01-03T19:15:08Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Jan 03 2018, Adam Dinwoodie jotted:\n\n> On Wednesday 03 January 2018 at 02:31 pm +0100, Ævar Arnfjörð Bjarmason wrote:\n>>\n>> On Wed, Jan 03 2018, Adam Dinwoodie jotted:\n>>\n>> > On Monday 25 December 2017 at 12:28 am +0000, Ævar Arnfjörð Bjarmason wrote:\n>> >> There has never been any full roundtrip testing of what git-ls-files\n>> >> and other functions that use wildmatch() actually do, rather we've\n>> >> been satisfied with just testing the underlying C function.\n>> >>\n>> >> Due to git-ls-files and friends having their own codepaths before they\n>> >> call wildmatch() there's sometimes differences in the behavior between\n>> >> the two, and even when we test for those (as with\n>> >> 9e4e8a64c2 (\"pathspec: die on empty strings as pathspec\", 2017-06-06))\n>> >> there was no one place where you can review how these two modes\n>> >> differ.\n>> >>\n>> >> Now there is. We now attempt to create a file called $haystack and\n>> >> match $needle against it for each pair of $needle and $haystack that\n>> >> we were passing to test-wildmatch.\n>> >>\n>> >> If we can't create the file we skip the test. This ensures that we can\n>> >> run this on all platforms and not maintain some infinitely growing\n>> >> whitelist of e.g. platforms that don't support certain characters in\n>> >> filenames.\n>> >>\n>> >> As a result of doing this we can now see the cases where these two\n>> >> ways of testing wildmatch differ:\n>> >>\n>> >>  * Creating a file called 'a[]b' and running ls-files 'a[]b' will show\n>> >>    that file, but wildmatch(\"a[]b\", \"a[]b\") will not match\n>> >>\n>> >>  * wildmatch() won't match a file called \\ against \\, but ls-files\n>> >>    will.\n>> >>\n>> >>  * `git --glob-pathspecs ls-files 'foo**'` will match a file\n>> >>    'foo/bba/arr', but wildmatch won't, however pathmatch will.\n>> >>\n>> >>    This seems like a bug to me, the two are otherwise equivalent as\n>> >>    these tests show.\n>> >>\n>> >> This also reveals the case discussed in 9e4e8a64c2 above, where '' is\n>> >> now an error as far as ls-files is concerned, but wildmatch() itself\n>> >> happily accepts it.\n>> >>\n>> >> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>> >\n>> > I'm seeing this test script failing on the pu branch as a result of this\n>> > commit when building on Cygwin.  Specifically, the test fails at\n>> > 9d45e1ca4 (\"Merge branch 'bw/oidmap-autoinit' into pu\", 2017-12-28), and\n>> > bisecting points the blame at 2ee0c785a (\"wildmatch test: create & test\n>> > files on disk in addition to in-memory\", 2017-12-25).\n>> >\n>> > I've copied the verbose error output for the first error below, and\n>> > uploaded the full output, including verbose and trace output for the\n>> > unexpectedly failing tests, at [0].  (With 42 failures among 1512 tests,\n>> > there's a lot of it, so I didn't want to include it in an email.)\n>>\n>> Does the fixup above in <878tdm8k2d.fsf@evledraar.gmail.com> work for\n>> you, i.e. changing $10 in the script to ${10}?\n>\n> This fixes some but not all of the failures: I'm now down from 42 to 24\n> failures.\n>\n> Updated verbose test output is at\n> https://gist.github.com/me-and/04443bcb00e12436f0eacce079b56d02\n\nThanks lot, looking through our own commit logs I believe the rest\nshould be fixed by this (prior art in 6fd1106aa4), it would be great if\nyou could test it, I don't have access to a Windows machine:\n\n    diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\n    index f985139b6f..5838fcb77d 100755\n    --- a/t/t3070-wildmatch.sh\n    +++ b/t/t3070-wildmatch.sh\n    @@ -23,6 +23,15 @@ create_test_file() {\n            *//*)\n                    return 1\n                    ;;\n    +       # On Windows, \\ in paths is silently converted to /, which\n    +       # would result in the \"touch\" below working, but the test\n    +       # itself failing.\n    +       *\\\\*)\n    +               if ! test_have_prereq BSLASHPSPEC\n    +               then\n    +                       return 1\n    +               fi\n    +               ;;\n            # When testing the difference between foo/bar and foo/bar/ we\n            # can't test the latter.\n            */)\n"},{"id":"335818","messageId":"20180104115058.GF29210@dinwoodie.org","threadId":"47493","inReplyTo":"87d12qdaa5.fsf@evledraar.gmail.com","subject":"Re: [PATCH v2 7/7] wildmatch test: create & test files on disk in addition to in-memory","fromName":"Adam Dinwoodie","fromEmail":"adam@dinwoodie.org","sentAt":"2018-01-04T11:50:58Z","receivedAt":"2018-01-04T11:51:09Z","isPatch":true,"sender":{"key":"adam@dinwoodie.org","avatar":"https://avatars.githubusercontent.com/u/1397507?v=4"},"body":"On Wednesday 03 January 2018 at 08:14 pm +0100, Ævar Arnfjörð Bjarmason wrote:\n> \n> On Wed, Jan 03 2018, Adam Dinwoodie jotted:\n> \n> > On Wednesday 03 January 2018 at 02:31 pm +0100, Ævar Arnfjörð Bjarmason wrote:\n> >> Does the fixup above in <878tdm8k2d.fsf@evledraar.gmail.com> work for\n> >> you, i.e. changing $10 in the script to ${10}?\n> >\n> > This fixes some but not all of the failures: I'm now down from 42 to 24\n> > failures.\n> >\n> > Updated verbose test output is at\n> > https://gist.github.com/me-and/04443bcb00e12436f0eacce079b56d02\n> \n> Thanks lot, looking through our own commit logs I believe the rest\n> should be fixed by this (prior art in 6fd1106aa4), it would be great if\n> you could test it, I don't have access to a Windows machine:\n> \n>     diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\n>     index f985139b6f..5838fcb77d 100755\n>     --- a/t/t3070-wildmatch.sh\n>     +++ b/t/t3070-wildmatch.sh\n>     @@ -23,6 +23,15 @@ create_test_file() {\n>             *//*)\n>                     return 1\n>                     ;;\n>     +       # On Windows, \\ in paths is silently converted to /, which\n>     +       # would result in the \"touch\" below working, but the test\n>     +       # itself failing.\n>     +       *\\\\*)\n>     +               if ! test_have_prereq BSLASHPSPEC\n>     +               then\n>     +                       return 1\n>     +               fi\n>     +               ;;\n>             # When testing the difference between foo/bar and foo/bar/ we\n>             # can't test the latter.\n>             */)\n\nConfirmed this fixes all the outstanding test failures.  Thank you!\n"},{"id":"335844","messageId":"20180104192657.28019-1-avarab@gmail.com","threadId":"47493","inReplyTo":"20180104115058.GF29210@dinwoodie.org","subject":"[PATCH v4 0/7] increase wildmatch test coverage","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-04T19:26:50Z","receivedAt":"2018-01-04T19:27:41Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This fixes errors in v3 that caused failures on bash & on Windows.\n\nÆvar Arnfjörð Bjarmason (7):\n  wildmatch test: indent with tabs, not spaces\n  wildmatch test: use more standard shell style\n  wildmatch test: don't try to vertically align our output\n  wildmatch test: use a paranoia pattern from nul_match()\n  wildmatch test: remove dead fnmatch() test code\n  wildmatch test: perform all tests under all wildmatch() modes\n\nNo changes\n\n  wildmatch test: create & test files on disk in addition to in-memory\n\nRephrase the commit message a bit.\n\nChange $10 to ${10} for portability.\n\nSkip tests that would create a file with \"\\\" in the name on Windows\n(or rather, where we don't have the BSLASHPSPEC prereq).\n\n t/helper/test-wildmatch.c |   2 +\n t/t3070-wildmatch.sh      | 777 +++++++++++++++++++++++++++++++---------------\n 2 files changed, 534 insertions(+), 245 deletions(-)\n\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335845","messageId":"20180104192657.28019-2-avarab@gmail.com","threadId":"47493","inReplyTo":"20180104192657.28019-1-avarab@gmail.com","subject":"[PATCH v4 1/7] wildmatch test: indent with tabs, not spaces","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-04T19:26:51Z","receivedAt":"2018-01-04T19:27:44Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Replace the 4-width mixed space & tab indentation in this file with\nindentation with tabs as we do in most of the rest of our tests.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 54 ++++++++++++++++++++++++++--------------------------\n 1 file changed, 27 insertions(+), 27 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 163a14a1c2..27fa878f6e 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -5,39 +5,39 @@ test_description='wildmatch tests'\n . ./test-lib.sh\n \n match() {\n-    if [ $1 = 1 ]; then\n-\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n-\t    test-wildmatch wildmatch '$3' '$4'\n-\t\"\n-    else\n-\ttest_expect_success \"wildmatch:  no match '$3' '$4'\" \"\n-\t    ! test-wildmatch wildmatch '$3' '$4'\n-\t\"\n-    fi\n+\tif [ $1 = 1 ]; then\n+\t\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n+\t\t\ttest-wildmatch wildmatch '$3' '$4'\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"wildmatch:  no match '$3' '$4'\" \"\n+\t\t\t! test-wildmatch wildmatch '$3' '$4'\n+\t\t\"\n+\tfi\n }\n \n imatch() {\n-    if [ $1 = 1 ]; then\n-\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n-\t    test-wildmatch iwildmatch '$2' '$3'\n-\t\"\n-    else\n-\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n-\t    ! test-wildmatch iwildmatch '$2' '$3'\n-\t\"\n-    fi\n+\tif [ $1 = 1 ]; then\n+\t\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n+\t\t\ttest-wildmatch iwildmatch '$2' '$3'\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n+\t\t\t! test-wildmatch iwildmatch '$2' '$3'\n+\t\t\"\n+\tfi\n }\n \n pathmatch() {\n-    if [ $1 = 1 ]; then\n-\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n-\t    test-wildmatch pathmatch '$2' '$3'\n-\t\"\n-    else\n-\ttest_expect_success \"pathmatch:  no match '$2' '$3'\" \"\n-\t    ! test-wildmatch pathmatch '$2' '$3'\n-\t\"\n-    fi\n+\tif [ $1 = 1 ]; then\n+\t\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n+\t\t\ttest-wildmatch pathmatch '$2' '$3'\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"pathmatch:  no match '$2' '$3'\" \"\n+\t\t\t! test-wildmatch pathmatch '$2' '$3'\n+\t\t\"\n+\tfi\n }\n \n # Basic wildmat features\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335846","messageId":"20180104192657.28019-3-avarab@gmail.com","threadId":"47493","inReplyTo":"20180104192657.28019-1-avarab@gmail.com","subject":"[PATCH v4 2/7] wildmatch test: use more standard shell style","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-04T19:26:52Z","receivedAt":"2018-01-04T19:27:46Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the wildmatch test to use more standard shell style, usually we\nuse \"if test\" not \"if [\".\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 9 ++++++---\n 1 file changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 27fa878f6e..4d589d1f9a 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -5,7 +5,8 @@ test_description='wildmatch tests'\n . ./test-lib.sh\n \n match() {\n-\tif [ $1 = 1 ]; then\n+\tif test \"$1\" = 1\n+\tthen\n \t\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n \t\t\ttest-wildmatch wildmatch '$3' '$4'\n \t\t\"\n@@ -17,7 +18,8 @@ match() {\n }\n \n imatch() {\n-\tif [ $1 = 1 ]; then\n+\tif test \"$1\" = 1\n+\tthen\n \t\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n \t\t\ttest-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n@@ -29,7 +31,8 @@ imatch() {\n }\n \n pathmatch() {\n-\tif [ $1 = 1 ]; then\n+\tif test \"$1\" = 1\n+\tthen\n \t\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n \t\t\ttest-wildmatch pathmatch '$2' '$3'\n \t\t\"\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335847","messageId":"20180104192657.28019-4-avarab@gmail.com","threadId":"47493","inReplyTo":"20180104192657.28019-1-avarab@gmail.com","subject":"[PATCH v4 3/7] wildmatch test: don't try to vertically align our output","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-04T19:26:53Z","receivedAt":"2018-01-04T19:27:50Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Don't try to vertically align the test output, which is futile anyway\nunder the TAP output where we're going to be emitting a number for\neach test without aligning the test count.\n\nThis makes subsequent changes of mine where I'm not going to be\naligning this output as I add new tests easier.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 4d589d1f9a..19ea64bba9 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -7,11 +7,11 @@ test_description='wildmatch tests'\n match() {\n \tif test \"$1\" = 1\n \tthen\n-\t\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n+\t\ttest_expect_success \"wildmatch: match '$3' '$4'\" \"\n \t\t\ttest-wildmatch wildmatch '$3' '$4'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"wildmatch:  no match '$3' '$4'\" \"\n+\t\ttest_expect_success \"wildmatch: no match '$3' '$4'\" \"\n \t\t\t! test-wildmatch wildmatch '$3' '$4'\n \t\t\"\n \tfi\n@@ -20,7 +20,7 @@ match() {\n imatch() {\n \tif test \"$1\" = 1\n \tthen\n-\t\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n+\t\ttest_expect_success \"iwildmatch: match '$2' '$3'\" \"\n \t\t\ttest-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n \telse\n@@ -33,11 +33,11 @@ imatch() {\n pathmatch() {\n \tif test \"$1\" = 1\n \tthen\n-\t\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n+\t\ttest_expect_success \"pathmatch: match '$2' '$3'\" \"\n \t\t\ttest-wildmatch pathmatch '$2' '$3'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"pathmatch:  no match '$2' '$3'\" \"\n+\t\ttest_expect_success \"pathmatch: no match '$2' '$3'\" \"\n \t\t\t! test-wildmatch pathmatch '$2' '$3'\n \t\t\"\n \tfi\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335848","messageId":"20180104192657.28019-5-avarab@gmail.com","threadId":"47493","inReplyTo":"20180104192657.28019-1-avarab@gmail.com","subject":"[PATCH v4 4/7] wildmatch test: use a paranoia pattern from nul_match()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-04T19:26:54Z","receivedAt":"2018-01-04T19:27:53Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Use a pattern from the nul_match() function in t7008-grep-binary.sh to\nmake sure that we don't just fall through to the \"else\" if there's an\nunknown parameter.\n\nThis is something I added in commit 77f6f4406f (\"grep: add a test\nhelper function for less verbose -f \\0 tests\", 2017-05-20) to grep\ntests, which were modeled on these wildmatch tests, and I'm now\nporting back to the original wildmatch tests.\n\nI am not using the \"say '...'; exit 1\" pattern from t0000-basic.sh\nbecause if I fail I want to run the rest of the tests (unless under\n-i), and doing this makes sure we do that and don't exit right away\nwithout fully reporting our errors.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 15 ++++++++++++---\n 1 file changed, 12 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 19ea64bba9..9691d8eda3 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -10,10 +10,13 @@ match() {\n \t\ttest_expect_success \"wildmatch: match '$3' '$4'\" \"\n \t\t\ttest-wildmatch wildmatch '$3' '$4'\n \t\t\"\n-\telse\n+\telif test \"$1\" = 0\n+\tthen\n \t\ttest_expect_success \"wildmatch: no match '$3' '$4'\" \"\n \t\t\t! test-wildmatch wildmatch '$3' '$4'\n \t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n \tfi\n }\n \n@@ -23,10 +26,13 @@ imatch() {\n \t\ttest_expect_success \"iwildmatch: match '$2' '$3'\" \"\n \t\t\ttest-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n-\telse\n+\telif test \"$1\" = 0\n+\tthen\n \t\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n \t\t\t! test-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n \tfi\n }\n \n@@ -36,10 +42,13 @@ pathmatch() {\n \t\ttest_expect_success \"pathmatch: match '$2' '$3'\" \"\n \t\t\ttest-wildmatch pathmatch '$2' '$3'\n \t\t\"\n-\telse\n+\telif test \"$1\" = 0\n+\tthen\n \t\ttest_expect_success \"pathmatch: no match '$2' '$3'\" \"\n \t\t\t! test-wildmatch pathmatch '$2' '$3'\n \t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n \tfi\n }\n \n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335849","messageId":"20180104192657.28019-6-avarab@gmail.com","threadId":"47493","inReplyTo":"20180104192657.28019-1-avarab@gmail.com","subject":"[PATCH v4 5/7] wildmatch test: remove dead fnmatch() test code","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-04T19:26:55Z","receivedAt":"2018-01-04T19:27:57Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the unused fnmatch() test parameter from the wildmatch\ntest. The code that used to test this was removed in 70a8fc999d (\"stop\nusing fnmatch (either native or compat)\", 2014-02-15).\n\nAs a --word-diff shows the only change to the body of the tests is the\nremoval of the second out of four parameters passed to match().\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 356 +++++++++++++++++++++++++--------------------------\n 1 file changed, 178 insertions(+), 178 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 9691d8eda3..2f8a681c72 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -7,13 +7,13 @@ test_description='wildmatch tests'\n match() {\n \tif test \"$1\" = 1\n \tthen\n-\t\ttest_expect_success \"wildmatch: match '$3' '$4'\" \"\n-\t\t\ttest-wildmatch wildmatch '$3' '$4'\n+\t\ttest_expect_success \"wildmatch: match '$2' '$3'\" \"\n+\t\t\ttest-wildmatch wildmatch '$2' '$3'\n \t\t\"\n \telif test \"$1\" = 0\n \tthen\n-\t\ttest_expect_success \"wildmatch: no match '$3' '$4'\" \"\n-\t\t\t! test-wildmatch wildmatch '$3' '$4'\n+\t\ttest_expect_success \"wildmatch: no match '$2' '$3'\" \"\n+\t\t\t! test-wildmatch wildmatch '$2' '$3'\n \t\t\"\n \telse\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n@@ -53,176 +53,176 @@ pathmatch() {\n }\n \n # Basic wildmat features\n-match 1 1 foo foo\n-match 0 0 foo bar\n-match 1 1 '' \"\"\n-match 1 1 foo '???'\n-match 0 0 foo '??'\n-match 1 1 foo '*'\n-match 1 1 foo 'f*'\n-match 0 0 foo '*f'\n-match 1 1 foo '*foo*'\n-match 1 1 foobar '*ob*a*r*'\n-match 1 1 aaaaaaabababab '*ab'\n-match 1 1 'foo*' 'foo\\*'\n-match 0 0 foobar 'foo\\*bar'\n-match 1 1 'f\\oo' 'f\\\\oo'\n-match 1 1 ball '*[al]?'\n-match 0 0 ten '[ten]'\n-match 0 1 ten '**[!te]'\n-match 0 0 ten '**[!ten]'\n-match 1 1 ten 't[a-g]n'\n-match 0 0 ten 't[!a-g]n'\n-match 1 1 ton 't[!a-g]n'\n-match 1 1 ton 't[^a-g]n'\n-match 1 x 'a]b' 'a[]]b'\n-match 1 x a-b 'a[]-]b'\n-match 1 x 'a]b' 'a[]-]b'\n-match 0 x aab 'a[]-]b'\n-match 1 x aab 'a[]a-]b'\n-match 1 1 ']' ']'\n+match 1 foo foo\n+match 0 foo bar\n+match 1 '' \"\"\n+match 1 foo '???'\n+match 0 foo '??'\n+match 1 foo '*'\n+match 1 foo 'f*'\n+match 0 foo '*f'\n+match 1 foo '*foo*'\n+match 1 foobar '*ob*a*r*'\n+match 1 aaaaaaabababab '*ab'\n+match 1 'foo*' 'foo\\*'\n+match 0 foobar 'foo\\*bar'\n+match 1 'f\\oo' 'f\\\\oo'\n+match 1 ball '*[al]?'\n+match 0 ten '[ten]'\n+match 0 ten '**[!te]'\n+match 0 ten '**[!ten]'\n+match 1 ten 't[a-g]n'\n+match 0 ten 't[!a-g]n'\n+match 1 ton 't[!a-g]n'\n+match 1 ton 't[^a-g]n'\n+match 1 'a]b' 'a[]]b'\n+match 1 a-b 'a[]-]b'\n+match 1 'a]b' 'a[]-]b'\n+match 0 aab 'a[]-]b'\n+match 1 aab 'a[]a-]b'\n+match 1 ']' ']'\n \n # Extended slash-matching features\n-match 0 0 'foo/baz/bar' 'foo*bar'\n-match 0 0 'foo/baz/bar' 'foo**bar'\n-match 0 1 'foobazbar' 'foo**bar'\n-match 1 1 'foo/baz/bar' 'foo/**/bar'\n-match 1 0 'foo/baz/bar' 'foo/**/**/bar'\n-match 1 0 'foo/b/a/z/bar' 'foo/**/bar'\n-match 1 0 'foo/b/a/z/bar' 'foo/**/**/bar'\n-match 1 0 'foo/bar' 'foo/**/bar'\n-match 1 0 'foo/bar' 'foo/**/**/bar'\n-match 0 0 'foo/bar' 'foo?bar'\n-match 0 0 'foo/bar' 'foo[/]bar'\n-match 0 0 'foo/bar' 'foo[^a-z]bar'\n-match 0 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 0 'foo' '**/foo'\n-match 1 x 'XXX/foo' '**/foo'\n-match 1 0 'bar/baz/foo' '**/foo'\n-match 0 0 'bar/baz/foo' '*/foo'\n-match 0 0 'foo/bar/baz' '**/bar*'\n-match 1 0 'deep/foo/bar/baz' '**/bar/*'\n-match 0 0 'deep/foo/bar/baz/' '**/bar/*'\n-match 1 0 'deep/foo/bar/baz/' '**/bar/**'\n-match 0 0 'deep/foo/bar' '**/bar/*'\n-match 1 0 'deep/foo/bar/' '**/bar/**'\n-match 0 0 'foo/bar/baz' '**/bar**'\n-match 1 0 'foo/bar/baz/x' '*/bar/**'\n-match 0 0 'deep/foo/bar/baz/x' '*/bar/**'\n-match 1 0 'deep/foo/bar/baz/x' '**/bar/*/*'\n+match 0 'foo/baz/bar' 'foo*bar'\n+match 0 'foo/baz/bar' 'foo**bar'\n+match 0 'foobazbar' 'foo**bar'\n+match 1 'foo/baz/bar' 'foo/**/bar'\n+match 1 'foo/baz/bar' 'foo/**/**/bar'\n+match 1 'foo/b/a/z/bar' 'foo/**/bar'\n+match 1 'foo/b/a/z/bar' 'foo/**/**/bar'\n+match 1 'foo/bar' 'foo/**/bar'\n+match 1 'foo/bar' 'foo/**/**/bar'\n+match 0 'foo/bar' 'foo?bar'\n+match 0 'foo/bar' 'foo[/]bar'\n+match 0 'foo/bar' 'foo[^a-z]bar'\n+match 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+match 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+match 1 'foo' '**/foo'\n+match 1 'XXX/foo' '**/foo'\n+match 1 'bar/baz/foo' '**/foo'\n+match 0 'bar/baz/foo' '*/foo'\n+match 0 'foo/bar/baz' '**/bar*'\n+match 1 'deep/foo/bar/baz' '**/bar/*'\n+match 0 'deep/foo/bar/baz/' '**/bar/*'\n+match 1 'deep/foo/bar/baz/' '**/bar/**'\n+match 0 'deep/foo/bar' '**/bar/*'\n+match 1 'deep/foo/bar/' '**/bar/**'\n+match 0 'foo/bar/baz' '**/bar**'\n+match 1 'foo/bar/baz/x' '*/bar/**'\n+match 0 'deep/foo/bar/baz/x' '*/bar/**'\n+match 1 'deep/foo/bar/baz/x' '**/bar/*/*'\n \n # Various additional tests\n-match 0 0 'acrt' 'a[c-c]st'\n-match 1 1 'acrt' 'a[c-c]rt'\n-match 0 0 ']' '[!]-]'\n-match 1 x 'a' '[!]-]'\n-match 0 0 '' '\\'\n-match 0 x '\\' '\\'\n-match 0 x 'XXX/\\' '*/\\'\n-match 1 x 'XXX/\\' '*/\\\\'\n-match 1 1 'foo' 'foo'\n-match 1 1 '@foo' '@foo'\n-match 0 0 'foo' '@foo'\n-match 1 1 '[ab]' '\\[ab]'\n-match 1 1 '[ab]' '[[]ab]'\n-match 1 x '[ab]' '[[:]ab]'\n-match 0 x '[ab]' '[[::]ab]'\n-match 1 x '[ab]' '[[:digit]ab]'\n-match 1 x '[ab]' '[\\[:]ab]'\n-match 1 1 '?a?b' '\\??\\?b'\n-match 1 1 'abc' '\\a\\b\\c'\n-match 0 0 'foo' ''\n-match 1 0 'foo/bar/baz/to' '**/t[o]'\n+match 0 'acrt' 'a[c-c]st'\n+match 1 'acrt' 'a[c-c]rt'\n+match 0 ']' '[!]-]'\n+match 1 'a' '[!]-]'\n+match 0 '' '\\'\n+match 0 '\\' '\\'\n+match 0 'XXX/\\' '*/\\'\n+match 1 'XXX/\\' '*/\\\\'\n+match 1 'foo' 'foo'\n+match 1 '@foo' '@foo'\n+match 0 'foo' '@foo'\n+match 1 '[ab]' '\\[ab]'\n+match 1 '[ab]' '[[]ab]'\n+match 1 '[ab]' '[[:]ab]'\n+match 0 '[ab]' '[[::]ab]'\n+match 1 '[ab]' '[[:digit]ab]'\n+match 1 '[ab]' '[\\[:]ab]'\n+match 1 '?a?b' '\\??\\?b'\n+match 1 'abc' '\\a\\b\\c'\n+match 0 'foo' ''\n+match 1 'foo/bar/baz/to' '**/t[o]'\n \n # Character class tests\n-match 1 x 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n-match 0 x 'a' '[[:digit:][:upper:][:space:]]'\n-match 1 x 'A' '[[:digit:][:upper:][:space:]]'\n-match 1 x '1' '[[:digit:][:upper:][:space:]]'\n-match 0 x '1' '[[:digit:][:upper:][:spaci:]]'\n-match 1 x ' ' '[[:digit:][:upper:][:space:]]'\n-match 0 x '.' '[[:digit:][:upper:][:space:]]'\n-match 1 x '.' '[[:digit:][:punct:][:space:]]'\n-match 1 x '5' '[[:xdigit:]]'\n-match 1 x 'f' '[[:xdigit:]]'\n-match 1 x 'D' '[[:xdigit:]]'\n-match 1 x '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n-match 1 x '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n-match 1 x '5' '[a-c[:digit:]x-z]'\n-match 1 x 'b' '[a-c[:digit:]x-z]'\n-match 1 x 'y' '[a-c[:digit:]x-z]'\n-match 0 x 'q' '[a-c[:digit:]x-z]'\n+match 1 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n+match 0 'a' '[[:digit:][:upper:][:space:]]'\n+match 1 'A' '[[:digit:][:upper:][:space:]]'\n+match 1 '1' '[[:digit:][:upper:][:space:]]'\n+match 0 '1' '[[:digit:][:upper:][:spaci:]]'\n+match 1 ' ' '[[:digit:][:upper:][:space:]]'\n+match 0 '.' '[[:digit:][:upper:][:space:]]'\n+match 1 '.' '[[:digit:][:punct:][:space:]]'\n+match 1 '5' '[[:xdigit:]]'\n+match 1 'f' '[[:xdigit:]]'\n+match 1 'D' '[[:xdigit:]]'\n+match 1 '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n+match 1 '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n+match 1 '5' '[a-c[:digit:]x-z]'\n+match 1 'b' '[a-c[:digit:]x-z]'\n+match 1 'y' '[a-c[:digit:]x-z]'\n+match 0 'q' '[a-c[:digit:]x-z]'\n \n # Additional tests, including some malformed wildmats\n-match 1 x ']' '[\\\\-^]'\n-match 0 0 '[' '[\\\\-^]'\n-match 1 x '-' '[\\-_]'\n-match 1 x ']' '[\\]]'\n-match 0 0 '\\]' '[\\]]'\n-match 0 0 '\\' '[\\]]'\n-match 0 0 'ab' 'a[]b'\n-match 0 x 'a[]b' 'a[]b'\n-match 0 x 'ab[' 'ab['\n-match 0 0 'ab' '[!'\n-match 0 0 'ab' '[-'\n-match 1 1 '-' '[-]'\n-match 0 0 '-' '[a-'\n-match 0 0 '-' '[!a-'\n-match 1 x '-' '[--A]'\n-match 1 x '5' '[--A]'\n-match 1 1 ' ' '[ --]'\n-match 1 1 '$' '[ --]'\n-match 1 1 '-' '[ --]'\n-match 0 0 '0' '[ --]'\n-match 1 x '-' '[---]'\n-match 1 x '-' '[------]'\n-match 0 0 'j' '[a-e-n]'\n-match 1 x '-' '[a-e-n]'\n-match 1 x 'a' '[!------]'\n-match 0 0 '[' '[]-a]'\n-match 1 x '^' '[]-a]'\n-match 0 0 '^' '[!]-a]'\n-match 1 x '[' '[!]-a]'\n-match 1 1 '^' '[a^bc]'\n-match 1 x '-b]' '[a-]b]'\n-match 0 0 '\\' '[\\]'\n-match 1 1 '\\' '[\\\\]'\n-match 0 0 '\\' '[!\\\\]'\n-match 1 1 'G' '[A-\\\\]'\n-match 0 0 'aaabbb' 'b*a'\n-match 0 0 'aabcaa' '*ba*'\n-match 1 1 ',' '[,]'\n-match 1 1 ',' '[\\\\,]'\n-match 1 1 '\\' '[\\\\,]'\n-match 1 1 '-' '[,-.]'\n-match 0 0 '+' '[,-.]'\n-match 0 0 '-.]' '[,-.]'\n-match 1 1 '2' '[\\1-\\3]'\n-match 1 1 '3' '[\\1-\\3]'\n-match 0 0 '4' '[\\1-\\3]'\n-match 1 1 '\\' '[[-\\]]'\n-match 1 1 '[' '[[-\\]]'\n-match 1 1 ']' '[[-\\]]'\n-match 0 0 '-' '[[-\\]]'\n+match 1 ']' '[\\\\-^]'\n+match 0 '[' '[\\\\-^]'\n+match 1 '-' '[\\-_]'\n+match 1 ']' '[\\]]'\n+match 0 '\\]' '[\\]]'\n+match 0 '\\' '[\\]]'\n+match 0 'ab' 'a[]b'\n+match 0 'a[]b' 'a[]b'\n+match 0 'ab[' 'ab['\n+match 0 'ab' '[!'\n+match 0 'ab' '[-'\n+match 1 '-' '[-]'\n+match 0 '-' '[a-'\n+match 0 '-' '[!a-'\n+match 1 '-' '[--A]'\n+match 1 '5' '[--A]'\n+match 1 ' ' '[ --]'\n+match 1 '$' '[ --]'\n+match 1 '-' '[ --]'\n+match 0 '0' '[ --]'\n+match 1 '-' '[---]'\n+match 1 '-' '[------]'\n+match 0 'j' '[a-e-n]'\n+match 1 '-' '[a-e-n]'\n+match 1 'a' '[!------]'\n+match 0 '[' '[]-a]'\n+match 1 '^' '[]-a]'\n+match 0 '^' '[!]-a]'\n+match 1 '[' '[!]-a]'\n+match 1 '^' '[a^bc]'\n+match 1 '-b]' '[a-]b]'\n+match 0 '\\' '[\\]'\n+match 1 '\\' '[\\\\]'\n+match 0 '\\' '[!\\\\]'\n+match 1 'G' '[A-\\\\]'\n+match 0 'aaabbb' 'b*a'\n+match 0 'aabcaa' '*ba*'\n+match 1 ',' '[,]'\n+match 1 ',' '[\\\\,]'\n+match 1 '\\' '[\\\\,]'\n+match 1 '-' '[,-.]'\n+match 0 '+' '[,-.]'\n+match 0 '-.]' '[,-.]'\n+match 1 '2' '[\\1-\\3]'\n+match 1 '3' '[\\1-\\3]'\n+match 0 '4' '[\\1-\\3]'\n+match 1 '\\' '[[-\\]]'\n+match 1 '[' '[[-\\]]'\n+match 1 ']' '[[-\\]]'\n+match 0 '-' '[[-\\]]'\n \n # Test recursion and the abort code (use \"wildtest -i\" to see iteration counts)\n-match 1 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 1 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n-match 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n-match 0 x foo '*/*/*'\n-match 0 x foo/bar '*/*/*'\n-match 1 x foo/bba/arr '*/*/*'\n-match 0 x foo/bb/aa/rr '*/*/*'\n-match 1 x foo/bb/aa/rr '**/**/**'\n-match 1 x abcXdefXghi '*X*i'\n-match 0 x ab/cXd/efXg/hi '*X*i'\n-match 1 x ab/cXd/efXg/hi '*/*X*/*/*i'\n-match 1 x ab/cXd/efXg/hi '**/*X*/**/*i'\n+match 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+match 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+match 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+match 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+match 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+match 1 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n+match 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n+match 0 foo '*/*/*'\n+match 0 foo/bar '*/*/*'\n+match 1 foo/bba/arr '*/*/*'\n+match 0 foo/bb/aa/rr '*/*/*'\n+match 1 foo/bb/aa/rr '**/**/**'\n+match 1 abcXdefXghi '*X*i'\n+match 0 ab/cXd/efXg/hi '*X*i'\n+match 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n+match 1 ab/cXd/efXg/hi '**/*X*/**/*i'\n \n pathmatch 1 foo foo\n pathmatch 0 foo fo\n@@ -248,20 +248,20 @@ pathmatch 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n pathmatch 1 ab/cXd/efXg/hi '*Xg*i'\n \n # Case-sensitivity features\n-match 0 x 'a' '[A-Z]'\n-match 1 x 'A' '[A-Z]'\n-match 0 x 'A' '[a-z]'\n-match 1 x 'a' '[a-z]'\n-match 0 x 'a' '[[:upper:]]'\n-match 1 x 'A' '[[:upper:]]'\n-match 0 x 'A' '[[:lower:]]'\n-match 1 x 'a' '[[:lower:]]'\n-match 0 x 'A' '[B-Za]'\n-match 1 x 'a' '[B-Za]'\n-match 0 x 'A' '[B-a]'\n-match 1 x 'a' '[B-a]'\n-match 0 x 'z' '[Z-y]'\n-match 1 x 'Z' '[Z-y]'\n+match 0 'a' '[A-Z]'\n+match 1 'A' '[A-Z]'\n+match 0 'A' '[a-z]'\n+match 1 'a' '[a-z]'\n+match 0 'a' '[[:upper:]]'\n+match 1 'A' '[[:upper:]]'\n+match 0 'A' '[[:lower:]]'\n+match 1 'a' '[[:lower:]]'\n+match 0 'A' '[B-Za]'\n+match 1 'a' '[B-Za]'\n+match 0 'A' '[B-a]'\n+match 1 'a' '[B-a]'\n+match 0 'z' '[Z-y]'\n+match 1 'Z' '[Z-y]'\n \n imatch 1 'a' '[A-Z]'\n imatch 1 'A' '[A-Z]'\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335850","messageId":"20180104192657.28019-7-avarab@gmail.com","threadId":"47493","inReplyTo":"20180104192657.28019-1-avarab@gmail.com","subject":"[PATCH v4 6/7] wildmatch test: perform all tests under all wildmatch() modes","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-04T19:26:56Z","receivedAt":"2018-01-04T19:28:00Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Rewrite the wildmatch() test suite so that each test now tests all\ncombinations of the wildmatch() WM_CASEFOLD and WM_PATHNAME flags.\n\nBefore this change some test inputs were not tested on\ne.g. WM_PATHNAME. Now the function is stress tested on all possible\ninputs, and for each input we declare what the result should be if the\nmode is case-insensitive, or pathname matching, or case-sensitive or\nnot matching pathnames.\n\nAlso before this change, nothing was testing case-insensitive\nnon-pathname matching, so I've added that to test-wildmatch.c and made\nuse of it.\n\nThis yields a rather scary patch, but there are no functional changes\nhere, just more test coverage. Some now-redundant tests were deleted\nas a result of this change, since they were now duplicating an earlier\ntest.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/helper/test-wildmatch.c |   2 +\n t/t3070-wildmatch.sh      | 478 +++++++++++++++++++++++-----------------------\n 2 files changed, 239 insertions(+), 241 deletions(-)\n\ndiff --git a/t/helper/test-wildmatch.c b/t/helper/test-wildmatch.c\nindex 921d7b3e7e..66d33dfcfd 100644\n--- a/t/helper/test-wildmatch.c\n+++ b/t/helper/test-wildmatch.c\n@@ -16,6 +16,8 @@ int cmd_main(int argc, const char **argv)\n \t\treturn !!wildmatch(argv[3], argv[2], WM_PATHNAME | WM_CASEFOLD);\n \telse if (!strcmp(argv[1], \"pathmatch\"))\n \t\treturn !!wildmatch(argv[3], argv[2], 0);\n+\telse if (!strcmp(argv[1], \"ipathmatch\"))\n+\t\treturn !!wildmatch(argv[3], argv[2], WM_CASEFOLD);\n \telse\n \t\treturn 1;\n }\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 2f8a681c72..06db053ae2 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -4,278 +4,274 @@ test_description='wildmatch tests'\n \n . ./test-lib.sh\n \n-match() {\n-\tif test \"$1\" = 1\n+wildtest() {\n+\tmatch_w_glob=$1\n+\tmatch_w_globi=$2\n+\tmatch_w_pathmatch=$3\n+\tmatch_w_pathmatchi=$4\n+\ttext=$5\n+\tpattern=$6\n+\n+\tif test \"$match_w_glob\" = 1\n \tthen\n-\t\ttest_expect_success \"wildmatch: match '$2' '$3'\" \"\n-\t\t\ttest-wildmatch wildmatch '$2' '$3'\n+\t\ttest_expect_success \"wildmatch: match '$text' '$pattern'\" \"\n+\t\t\ttest-wildmatch wildmatch '$text' '$pattern'\n \t\t\"\n-\telif test \"$1\" = 0\n+\telif test \"$match_w_glob\" = 0\n \tthen\n-\t\ttest_expect_success \"wildmatch: no match '$2' '$3'\" \"\n-\t\t\t! test-wildmatch wildmatch '$2' '$3'\n+\t\ttest_expect_success \"wildmatch: no match '$text' '$pattern'\" \"\n+\t\t\t! test-wildmatch wildmatch '$text' '$pattern'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_glob\" 'false'\n \tfi\n-}\n \n-imatch() {\n-\tif test \"$1\" = 1\n+\tif test \"$match_w_globi\" = 1\n \tthen\n-\t\ttest_expect_success \"iwildmatch: match '$2' '$3'\" \"\n-\t\t\ttest-wildmatch iwildmatch '$2' '$3'\n+\t\ttest_expect_success \"iwildmatch: match '$text' '$pattern'\" \"\n+\t\t\ttest-wildmatch iwildmatch '$text' '$pattern'\n \t\t\"\n-\telif test \"$1\" = 0\n+\telif test \"$match_w_globi\" = 0\n \tthen\n-\t\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n-\t\t\t! test-wildmatch iwildmatch '$2' '$3'\n+\t\ttest_expect_success \"iwildmatch: no match '$text' '$pattern'\" \"\n+\t\t\t! test-wildmatch iwildmatch '$text' '$pattern'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_globi\" 'false'\n \tfi\n-}\n \n-pathmatch() {\n-\tif test \"$1\" = 1\n+\tif test \"$match_w_pathmatch\" = 1\n \tthen\n-\t\ttest_expect_success \"pathmatch: match '$2' '$3'\" \"\n-\t\t\ttest-wildmatch pathmatch '$2' '$3'\n+\t\ttest_expect_success \"pathmatch: match '$text' '$pattern'\" \"\n+\t\t\ttest-wildmatch pathmatch '$text' '$pattern'\n \t\t\"\n-\telif test \"$1\" = 0\n+\telif test \"$match_w_pathmatch\" = 0\n \tthen\n-\t\ttest_expect_success \"pathmatch: no match '$2' '$3'\" \"\n-\t\t\t! test-wildmatch pathmatch '$2' '$3'\n+\t\ttest_expect_success \"pathmatch: no match '$text' '$pattern'\" \"\n+\t\t\t! test-wildmatch pathmatch '$text' '$pattern'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_pathmatch\" 'false'\n+\tfi\n+\n+\tif test \"$match_w_pathmatchi\" = 1\n+\tthen\n+\t\ttest_expect_success \"ipathmatch: match '$text' '$pattern'\" \"\n+\t\t\ttest-wildmatch ipathmatch '$text' '$pattern'\n+\t\t\"\n+\telif test \"$match_w_pathmatchi\" = 0\n+\tthen\n+\t\ttest_expect_success \"ipathmatch: no match '$text' '$pattern'\" \"\n+\t\t\t! test-wildmatch ipathmatch '$text' '$pattern'\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_pathmatchi\" 'false'\n \tfi\n }\n \n-# Basic wildmat features\n-match 1 foo foo\n-match 0 foo bar\n-match 1 '' \"\"\n-match 1 foo '???'\n-match 0 foo '??'\n-match 1 foo '*'\n-match 1 foo 'f*'\n-match 0 foo '*f'\n-match 1 foo '*foo*'\n-match 1 foobar '*ob*a*r*'\n-match 1 aaaaaaabababab '*ab'\n-match 1 'foo*' 'foo\\*'\n-match 0 foobar 'foo\\*bar'\n-match 1 'f\\oo' 'f\\\\oo'\n-match 1 ball '*[al]?'\n-match 0 ten '[ten]'\n-match 0 ten '**[!te]'\n-match 0 ten '**[!ten]'\n-match 1 ten 't[a-g]n'\n-match 0 ten 't[!a-g]n'\n-match 1 ton 't[!a-g]n'\n-match 1 ton 't[^a-g]n'\n-match 1 'a]b' 'a[]]b'\n-match 1 a-b 'a[]-]b'\n-match 1 'a]b' 'a[]-]b'\n-match 0 aab 'a[]-]b'\n-match 1 aab 'a[]a-]b'\n-match 1 ']' ']'\n+# Basic wildmatch features\n+wildtest 1 1 1 1 foo foo\n+wildtest 0 0 0 0 foo bar\n+wildtest 1 1 1 1 '' \"\"\n+wildtest 1 1 1 1 foo '???'\n+wildtest 0 0 0 0 foo '??'\n+wildtest 1 1 1 1 foo '*'\n+wildtest 1 1 1 1 foo 'f*'\n+wildtest 0 0 0 0 foo '*f'\n+wildtest 1 1 1 1 foo '*foo*'\n+wildtest 1 1 1 1 foobar '*ob*a*r*'\n+wildtest 1 1 1 1 aaaaaaabababab '*ab'\n+wildtest 1 1 1 1 'foo*' 'foo\\*'\n+wildtest 0 0 0 0 foobar 'foo\\*bar'\n+wildtest 1 1 1 1 'f\\oo' 'f\\\\oo'\n+wildtest 1 1 1 1 ball '*[al]?'\n+wildtest 0 0 0 0 ten '[ten]'\n+wildtest 0 0 1 1 ten '**[!te]'\n+wildtest 0 0 0 0 ten '**[!ten]'\n+wildtest 1 1 1 1 ten 't[a-g]n'\n+wildtest 0 0 0 0 ten 't[!a-g]n'\n+wildtest 1 1 1 1 ton 't[!a-g]n'\n+wildtest 1 1 1 1 ton 't[^a-g]n'\n+wildtest 1 1 1 1 'a]b' 'a[]]b'\n+wildtest 1 1 1 1 a-b 'a[]-]b'\n+wildtest 1 1 1 1 'a]b' 'a[]-]b'\n+wildtest 0 0 0 0 aab 'a[]-]b'\n+wildtest 1 1 1 1 aab 'a[]a-]b'\n+wildtest 1 1 1 1 ']' ']'\n \n # Extended slash-matching features\n-match 0 'foo/baz/bar' 'foo*bar'\n-match 0 'foo/baz/bar' 'foo**bar'\n-match 0 'foobazbar' 'foo**bar'\n-match 1 'foo/baz/bar' 'foo/**/bar'\n-match 1 'foo/baz/bar' 'foo/**/**/bar'\n-match 1 'foo/b/a/z/bar' 'foo/**/bar'\n-match 1 'foo/b/a/z/bar' 'foo/**/**/bar'\n-match 1 'foo/bar' 'foo/**/bar'\n-match 1 'foo/bar' 'foo/**/**/bar'\n-match 0 'foo/bar' 'foo?bar'\n-match 0 'foo/bar' 'foo[/]bar'\n-match 0 'foo/bar' 'foo[^a-z]bar'\n-match 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 'foo' '**/foo'\n-match 1 'XXX/foo' '**/foo'\n-match 1 'bar/baz/foo' '**/foo'\n-match 0 'bar/baz/foo' '*/foo'\n-match 0 'foo/bar/baz' '**/bar*'\n-match 1 'deep/foo/bar/baz' '**/bar/*'\n-match 0 'deep/foo/bar/baz/' '**/bar/*'\n-match 1 'deep/foo/bar/baz/' '**/bar/**'\n-match 0 'deep/foo/bar' '**/bar/*'\n-match 1 'deep/foo/bar/' '**/bar/**'\n-match 0 'foo/bar/baz' '**/bar**'\n-match 1 'foo/bar/baz/x' '*/bar/**'\n-match 0 'deep/foo/bar/baz/x' '*/bar/**'\n-match 1 'deep/foo/bar/baz/x' '**/bar/*/*'\n+wildtest 0 0 1 1 'foo/baz/bar' 'foo*bar'\n+wildtest 0 0 1 1 'foo/baz/bar' 'foo**bar'\n+wildtest 0 0 1 1 'foobazbar' 'foo**bar'\n+wildtest 1 1 1 1 'foo/baz/bar' 'foo/**/bar'\n+wildtest 1 1 0 0 'foo/baz/bar' 'foo/**/**/bar'\n+wildtest 1 1 1 1 'foo/b/a/z/bar' 'foo/**/bar'\n+wildtest 1 1 1 1 'foo/b/a/z/bar' 'foo/**/**/bar'\n+wildtest 1 1 0 0 'foo/bar' 'foo/**/bar'\n+wildtest 1 1 0 0 'foo/bar' 'foo/**/**/bar'\n+wildtest 0 0 1 1 'foo/bar' 'foo?bar'\n+wildtest 0 0 1 1 'foo/bar' 'foo[/]bar'\n+wildtest 0 0 1 1 'foo/bar' 'foo[^a-z]bar'\n+wildtest 0 0 1 1 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+wildtest 1 1 1 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+wildtest 1 1 0 0 'foo' '**/foo'\n+wildtest 1 1 1 1 'XXX/foo' '**/foo'\n+wildtest 1 1 1 1 'bar/baz/foo' '**/foo'\n+wildtest 0 0 1 1 'bar/baz/foo' '*/foo'\n+wildtest 0 0 1 1 'foo/bar/baz' '**/bar*'\n+wildtest 1 1 1 1 'deep/foo/bar/baz' '**/bar/*'\n+wildtest 0 0 1 1 'deep/foo/bar/baz/' '**/bar/*'\n+wildtest 1 1 1 1 'deep/foo/bar/baz/' '**/bar/**'\n+wildtest 0 0 0 0 'deep/foo/bar' '**/bar/*'\n+wildtest 1 1 1 1 'deep/foo/bar/' '**/bar/**'\n+wildtest 0 0 1 1 'foo/bar/baz' '**/bar**'\n+wildtest 1 1 1 1 'foo/bar/baz/x' '*/bar/**'\n+wildtest 0 0 1 1 'deep/foo/bar/baz/x' '*/bar/**'\n+wildtest 1 1 1 1 'deep/foo/bar/baz/x' '**/bar/*/*'\n \n # Various additional tests\n-match 0 'acrt' 'a[c-c]st'\n-match 1 'acrt' 'a[c-c]rt'\n-match 0 ']' '[!]-]'\n-match 1 'a' '[!]-]'\n-match 0 '' '\\'\n-match 0 '\\' '\\'\n-match 0 'XXX/\\' '*/\\'\n-match 1 'XXX/\\' '*/\\\\'\n-match 1 'foo' 'foo'\n-match 1 '@foo' '@foo'\n-match 0 'foo' '@foo'\n-match 1 '[ab]' '\\[ab]'\n-match 1 '[ab]' '[[]ab]'\n-match 1 '[ab]' '[[:]ab]'\n-match 0 '[ab]' '[[::]ab]'\n-match 1 '[ab]' '[[:digit]ab]'\n-match 1 '[ab]' '[\\[:]ab]'\n-match 1 '?a?b' '\\??\\?b'\n-match 1 'abc' '\\a\\b\\c'\n-match 0 'foo' ''\n-match 1 'foo/bar/baz/to' '**/t[o]'\n+wildtest 0 0 0 0 'acrt' 'a[c-c]st'\n+wildtest 1 1 1 1 'acrt' 'a[c-c]rt'\n+wildtest 0 0 0 0 ']' '[!]-]'\n+wildtest 1 1 1 1 'a' '[!]-]'\n+wildtest 0 0 0 0 '' '\\'\n+wildtest 0 0 0 0 '\\' '\\'\n+wildtest 0 0 0 0 'XXX/\\' '*/\\'\n+wildtest 1 1 1 1 'XXX/\\' '*/\\\\'\n+wildtest 1 1 1 1 'foo' 'foo'\n+wildtest 1 1 1 1 '@foo' '@foo'\n+wildtest 0 0 0 0 'foo' '@foo'\n+wildtest 1 1 1 1 '[ab]' '\\[ab]'\n+wildtest 1 1 1 1 '[ab]' '[[]ab]'\n+wildtest 1 1 1 1 '[ab]' '[[:]ab]'\n+wildtest 0 0 0 0 '[ab]' '[[::]ab]'\n+wildtest 1 1 1 1 '[ab]' '[[:digit]ab]'\n+wildtest 1 1 1 1 '[ab]' '[\\[:]ab]'\n+wildtest 1 1 1 1 '?a?b' '\\??\\?b'\n+wildtest 1 1 1 1 'abc' '\\a\\b\\c'\n+wildtest 0 0 0 0 'foo' ''\n+wildtest 1 1 1 1 'foo/bar/baz/to' '**/t[o]'\n \n # Character class tests\n-match 1 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n-match 0 'a' '[[:digit:][:upper:][:space:]]'\n-match 1 'A' '[[:digit:][:upper:][:space:]]'\n-match 1 '1' '[[:digit:][:upper:][:space:]]'\n-match 0 '1' '[[:digit:][:upper:][:spaci:]]'\n-match 1 ' ' '[[:digit:][:upper:][:space:]]'\n-match 0 '.' '[[:digit:][:upper:][:space:]]'\n-match 1 '.' '[[:digit:][:punct:][:space:]]'\n-match 1 '5' '[[:xdigit:]]'\n-match 1 'f' '[[:xdigit:]]'\n-match 1 'D' '[[:xdigit:]]'\n-match 1 '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n-match 1 '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n-match 1 '5' '[a-c[:digit:]x-z]'\n-match 1 'b' '[a-c[:digit:]x-z]'\n-match 1 'y' '[a-c[:digit:]x-z]'\n-match 0 'q' '[a-c[:digit:]x-z]'\n-\n-# Additional tests, including some malformed wildmats\n-match 1 ']' '[\\\\-^]'\n-match 0 '[' '[\\\\-^]'\n-match 1 '-' '[\\-_]'\n-match 1 ']' '[\\]]'\n-match 0 '\\]' '[\\]]'\n-match 0 '\\' '[\\]]'\n-match 0 'ab' 'a[]b'\n-match 0 'a[]b' 'a[]b'\n-match 0 'ab[' 'ab['\n-match 0 'ab' '[!'\n-match 0 'ab' '[-'\n-match 1 '-' '[-]'\n-match 0 '-' '[a-'\n-match 0 '-' '[!a-'\n-match 1 '-' '[--A]'\n-match 1 '5' '[--A]'\n-match 1 ' ' '[ --]'\n-match 1 '$' '[ --]'\n-match 1 '-' '[ --]'\n-match 0 '0' '[ --]'\n-match 1 '-' '[---]'\n-match 1 '-' '[------]'\n-match 0 'j' '[a-e-n]'\n-match 1 '-' '[a-e-n]'\n-match 1 'a' '[!------]'\n-match 0 '[' '[]-a]'\n-match 1 '^' '[]-a]'\n-match 0 '^' '[!]-a]'\n-match 1 '[' '[!]-a]'\n-match 1 '^' '[a^bc]'\n-match 1 '-b]' '[a-]b]'\n-match 0 '\\' '[\\]'\n-match 1 '\\' '[\\\\]'\n-match 0 '\\' '[!\\\\]'\n-match 1 'G' '[A-\\\\]'\n-match 0 'aaabbb' 'b*a'\n-match 0 'aabcaa' '*ba*'\n-match 1 ',' '[,]'\n-match 1 ',' '[\\\\,]'\n-match 1 '\\' '[\\\\,]'\n-match 1 '-' '[,-.]'\n-match 0 '+' '[,-.]'\n-match 0 '-.]' '[,-.]'\n-match 1 '2' '[\\1-\\3]'\n-match 1 '3' '[\\1-\\3]'\n-match 0 '4' '[\\1-\\3]'\n-match 1 '\\' '[[-\\]]'\n-match 1 '[' '[[-\\]]'\n-match 1 ']' '[[-\\]]'\n-match 0 '-' '[[-\\]]'\n+wildtest 1 1 1 1 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n+wildtest 0 1 0 1 'a' '[[:digit:][:upper:][:space:]]'\n+wildtest 1 1 1 1 'A' '[[:digit:][:upper:][:space:]]'\n+wildtest 1 1 1 1 '1' '[[:digit:][:upper:][:space:]]'\n+wildtest 0 0 0 0 '1' '[[:digit:][:upper:][:spaci:]]'\n+wildtest 1 1 1 1 ' ' '[[:digit:][:upper:][:space:]]'\n+wildtest 0 0 0 0 '.' '[[:digit:][:upper:][:space:]]'\n+wildtest 1 1 1 1 '.' '[[:digit:][:punct:][:space:]]'\n+wildtest 1 1 1 1 '5' '[[:xdigit:]]'\n+wildtest 1 1 1 1 'f' '[[:xdigit:]]'\n+wildtest 1 1 1 1 'D' '[[:xdigit:]]'\n+wildtest 1 1 1 1 '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n+wildtest 1 1 1 1 '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n+wildtest 1 1 1 1 '5' '[a-c[:digit:]x-z]'\n+wildtest 1 1 1 1 'b' '[a-c[:digit:]x-z]'\n+wildtest 1 1 1 1 'y' '[a-c[:digit:]x-z]'\n+wildtest 0 0 0 0 'q' '[a-c[:digit:]x-z]'\n \n-# Test recursion and the abort code (use \"wildtest -i\" to see iteration counts)\n-match 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 1 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n-match 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n-match 0 foo '*/*/*'\n-match 0 foo/bar '*/*/*'\n-match 1 foo/bba/arr '*/*/*'\n-match 0 foo/bb/aa/rr '*/*/*'\n-match 1 foo/bb/aa/rr '**/**/**'\n-match 1 abcXdefXghi '*X*i'\n-match 0 ab/cXd/efXg/hi '*X*i'\n-match 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n-match 1 ab/cXd/efXg/hi '**/*X*/**/*i'\n+# Additional tests, including some malformed wildmatch patterns\n+wildtest 1 1 1 1 ']' '[\\\\-^]'\n+wildtest 0 0 0 0 '[' '[\\\\-^]'\n+wildtest 1 1 1 1 '-' '[\\-_]'\n+wildtest 1 1 1 1 ']' '[\\]]'\n+wildtest 0 0 0 0 '\\]' '[\\]]'\n+wildtest 0 0 0 0 '\\' '[\\]]'\n+wildtest 0 0 0 0 'ab' 'a[]b'\n+wildtest 0 0 0 0 'a[]b' 'a[]b'\n+wildtest 0 0 0 0 'ab[' 'ab['\n+wildtest 0 0 0 0 'ab' '[!'\n+wildtest 0 0 0 0 'ab' '[-'\n+wildtest 1 1 1 1 '-' '[-]'\n+wildtest 0 0 0 0 '-' '[a-'\n+wildtest 0 0 0 0 '-' '[!a-'\n+wildtest 1 1 1 1 '-' '[--A]'\n+wildtest 1 1 1 1 '5' '[--A]'\n+wildtest 1 1 1 1 ' ' '[ --]'\n+wildtest 1 1 1 1 '$' '[ --]'\n+wildtest 1 1 1 1 '-' '[ --]'\n+wildtest 0 0 0 0 '0' '[ --]'\n+wildtest 1 1 1 1 '-' '[---]'\n+wildtest 1 1 1 1 '-' '[------]'\n+wildtest 0 0 0 0 'j' '[a-e-n]'\n+wildtest 1 1 1 1 '-' '[a-e-n]'\n+wildtest 1 1 1 1 'a' '[!------]'\n+wildtest 0 0 0 0 '[' '[]-a]'\n+wildtest 1 1 1 1 '^' '[]-a]'\n+wildtest 0 0 0 0 '^' '[!]-a]'\n+wildtest 1 1 1 1 '[' '[!]-a]'\n+wildtest 1 1 1 1 '^' '[a^bc]'\n+wildtest 1 1 1 1 '-b]' '[a-]b]'\n+wildtest 0 0 0 0 '\\' '[\\]'\n+wildtest 1 1 1 1 '\\' '[\\\\]'\n+wildtest 0 0 0 0 '\\' '[!\\\\]'\n+wildtest 1 1 1 1 'G' '[A-\\\\]'\n+wildtest 0 0 0 0 'aaabbb' 'b*a'\n+wildtest 0 0 0 0 'aabcaa' '*ba*'\n+wildtest 1 1 1 1 ',' '[,]'\n+wildtest 1 1 1 1 ',' '[\\\\,]'\n+wildtest 1 1 1 1 '\\' '[\\\\,]'\n+wildtest 1 1 1 1 '-' '[,-.]'\n+wildtest 0 0 0 0 '+' '[,-.]'\n+wildtest 0 0 0 0 '-.]' '[,-.]'\n+wildtest 1 1 1 1 '2' '[\\1-\\3]'\n+wildtest 1 1 1 1 '3' '[\\1-\\3]'\n+wildtest 0 0 0 0 '4' '[\\1-\\3]'\n+wildtest 1 1 1 1 '\\' '[[-\\]]'\n+wildtest 1 1 1 1 '[' '[[-\\]]'\n+wildtest 1 1 1 1 ']' '[[-\\]]'\n+wildtest 0 0 0 0 '-' '[[-\\]]'\n \n-pathmatch 1 foo foo\n-pathmatch 0 foo fo\n-pathmatch 1 foo/bar foo/bar\n-pathmatch 1 foo/bar 'foo/*'\n-pathmatch 1 foo/bba/arr 'foo/*'\n-pathmatch 1 foo/bba/arr 'foo/**'\n-pathmatch 1 foo/bba/arr 'foo*'\n-pathmatch 1 foo/bba/arr 'foo**'\n-pathmatch 1 foo/bba/arr 'foo/*arr'\n-pathmatch 1 foo/bba/arr 'foo/**arr'\n-pathmatch 0 foo/bba/arr 'foo/*z'\n-pathmatch 0 foo/bba/arr 'foo/**z'\n-pathmatch 1 foo/bar 'foo?bar'\n-pathmatch 1 foo/bar 'foo[/]bar'\n-pathmatch 1 foo/bar 'foo[^a-z]bar'\n-pathmatch 0 foo '*/*/*'\n-pathmatch 0 foo/bar '*/*/*'\n-pathmatch 1 foo/bba/arr '*/*/*'\n-pathmatch 1 foo/bb/aa/rr '*/*/*'\n-pathmatch 1 abcXdefXghi '*X*i'\n-pathmatch 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n-pathmatch 1 ab/cXd/efXg/hi '*Xg*i'\n+# Test recursion\n+wildtest 1 1 1 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+wildtest 0 0 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+wildtest 0 0 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+wildtest 1 1 1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+wildtest 0 0 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+wildtest 1 1 1 1 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n+wildtest 0 0 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n+wildtest 0 0 0 0 foo '*/*/*'\n+wildtest 0 0 0 0 foo/bar '*/*/*'\n+wildtest 1 1 1 1 foo/bba/arr '*/*/*'\n+wildtest 0 0 1 1 foo/bb/aa/rr '*/*/*'\n+wildtest 1 1 1 1 foo/bb/aa/rr '**/**/**'\n+wildtest 1 1 1 1 abcXdefXghi '*X*i'\n+wildtest 0 0 1 1 ab/cXd/efXg/hi '*X*i'\n+wildtest 1 1 1 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n+wildtest 1 1 1 1 ab/cXd/efXg/hi '**/*X*/**/*i'\n \n-# Case-sensitivity features\n-match 0 'a' '[A-Z]'\n-match 1 'A' '[A-Z]'\n-match 0 'A' '[a-z]'\n-match 1 'a' '[a-z]'\n-match 0 'a' '[[:upper:]]'\n-match 1 'A' '[[:upper:]]'\n-match 0 'A' '[[:lower:]]'\n-match 1 'a' '[[:lower:]]'\n-match 0 'A' '[B-Za]'\n-match 1 'a' '[B-Za]'\n-match 0 'A' '[B-a]'\n-match 1 'a' '[B-a]'\n-match 0 'z' '[Z-y]'\n-match 1 'Z' '[Z-y]'\n+# Extra pathmatch tests\n+wildtest 0 0 0 0 foo fo\n+wildtest 1 1 1 1 foo/bar foo/bar\n+wildtest 1 1 1 1 foo/bar 'foo/*'\n+wildtest 0 0 1 1 foo/bba/arr 'foo/*'\n+wildtest 1 1 1 1 foo/bba/arr 'foo/**'\n+wildtest 0 0 1 1 foo/bba/arr 'foo*'\n+wildtest 0 0 1 1 foo/bba/arr 'foo**'\n+wildtest 0 0 1 1 foo/bba/arr 'foo/*arr'\n+wildtest 0 0 1 1 foo/bba/arr 'foo/**arr'\n+wildtest 0 0 0 0 foo/bba/arr 'foo/*z'\n+wildtest 0 0 0 0 foo/bba/arr 'foo/**z'\n+wildtest 0 0 1 1 foo/bar 'foo?bar'\n+wildtest 0 0 1 1 foo/bar 'foo[/]bar'\n+wildtest 0 0 1 1 foo/bar 'foo[^a-z]bar'\n+wildtest 0 0 1 1 ab/cXd/efXg/hi '*Xg*i'\n \n-imatch 1 'a' '[A-Z]'\n-imatch 1 'A' '[A-Z]'\n-imatch 1 'A' '[a-z]'\n-imatch 1 'a' '[a-z]'\n-imatch 1 'a' '[[:upper:]]'\n-imatch 1 'A' '[[:upper:]]'\n-imatch 1 'A' '[[:lower:]]'\n-imatch 1 'a' '[[:lower:]]'\n-imatch 1 'A' '[B-Za]'\n-imatch 1 'a' '[B-Za]'\n-imatch 1 'A' '[B-a]'\n-imatch 1 'a' '[B-a]'\n-imatch 1 'z' '[Z-y]'\n-imatch 1 'Z' '[Z-y]'\n+# Extra case-sensitivity tests\n+wildtest 0 1 0 1 'a' '[A-Z]'\n+wildtest 1 1 1 1 'A' '[A-Z]'\n+wildtest 0 1 0 1 'A' '[a-z]'\n+wildtest 1 1 1 1 'a' '[a-z]'\n+wildtest 0 1 0 1 'a' '[[:upper:]]'\n+wildtest 1 1 1 1 'A' '[[:upper:]]'\n+wildtest 0 1 0 1 'A' '[[:lower:]]'\n+wildtest 1 1 1 1 'a' '[[:lower:]]'\n+wildtest 0 1 0 1 'A' '[B-Za]'\n+wildtest 1 1 1 1 'a' '[B-Za]'\n+wildtest 0 1 0 1 'A' '[B-a]'\n+wildtest 1 1 1 1 'a' '[B-a]'\n+wildtest 0 1 0 1 'z' '[Z-y]'\n+wildtest 1 1 1 1 'Z' '[Z-y]'\n \n test_done\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335851","messageId":"20180104192657.28019-8-avarab@gmail.com","threadId":"47493","inReplyTo":"20180104192657.28019-1-avarab@gmail.com","subject":"[PATCH v4 7/7] wildmatch test: create & test files on disk in addition to in-memory","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-04T19:26:57Z","receivedAt":"2018-01-04T19:28:03Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"There has never been any full roundtrip testing of what git-ls-files\nand other commands that use wildmatch() actually do, rather we've been\nsatisfied with just testing the underlying C function.\n\nDue to git-ls-files and friends having their own codepaths before they\ncall wildmatch() there's sometimes differences in the behavior between\nthe two. Even when we test for those (as with [1]), there was no one\nplace where you can review how these two modes differ.\n\nNow there is. We now attempt to create a file called $haystack and\nmatch $needle against it for each pair of $needle and $haystack that\nwe were passing to test-wildmatch.\n\nIf we can't create the file we skip the test. This ensures that we can\nrun this on all platforms and not maintain some infinitely growing\nwhitelist of e.g. platforms that don't support certain characters in\nfilenames.\n\nAs a result of doing this we can now see the cases where these two\nways of testing wildmatch differ:\n\n * Creating a file called 'a[]b' and running ls-files 'a[]b' will show\n   that file, but wildmatch(\"a[]b\", \"a[]b\") will not match\n\n * wildmatch() won't match a file called \\ against \\, but ls-files\n   will.\n\n * `git --glob-pathspecs ls-files 'foo**'` will match a file\n   'foo/bba/arr', but wildmatch won't, however pathmatch will.\n\n   This seems like a bug to me, the two are otherwise equivalent as\n   these tests show.\n\nThis also reveals the case discussed in [1] above, where '' is now an\nerror as far as ls-files is concerned, but wildmatch() itself happily\naccepts it.\n\n1. 9e4e8a64c2 (\"pathspec: die on empty strings as pathspec\",\n   2017-06-06)\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 301 +++++++++++++++++++++++++++++++++++++++++++++++++--\n 1 file changed, 290 insertions(+), 11 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 06db053ae2..f606f91acb 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -4,14 +4,113 @@ test_description='wildmatch tests'\n \n . ./test-lib.sh\n \n+create_test_file() {\n+\tfile=$1\n+\n+\tcase $file in\n+\t# `touch .` will succeed but obviously not do what we intend\n+\t# here.\n+\t\".\")\n+\t\treturn 1\n+\t\t;;\n+\t# We cannot create a file with an empty filename.\n+\t\"\")\n+\t\treturn 1\n+\t\t;;\n+\t# The tests that are testing that e.g. foo//bar is matched by\n+\t# foo/*/bar can't be tested on filesystems since there's no\n+\t# way we're getting a double slash.\n+\t*//*)\n+\t\treturn 1\n+\t\t;;\n+\t# When testing the difference between foo/bar and foo/bar/ we\n+\t# can't test the latter.\n+\t*/)\n+\t\treturn 1\n+\t\t;;\n+\t# On Windows, \\ in paths is silently converted to /, which\n+\t# would result in the \"touch\" below working, but the test\n+\t# itself failing. See 6fd1106aa4 (\"t3700: Skip a test with\n+\t# backslashes in pathspec\", 2009-03-13) for prior art and\n+\t# details.\n+\t*\\\\*)\n+\t\tif ! test_have_prereq BSLASHPSPEC\n+\t\tthen\n+\t\t\treturn 1\n+\t\tfi\n+\t\t# NOTE: The ;;& bash extension is not portable, so\n+\t\t# this test needs to be at the end of the pattern\n+\t\t# list.\n+\t\t#\n+\t\t# If we want to add more conditional returns we either\n+\t\t# need a new case statement, or turn this whole thing\n+\t\t# into a series of \"if\" tests.\n+\t\t;;\n+\tesac\n+\n+\t# Turn foo/bar/baz into foo/bar to create foo/bar as a\n+\t# directory structure.\n+\tdirs=${file%/*}\n+\n+\t# We touch \"./$file\" instead of \"$file\" because even an\n+\t# escaped \"touch -- -\" means get arguments from stdin.\n+\tif test \"$file\" != \"$dirs\"\n+\tthen\n+\t\tmkdir -p -- \"$dirs\" &&\n+\t\ttouch -- \"./$file\" &&\n+\t\treturn 0\n+\telse\n+\t\ttouch -- \"./$file\" &&\n+\t\treturn 0\n+\tfi\n+\treturn 1\n+}\n+\n+wildtest_file_setup() {\n+\ttest_when_finished \"\n+\t\trm -rf -- * &&\n+\t\tgit reset\n+\t\" &&\n+\tgit add -A &&\n+\t>expect.err\n+}\n+\n+wildtest_stdout_stderr_cmp() {\n+\ttr -d '\\0' <actual.raw >actual &&\n+\ttest_cmp expect.err actual.err &&\n+\ttest_cmp expect actual\n+}\n+\n wildtest() {\n-\tmatch_w_glob=$1\n-\tmatch_w_globi=$2\n-\tmatch_w_pathmatch=$3\n-\tmatch_w_pathmatchi=$4\n-\ttext=$5\n-\tpattern=$6\n+\tif test \"$#\" = 6\n+\tthen\n+\t\t# When test-wildmatch and git ls-files produce the same\n+\t\t# result.\n+\t\tmatch_w_glob=$1\n+\t\tmatch_f_w_glob=$match_w_glob\n+\t\tmatch_w_globi=$2\n+\t\tmatch_f_w_globi=$match_w_globi\n+\t\tmatch_w_pathmatch=$3\n+\t\tmatch_f_w_pathmatch=$match_w_pathmatch\n+\t\tmatch_w_pathmatchi=$4\n+\t\tmatch_f_w_pathmatchi=$match_w_pathmatchi\n+\t\ttext=$5\n+\t\tpattern=$6\n+\telif test \"$#\" = 10\n+\tthen\n+\t\tmatch_w_glob=$1\n+\t\tmatch_w_globi=$2\n+\t\tmatch_w_pathmatch=$3\n+\t\tmatch_w_pathmatchi=$4\n+\t\tmatch_f_w_glob=$5\n+\t\tmatch_f_w_globi=$6\n+\t\tmatch_f_w_pathmatch=$7\n+\t\tmatch_f_w_pathmatchi=$8\n+\t\ttext=$9\n+\t\tpattern=${10}\n+\tfi\n \n+\t# $1: Case sensitive glob match: test-wildmatch\n \tif test \"$match_w_glob\" = 1\n \tthen\n \t\ttest_expect_success \"wildmatch: match '$text' '$pattern'\" \"\n@@ -26,6 +125,50 @@ wildtest() {\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_glob\" 'false'\n \tfi\n \n+\t# $1: Case sensitive glob match: ls-files\n+\tif test \"$match_f_w_glob\" = 'E'\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"wildmatch(ls): match dies on '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\ttest_must_fail git --glob-pathspecs ls-files -z -- '$pattern'\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_glob\" = 1\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"wildmatch(ls): match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\tgit --glob-pathspecs ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_glob\" = 0\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"wildmatch(ls): no match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\t>expect &&\n+\t\t\t\tgit --glob-pathspecs ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): no match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_f_w_glob\" 'false'\n+\tfi\n+\n+\t# $2: Case insensitive glob match: test-wildmatch\n \tif test \"$match_w_globi\" = 1\n \tthen\n \t\ttest_expect_success \"iwildmatch: match '$text' '$pattern'\" \"\n@@ -40,6 +183,50 @@ wildtest() {\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_globi\" 'false'\n \tfi\n \n+\t# $2: Case insensitive glob match: ls-files\n+\tif test \"$match_f_w_globi\" = 'E'\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"iwildmatch(ls): match dies on '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\ttest_must_fail git --glob-pathspecs --icase-pathspecs ls-files -z -- '$pattern'\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"wildmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_globi\" = 1\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"iwildmatch(ls): match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\tgit --glob-pathspecs --icase-pathspecs ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"iwildmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_globi\" = 0\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"iwildmatch(ls): no match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\t>expect &&\n+\t\t\t\tgit --glob-pathspecs --icase-pathspecs ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"iwildmatch(ls): no match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_f_w_globi\" 'false'\n+\tfi\n+\n+\t# $3: Case sensitive path match: test-wildmatch\n \tif test \"$match_w_pathmatch\" = 1\n \tthen\n \t\ttest_expect_success \"pathmatch: match '$text' '$pattern'\" \"\n@@ -54,6 +241,50 @@ wildtest() {\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_pathmatch\" 'false'\n \tfi\n \n+\t# $4: Case sensitive path match: ls-files\n+\tif test \"$match_f_w_pathmatch\" = 'E'\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"pathmatch(ls): match dies on '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\ttest_must_fail git ls-files -z -- '$pattern'\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_pathmatch\" = 1\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"pathmatch(ls): match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\tgit ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_pathmatch\" = 0\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"pathmatch(ls): no match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\t>expect &&\n+\t\t\t\tgit ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): no match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_f_w_pathmatch\" 'false'\n+\tfi\n+\n+\t# $4: Case insensitive path match: test-wildmatch\n \tif test \"$match_w_pathmatchi\" = 1\n \tthen\n \t\ttest_expect_success \"ipathmatch: match '$text' '$pattern'\" \"\n@@ -67,6 +298,49 @@ wildtest() {\n \telse\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_w_pathmatchi\" 'false'\n \tfi\n+\n+\t# $4: Case insensitive path match: ls-files\n+\tif test \"$match_f_w_pathmatchi\" = 'E'\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"ipathmatch(ls): match dies on '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\ttest_must_fail git --icase-pathspecs ls-files -z -- '$pattern'\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"pathmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_pathmatchi\" = 1\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"ipathmatch(ls): match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\tgit --icase-pathspecs ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"ipathmatch(ls): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_f_w_pathmatchi\" = 0\n+\tthen\n+\t\tif create_test_file \"$text\"\n+\t\tthen\n+\t\t\ttest_expect_success \"ipathmatch(ls): no match '$pattern' '$text'\" \"\n+\t\t\t\twildtest_file_setup &&\n+\t\t\t\t>expect &&\n+\t\t\t\tgit ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\twildtest_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"ipathmatch(ls): no match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_f_w_pathmatchi\" 'false'\n+\tfi\n }\n \n # Basic wildmatch features\n@@ -135,7 +409,8 @@ wildtest 1 1 1 1 'acrt' 'a[c-c]rt'\n wildtest 0 0 0 0 ']' '[!]-]'\n wildtest 1 1 1 1 'a' '[!]-]'\n wildtest 0 0 0 0 '' '\\'\n-wildtest 0 0 0 0 '\\' '\\'\n+wildtest 0 0 0 0 \\\n+\t 1 1 1 1 '\\' '\\'\n wildtest 0 0 0 0 'XXX/\\' '*/\\'\n wildtest 1 1 1 1 'XXX/\\' '*/\\\\'\n wildtest 1 1 1 1 'foo' 'foo'\n@@ -149,7 +424,8 @@ wildtest 1 1 1 1 '[ab]' '[[:digit]ab]'\n wildtest 1 1 1 1 '[ab]' '[\\[:]ab]'\n wildtest 1 1 1 1 '?a?b' '\\??\\?b'\n wildtest 1 1 1 1 'abc' '\\a\\b\\c'\n-wildtest 0 0 0 0 'foo' ''\n+wildtest 0 0 0 0 \\\n+\t E E E E 'foo' ''\n wildtest 1 1 1 1 'foo/bar/baz/to' '**/t[o]'\n \n # Character class tests\n@@ -179,8 +455,10 @@ wildtest 1 1 1 1 ']' '[\\]]'\n wildtest 0 0 0 0 '\\]' '[\\]]'\n wildtest 0 0 0 0 '\\' '[\\]]'\n wildtest 0 0 0 0 'ab' 'a[]b'\n-wildtest 0 0 0 0 'a[]b' 'a[]b'\n-wildtest 0 0 0 0 'ab[' 'ab['\n+wildtest 0 0 0 0 \\\n+\t 1 1 1 1 'a[]b' 'a[]b'\n+wildtest 0 0 0 0 \\\n+\t 1 1 1 1 'ab[' 'ab['\n wildtest 0 0 0 0 'ab' '[!'\n wildtest 0 0 0 0 'ab' '[-'\n wildtest 1 1 1 1 '-' '[-]'\n@@ -248,7 +526,8 @@ wildtest 1 1 1 1 foo/bar 'foo/*'\n wildtest 0 0 1 1 foo/bba/arr 'foo/*'\n wildtest 1 1 1 1 foo/bba/arr 'foo/**'\n wildtest 0 0 1 1 foo/bba/arr 'foo*'\n-wildtest 0 0 1 1 foo/bba/arr 'foo**'\n+wildtest 0 0 1 1 \\\n+\t 1 1 1 1 foo/bba/arr 'foo**'\n wildtest 0 0 1 1 foo/bba/arr 'foo/*arr'\n wildtest 0 0 1 1 foo/bba/arr 'foo/**arr'\n wildtest 0 0 0 0 foo/bba/arr 'foo/*z'\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"335932","messageId":"nycvar.QRO.7.76.6.1801051622010.1337@wbunaarf-fpuvaqryva.tvgsbejvaqbjf.bet","threadId":"47493","inReplyTo":"20180104192657.28019-8-avarab@gmail.com","subject":"Re: [PATCH v4 7/7] wildmatch test: create & test files on disk in addition to in-memory","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-01-05T16:41:31Z","receivedAt":"2018-01-05T16:41:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Ævar,\n\nI spent the last 3.5 hours chasing down a bug in your patch series that\nseems to be Windows specific, so please forgive me if the following might\nleak a bit of my frustration into the open...\n\nOn Thu, 4 Jan 2018, Ævar Arnfjörð Bjarmason wrote:\n\n>  t/t3070-wildmatch.sh | 301 +++++++++++++++++++++++++++++++++++++++++++++++++--\n\nWow, this file is ugly. Sorry, that was an outburst, you did not deserve\nthat, but I have to say that it is *really* hard to wrap your head around\nlines like this:\n\n\twildtest 1 1 1 1 'foo*' 'foo\\*'\n\nWhat are those 1s supposed to mean? Granted, for you, the author of this\nline, it is easy.\n\nThe point, though, of regression tests is not only to catch regressions\nbut also to make it easy to fix them. Not only for the test script's\nauthor, but for others, too (and your script is not even the best example\nwe have for a script that needs hours to study before one can even hope to\nbegin to see what is going wrong... I am looking at you, t0027, yes, you.\nYou know why).\n\nSo then I go and see that the `wildtest` function has magic to handle both\n6 and 10 parameters. And those parameters get assigned to variable names\nas intuitive as `match_f_w_pathmatchi`...\n\nThe next thing about the test script is this: calling it with -x is pretty\nmuch useless, because *so much* is happening outside of\ntest_expect_success clauses (and is therefore *not* traced).\n\nOf course I can debug this, but can't this be easier? And this is not even\na regression after a couple of years, this is fresh from the start...\n\nSo here is the first bummer about your rather extensive test (which I\nthink tests the same behavior over and over and over again, just with\nslight variations which however do not matter all that much... for\nexample, it should be enough to verify *without* filenames that the\nglobbing of wildmatch() works, and then a single test *with* a filename\nshould suffice to verify that the connection between globbing and files\nworks): it requires filenames that are illegal on Windows. Stars, question\nmarks: forbidden.\n\nWorse, since we have to use Unix shell scripts to perform our\n\"platform-independent\" tests, we have to rely on a Unix shell interpreter,\nand Git for Windows uses MSYS2's Bash, which means that we inherit most of\nCygwin's behavior.\n\nNow, Cygwin wants to be cute and allow those illegal filenames because (as\nis demonstrated here quite nicely) Unix programmers don't give one bit of\na flying fish about portable filesystem requirements.\n\nSo Cygwin maps those illegal characters into a private Unicode page. Which\nmeans that Cygwin can read them alright, but no non-Cygwin program\nrecognizes the stars and question marks and tabs and newlines. Including\nGit.\n\nIn short: the Unix shell script t3070 manages to write what it thinks is a\nfile called 'foo*', but Git only sees 'foo<some-undisplayable-character>'.\n\nI tried to address this problem with this patch:\n\n-- snip --\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex f606f91acbb..51dcb675e7b 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -4,6 +4,14 @@ test_description='wildmatch tests'\n \n . ./test-lib.sh\n \n+if test_have_prereq !MINGW && touch -- 'a*b' 2>/dev/null\n+then\n+\ttest_set_prereq FILENAMESWITHSTARS\n+else\n+\tsay 'Your filesystem does not allow stars in filenames.'\n+fi\n+rm -f 'a*b'\n+\n create_test_file() {\n \tfile=$1\n \n@@ -28,6 +36,17 @@ create_test_file() {\n \t*/)\n \t\treturn 1\n \t\t;;\n+\t# On Windows, stars are not allowed in filenames. Git for Windows'\n+\t# Bash, however, is based on Cygwin which plays funny names with a\n+\t# private Unicode page to emulate stars in filenames. Meaning that\n+\t# the shell script will \"succeed\" to write the file, but Git will\n+\t# not see it. Nor any other, regular Windows process.\n+\t*\\**|*\\[*)\n+\t\tif ! test_have_prereq FILENAMESWITHSTARS\n+\t\tthen\n+\t\t\treturn 1\n+\t\tfi\n+\t\t;;\n \t# On Windows, \\ in paths is silently converted to /, which\n \t# would result in the \"touch\" below working, but the test\n \t# itself failing. See 6fd1106aa4 (\"t3700: Skip a test with\n-- snap --\n\nThis gets us further. But not by much:\n\nfatal: Invalid path '\\[ab]': No such file or directory\n\nYou see, any path starting with a backslash *is* an absolute path on\nWindows. It is relative to the current drive.\n\nThis affects *quite* a few of the test cases you added.\n\nAnd even if I just comment all of those out, I run into the next problem\nwhere you try to create a file whose name consists of a single space,\nwhich is also illegal on Windows.\n\nThese woes demonstrate one problem with the approach of overzealously\ntesting *everything*. You are kind of performing an integration test of\nthe wildmatch() functionality, the integration into ls-files, *and* of a\nfilesystem that behaves like the filesystems you are used to.\n\nAll you *should* want to test, though, is the wildmatch() functionality.\nAnd *maybe* one or two tests verifying that this wildmatch() functionality\nis actually hooked up into ls-files correctly.\n\nYou do not need to test that 'a*' matches the strings 'a', 'ab', 'abc',\n'abcd', 'abcde', 'abcdef', etc. *and* filenames identical to those\nstrings. If we already verified (lightly) that wildmatch() *works*, then\nwe only have to make sure that ls-files uses wildmatch() correctly.\nEverything else is useless expense of innocent electrons and neurons of\nother developers.\n\nAnother problem with this approach (*extensive* testing of essentially the\nsame stuff over and over again) is what I mentioned earlier: these\ntests are really hard to read, and it is even harder to debug test\nfailures.\n\nAnd lastly, this approach of overzealously testing *everything* simply\ntakes *a lot of time* and also electricity. As a developer of patches who\nruns the entire test suite before submitting every iteration of every\npatch series, this affects me. Others, too, I guess, and they might just\nskip the test suite as a consequence because it takes too long. Don't\nsneer, you know that this is happening.\n\nNeedless to say, I am not enthused.\n\nI would much rather have a lean and mean test script that tested things\nlightly, in more of a unit test fashion: test wildmatch. Just wildmatch.\nNot ls-files, no filesystem, no nothing. There is already\nt/helper/test-wildmatch, for crying out loud. Just feed it test data\ntogether with expected outcomes, will make things much easier to debug,\nfaster to execute, and be a lot easier to read and modify/fix.\n\nWhatever you decide, in the current form this cannot go to master, as it\nfails royally on Windows.\n\nCiao,\nDscho"},{"id":"335943","messageId":"87r2r4azt5.fsf@evledraar.gmail.com","threadId":"47493","inReplyTo":"nycvar.QRO.7.76.6.1801051622010.1337@wbunaarf-fpuvaqryva.tvgsbejvaqbjf.bet","subject":"Re: [PATCH v4 7/7] wildmatch test: create & test files on disk in addition to in-memory","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-05T19:08:38Z","receivedAt":"2018-01-05T19:08:47Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Fri, Jan 05 2018, Johannes Schindelin jotted:\n\n> I spent the last 3.5 hours chasing down a bug in your patch series that\n> seems to be Windows specific, so please forgive me if the following might\n> leak a bit of my frustration into the open...\n\nThanks for looking into this.\n\n> On Thu, 4 Jan 2018, Ævar Arnfjörð Bjarmason wrote:\n>\n>>  t/t3070-wildmatch.sh | 301 +++++++++++++++++++++++++++++++++++++++++++++++++--\n>\n> Wow, this file is ugly. Sorry, that was an outburst, you did not deserve\n> that, but I have to say that it is *really* hard to wrap your head around\n> lines like this:\n>\n> \twildtest 1 1 1 1 'foo*' 'foo\\*'\n>\n> What are those 1s supposed to mean? Granted, for you, the author of this\n> line, it is easy.\n\nJust for some context, this line has looked very similar to this since\nfeabcc173b (\"Integrate wildmatch to git\", 2012-10-15):\n\n    match 1 1 'foo' 'foo'\n\nIt could be made less verbose at the expense of some complexity in\nwildmatch(), i.e.:\n\n    match 1 'foo' 'foo'\n\nWhich would implicitly mean:\n\n    match 1 1 1 1 'foo' 'foo'\n\nBut I thought it was more readable to maintain vertical alignment of the\npatterns, but I'm open to ideas on how to make this less shitty.\n\n> The point, though, of regression tests is not only to catch regressions\n> but also to make it easy to fix them. Not only for the test script's\n> author, but for others, too (and your script is not even the best example\n> we have for a script that needs hours to study before one can even hope to\n> begin to see what is going wrong... I am looking at you, t0027, yes, you.\n> You know why).\n>\n> So then I go and see that the `wildtest` function has magic to handle both\n> 6 and 10 parameters. And those parameters get assigned to variable names\n> as intuitive as `match_f_w_pathmatchi`...\n>\n> The next thing about the test script is this: calling it with -x is pretty\n> much useless, because *so much* is happening outside of\n> test_expect_success clauses (and is therefore *not* traced).\n\nGood point. I guess create_test_file() could create a file only if we\ncan create the test file, and then we run the actual test as a condition\nof that. I.e. to move its logic into a test_expect_success() which would\nalways succeed.\n\n> Of course I can debug this, but can't this be easier? And this is not even\n> a regression after a couple of years, this is fresh from the start...\n>\n> So here is the first bummer about your rather extensive test (which I\n> think tests the same behavior over and over and over again, just with\n> slight variations which however do not matter all that much... for\n> example, it should be enough to verify *without* filenames that the\n> globbing of wildmatch() works, and then a single test *with* a filename\n> should suffice to verify that the connection between globbing and files\n> works): it requires filenames that are illegal on Windows. Stars, question\n> marks: forbidden.\n\nThat's really not the case. The path match code is not simply taking a\nfull path and a pattern and calling wildmatch(), if it was I'd agree\nthat roundtrip testing like this on every single pattern would be\ncompletely pointless.\n\nAs noted in v1\n(https://public-inbox.org/git/20171223213012.1962-1-avarab@gmail.com/)\nthis series came out of my attempts to replace the underlying wildmatch\nengine, which after trying for a bit I found I was blocked by rather bad\nwildmatch test coverage.\n\nI'd make code changes and some random other test would fail, but not\nt3070-wildmatch.sh, which later turned out to be a blindspot that this\nseries rectifies.\n\nA pattern like \"t/**.sh\" isn't just matched against a path like\n\"t/test-lib.sh\" internally, instead we peel off \"t/\" since we know it's\na dir, and then try to match \"**.sh\" against \"test-lib.sh\".\n\nAs 7/7 shows there's several cases where the behavior is different, and\nwithout roundtrip testing like this there's no telling what other case\nmight inadvertently be added in the future.\n\nHowever, read on...\n\n> Worse, since we have to use Unix shell scripts to perform our\n> \"platform-independent\" tests, we have to rely on a Unix shell interpreter,\n> and Git for Windows uses MSYS2's Bash, which means that we inherit most of\n> Cygwin's behavior.\n>\n> Now, Cygwin wants to be cute and allow those illegal filenames because (as\n> is demonstrated here quite nicely) Unix programmers don't give one bit of\n> a flying fish about portable filesystem requirements.\n>\n> So Cygwin maps those illegal characters into a private Unicode page. Which\n> means that Cygwin can read them alright, but no non-Cygwin program\n> recognizes the stars and question marks and tabs and newlines. Including\n> Git.\n>\n> In short: the Unix shell script t3070 manages to write what it thinks is a\n> file called 'foo*', but Git only sees 'foo<some-undisplayable-character>'.\n>\n> I tried to address this problem with this patch:\n\n...I don't see any particular value in trying to do these full roundtrip\ntests on platforms like Windows. Perhaps we should just do these on a\nwhitelist of POSIX systems for now, and leave expanding that list to\nsome future step.\n\n> -- snip --\n> diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\n> index f606f91acbb..51dcb675e7b 100755\n> --- a/t/t3070-wildmatch.sh\n> +++ b/t/t3070-wildmatch.sh\n> @@ -4,6 +4,14 @@ test_description='wildmatch tests'\n>\n>  . ./test-lib.sh\n>\n> +if test_have_prereq !MINGW && touch -- 'a*b' 2>/dev/null\n> +then\n> +\ttest_set_prereq FILENAMESWITHSTARS\n> +else\n> +\tsay 'Your filesystem does not allow stars in filenames.'\n> +fi\n> +rm -f 'a*b'\n> +\n>  create_test_file() {\n>  \tfile=$1\n>\n> @@ -28,6 +36,17 @@ create_test_file() {\n>  \t*/)\n>  \t\treturn 1\n>  \t\t;;\n> +\t# On Windows, stars are not allowed in filenames. Git for Windows'\n> +\t# Bash, however, is based on Cygwin which plays funny names with a\n> +\t# private Unicode page to emulate stars in filenames. Meaning that\n> +\t# the shell script will \"succeed\" to write the file, but Git will\n> +\t# not see it. Nor any other, regular Windows process.\n> +\t*\\**|*\\[*)\n> +\t\tif ! test_have_prereq FILENAMESWITHSTARS\n> +\t\tthen\n> +\t\t\treturn 1\n> +\t\tfi\n> +\t\t;;\n>  \t# On Windows, \\ in paths is silently converted to /, which\n>  \t# would result in the \"touch\" below working, but the test\n>  \t# itself failing. See 6fd1106aa4 (\"t3700: Skip a test with\n> -- snap --\n>\n> This gets us further. But not by much:\n\nOkey, that's very weird. So you can:\n\n    touch \"./*\"; echo $?\n\nAnd it'll return 0 but then the file won't exist?\n\nHow about this:\n\n    touch \"./*\" && test -e \"./*\"; echo $?\n\nI.e. could we more generally just test whether the file got created\nsuccessfully? Does that work on Windows?\n\nThe reason this latest version stopped creating files with \"\\\" in them\nunless under BSLASHPSPEC is because Cygwin would silently translate it,\nso it would create the file but it would actually mean something the\ntests didn't expect.\n\nFor anything else, such as stars not being allowed in filenames I was\nexpecting that \"touch\" command to return an error, but if that's not the\ncase maybe we need the \"test -e\" as well, unless I'm missing something\nhere.\n\n\n> fatal: Invalid path '\\[ab]': No such file or directory\n>\n> You see, any path starting with a backslash *is* an absolute path on\n> Windows. It is relative to the current drive.\n\nRight, which I was trying to avoid by not actually creating \\[ab], but\n\"./\\[ab]\", is that the same filename on Windows?\n\n> This affects *quite* a few of the test cases you added.\n>\n> And even if I just comment all of those out, I run into the next problem\n> where you try to create a file whose name consists of a single space,\n> which is also illegal on Windows.\n\nOkey, but ditto above about touch not catching it, does:\n\n    touch \"./ \"; echo $?\n\nNot return an error? Then how about:\n\n    touch \"./ \" && test -e \"./ \"; echo $?\n\n> These woes demonstrate one problem with the approach of overzealously\n> testing *everything*[...]\n\nI think the rest of this gets into topics I've covered above. I.e. that\nthis increased test coverage has caught bugs.\n"},{"id":"336007","messageId":"nycvar.QRO.7.76.6.1801052133380.1337@wbunaarf-fpuvaqryva.tvgsbejvaqbjf.bet","threadId":"47493","inReplyTo":"87r2r4azt5.fsf@evledraar.gmail.com","subject":"Re: [PATCH v4 7/7] wildmatch test: create & test files on disk in addition to in-memory","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-01-05T20:48:35Z","receivedAt":"2018-01-05T20:48:47Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Ævar,\n\nOn Fri, 5 Jan 2018, Ævar Arnfjörð Bjarmason wrote:\n\n> On Fri, Jan 05 2018, Johannes Schindelin jotted:\n> \n> > [...]\n> >\n> > In short: the Unix shell script t3070 manages to write what it thinks is a\n> > file called 'foo*', but Git only sees 'foo<some-undisplayable-character>'.\n> >\n> > I tried to address this problem with this patch:\n> \n> ...I don't see any particular value in trying to do these full roundtrip\n> tests on platforms like Windows. Perhaps we should just do these on a\n> whitelist of POSIX systems for now, and leave expanding that list to\n> some future step.\n\nI don't think so. Windows is already handled as a second-class citizen, as\nif nobody developed on it. As a consequence, only very few of the\ngazillions of Windows developers... develop Git. We could worsify the\nsituation, of course, but why? Shouldn't we at least pretend to try the\nopposite?\n\n> > -- snip --\n> > diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\n> > index f606f91acbb..51dcb675e7b 100755\n> > --- a/t/t3070-wildmatch.sh\n> > +++ b/t/t3070-wildmatch.sh\n> > @@ -4,6 +4,14 @@ test_description='wildmatch tests'\n> >\n> >  . ./test-lib.sh\n> >\n> > +if test_have_prereq !MINGW && touch -- 'a*b' 2>/dev/null\n> > +then\n> > +\ttest_set_prereq FILENAMESWITHSTARS\n> > +else\n> > +\tsay 'Your filesystem does not allow stars in filenames.'\n> > +fi\n> > +rm -f 'a*b'\n> > +\n> >  create_test_file() {\n> >  \tfile=$1\n> >\n> > @@ -28,6 +36,17 @@ create_test_file() {\n> >  \t*/)\n> >  \t\treturn 1\n> >  \t\t;;\n> > +\t# On Windows, stars are not allowed in filenames. Git for Windows'\n> > +\t# Bash, however, is based on Cygwin which plays funny names with a\n> > +\t# private Unicode page to emulate stars in filenames. Meaning that\n> > +\t# the shell script will \"succeed\" to write the file, but Git will\n> > +\t# not see it. Nor any other, regular Windows process.\n> > +\t*\\**|*\\[*)\n> > +\t\tif ! test_have_prereq FILENAMESWITHSTARS\n> > +\t\tthen\n> > +\t\t\treturn 1\n> > +\t\tfi\n> > +\t\t;;\n> >  \t# On Windows, \\ in paths is silently converted to /, which\n> >  \t# would result in the \"touch\" below working, but the test\n> >  \t# itself failing. See 6fd1106aa4 (\"t3700: Skip a test with\n> > -- snap --\n> >\n> > This gets us further. But not by much:\n> \n> Okey, that's very weird. So you can:\n> \n>     touch \"./*\"; echo $?\n> \n> And it'll return 0 but then the file won't exist?\n\nAlmost. The file exists, but it won't have the name '*'. It will have as\nname a Unicode character that is in a private page, not standardized by\nthe Unicode specification.\n\n> How about this:\n> \n>     touch \"./*\" && test -e \"./*\"; echo $?\n\nWould return 0. Why? Because *you are still in a Unix shell script, so the\nCygwin cuteness still applies*.\n\n> The reason this latest version stopped creating files with \"\\\" in them\n> unless under BSLASHPSPEC is because Cygwin would silently translate it,\n> so it would create the file but it would actually mean something the\n> tests didn't expect.\n\nI understand that. And I would wish that the test would be designed in a\nmore cross-platform-aware mindset.\n\n> For anything else, such as stars not being allowed in filenames I was\n> expecting that \"touch\" command to return an error, but if that's not the\n> case maybe we need the \"test -e\" as well, unless I'm missing something\n> here.\n\nThis is one of the many bad consequences of Git relying so much on Unix\nshell scripting. Despite what many, many, many Git developers think: shell\nscripting is not portable.\n\nCygwin does a good job of pretending that it is, and MSYS2 exacerbates\nthat notion, but it comes back to haunt you right here and right now. The\n`touch` invocation will *report success*, but it will have done something\ndifferent than you wanted. It's like the Thinking: Fast and Slow.\n\n> > fatal: Invalid path '\\[ab]': No such file or directory\n> >\n> > You see, any path starting with a backslash *is* an absolute path on\n> > Windows. It is relative to the current drive.\n> \n> Right, which I was trying to avoid by not actually creating \\[ab], but\n> \"./\\[ab]\", is that the same filename on Windows?\n\nWhoops. I managed to copy-paste the *wrong* command's error message. Sorry\nabout that. The correct one:\n\n$ git --glob-pathspecs ls-files -z -- '\\[ab]'\nfatal: \\[ab]: '\\[ab]' is outside repository\n\nNote how it is Git reporting that you asked for a path that is outside?\nThat's because it thinks you are referring to C:\\[ab] (if your current\ndirectory is on the C: drive).\n\nAnd it would be correct to complain on Windows: the `\\[ab]` parameter\nrefers to an absolute path.\n\n> > This affects *quite* a few of the test cases you added.\n> >\n> > And even if I just comment all of those out, I run into the next problem\n> > where you try to create a file whose name consists of a single space,\n> > which is also illegal on Windows.\n> \n> Okey, but ditto above about touch not catching it, does:\n> \n>     touch \"./ \"; echo $?\n> \n> Not return an error? Then how about:\n> \n>     touch \"./ \" && test -e \"./ \"; echo $?\n\nAgain: as long as you stay within the bounds of the Unix shell script (did\nI point out enough yet how non-portable this design is? Even Subversion\nknew better than to implement parts of its operations as Unix shell\nscripts. I mean, for PoCing, okay, but for production code?) you fall prey\nto Cygwin's emulation of POSIX-y filenames. As soon as you leave that\nbubble (e.g. by calling git.exe), you're not going to see those illegal\nfile names, but the ones with the unprintable Unicode characters.\n\n> > These woes demonstrate one problem with the approach of overzealously\n> > testing *everything*[...]\n> \n> I think the rest of this gets into topics I've covered above. I.e. that\n> this increased test coverage has caught bugs.\n\nThat's all good and dandy, but what about regressions? I know how much I\nwill curse in your vague direction when I encounter the next\nwildmatch-related bug in, say, half a year and have to wade through the\njungle of unintuitive tests in t3070.\n\nCan't we do a lot better than this? Shouldn't it be a lot more obvious\nwhat the heck went wrong when running t3070 with -i -v -x?\n\nCiao,\nJohannes"},{"id":"336021","messageId":"20180105221222.28867-1-avarab@gmail.com","threadId":"47493","inReplyTo":"nycvar.QRO.7.76.6.1801052133380.1337@wbunaarf-fpuvaqryva.tvgsbejvaqbjf.bet","subject":"[PATCH v4 8/7] wildmatch test: skip file creation tests on Windows proper","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-05T22:12:22Z","receivedAt":"2018-01-05T22:12:50Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Skip the newly added file creation tests on Windows proper, these\nalready work under Cygwin, but as that involves a significant\nemulation layer the results are different under Windows proper with\nMinGW.\n\nIdeally we'd get exhaustive coverage for this area on all platforms,\nbut having any increase in test coverage anywhere is a net\nimprovement.\n\nParticularly in this case where there's no reason to suspect (aside\nfrom perhaps odd edge case like \\foo meaning C:\\foo) that the actual\npattern matching engine will behave differently on Windows. The tests\ncan't be run due to limitations elsewhere.\n\nThe thread starting at\nhttps://public-inbox.org/git/?q=nycvar.QRO.7.76.6.1801051622010.1337%40wbunaarf-fpuvaqryva.tvgsbejvaqbjf.bet\nhas more details about specific issues under Windows.\n\nReported-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n\nOn Fri, Jan 05 2018, Johannes Schindelin jotted:\n\n> Hi Ævar,\n>\n> On Fri, 5 Jan 2018, Ævar Arnfjörð Bjarmason wrote:\n>\n>> On Fri, Jan 05 2018, Johannes Schindelin jotted:\n>> \n>> > [...]\n>> >\n>> > In short: the Unix shell script t3070 manages to write what it thinks is a\n>> > file called 'foo*', but Git only sees 'foo<some-undisplayable-character>'.\n>> >\n>> > I tried to address this problem with this patch:\n>> \n>> ...I don't see any particular value in trying to do these full roundtrip\n>> tests on platforms like Windows. Perhaps we should just do these on a\n>> whitelist of POSIX systems for now, and leave expanding that list to\n>> some future step.\n>\n> I don't think so. Windows is already handled as a second-class citizen, as\n> if nobody developed on it. As a consequence, only very few of the\n> gazillions of Windows developers... develop Git. We could worsify the\n> situation, of course, but why? Shouldn't we at least pretend to try the\n> opposite?\n\nI don't think we should never test for this on MinGW, but given the\nincrease in test coverage, and not making perfect the enemy of the\ngood I think (as explained in the commit message above) that we're\nbetter off *starting* with just disabling these tests under MinGW, and\nthen fixing that platform later.\n\n> [...]\n> That's all good and dandy, but what about regressions? I know how much I\n> will curse in your vague direction when I encounter the next\n> wildmatch-related bug in, say, half a year and have to wade through the\n> jungle of unintuitive tests in t3070.\n\nIf we have a new wildmatch-related bug we'll be a lot better off with\nexhaustive test coverage, even if we can only run those tests on\n*nix-like platforms.\n\n> Can't we do a lot better than this? Shouldn't it be a lot more obvious\n> what the heck went wrong when running t3070 with -i -v -x?\n\nI had something closer to that in v1 in\n20171223213012.1962-7-avarab@gmail.com, but trying again I didn't find\na good way to compromise between -x readability and the entire patch\nbasically not being the copy/pasted code all over again, and I think\ne.g. doing string interpolation into the test code would be even\nnastier.\n\n t/t3070-wildmatch.sh | 10 +++++++++-\n 1 file changed, 9 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex f606f91acb..50a53e7a62 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -7,6 +7,14 @@ test_description='wildmatch tests'\n create_test_file() {\n \tfile=$1\n \n+\t# These tests limp along under Cygwin, but the failures on\n+\t# native Windows are still too many. Skip file tests there\n+\t# until they're sorted out.\n+\tif test_have_prereq MINGW\n+\tthen\n+\t\treturn 1\n+\tfi\n+\n \tcase $file in\n \t# `touch .` will succeed but obviously not do what we intend\n \t# here.\n@@ -28,7 +36,7 @@ create_test_file() {\n \t*/)\n \t\treturn 1\n \t\t;;\n-\t# On Windows, \\ in paths is silently converted to /, which\n+\t# On Cygwin, \\ in paths is silently converted to /, which\n \t# would result in the \"touch\" below working, but the test\n \t# itself failing. See 6fd1106aa4 (\"t3700: Skip a test with\n \t# backslashes in pathspec\", 2009-03-13) for prior art and\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"336026","messageId":"xmqqzi5raogu.fsf@gitster.mtv.corp.google.com","threadId":"47493","inReplyTo":"20180105221222.28867-1-avarab@gmail.com","subject":"Re: [PATCH v4 8/7] wildmatch test: skip file creation tests on Windows proper","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-01-05T23:13:37Z","receivedAt":"2018-01-05T23:13:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> Skip the newly added file creation tests on Windows proper, these\n> already work under Cygwin, but as that involves a significant\n> emulation layer the results are different under Windows proper with\n> MinGW.\n> ...\n> diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\n> index f606f91acb..50a53e7a62 100755\n> --- a/t/t3070-wildmatch.sh\n> +++ b/t/t3070-wildmatch.sh\n> @@ -7,6 +7,14 @@ test_description='wildmatch tests'\n>  create_test_file() {\n>  \tfile=$1\n>  \n> +\t# These tests limp along under Cygwin, but the failures on\n> +\t# native Windows are still too many. Skip file tests there\n> +\t# until they're sorted out.\n> +\tif test_have_prereq MINGW\n> +\tthen\n> +\t\treturn 1\n> +\tfi\n> +\n\nThat looks to be a nuclear option.  For now it may be suffice, but\nsomehow it feels that it goes directly against Dscho's wish to treat\n(or pretend to treat) Windows as first-class citizens and/or just\nlike other platforms.\n\n\n"},{"id":"336051","messageId":"nycvar.QRO.7.76.6.1801061337020.1337@wbunaarf-fpuvaqryva.tvgsbejvaqbjf.bet","threadId":"47493","inReplyTo":"xmqqzi5raogu.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v4 8/7] wildmatch test: skip file creation tests on Windows proper","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-01-06T12:51:45Z","receivedAt":"2018-01-06T12:51:59Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Junio,\n\nOn Fri, 5 Jan 2018, Junio C Hamano wrote:\n\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n> \n> > Skip the newly added file creation tests on Windows proper, these\n> > already work under Cygwin, but as that involves a significant\n> > emulation layer the results are different under Windows proper with\n> > MinGW.\n> > ...\n> > diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\n> > index f606f91acb..50a53e7a62 100755\n> > --- a/t/t3070-wildmatch.sh\n> > +++ b/t/t3070-wildmatch.sh\n> > @@ -7,6 +7,14 @@ test_description='wildmatch tests'\n> >  create_test_file() {\n> >  \tfile=$1\n> >  \n> > +\t# These tests limp along under Cygwin, but the failures on\n> > +\t# native Windows are still too many. Skip file tests there\n> > +\t# until they're sorted out.\n> > +\tif test_have_prereq MINGW\n> > +\tthen\n> > +\t\treturn 1\n> > +\tfi\n> > +\n> \n> That looks to be a nuclear option.\n\nIndeed:\n\n\t# still have 84 known breakage(s)\n\t# failed 52 among remaining 1428 test(s)\n\t1..1512\n\nLet's just switch it off completely because 52 of those 1512 test cases\nbreak only on Windows? Pretty heavy-handed.\n\nBut do read on.\n\n> For now it may be suffice, but somehow it feels that it goes directly\n> against Dscho's wish to treat (or pretend to treat) Windows as\n> first-class citizens and/or just like other platforms.\n\nIt not only goes against my wish to treat Windows as a normal citizen\ninstead of like Rey's parents, it also goes against my wish to have a\nfocused and meaningful test suite. Nobody likes to run tests that take too\nlong. And look at this:\n\n\t...\n\tok 1511 - ipathmatch: match 'Z' '[Z-y]'\n\tok 1512 - ipathmatch(ls): match '[Z-y]' 'Z'\n\t# still have 84 known breakage(s)\n\t# failed 52 among remaining 1428 test(s)\n\t1..1512\n\n\treal    5m51.432s\n\tuser    0m33.986s\n\tsys     2m13.162s\n\nYep. It takes *over eight minutes*.\n\nAnd this is a *fast* machine.\n\nWhy? Because of the completely overboard testing of all kinds of\n*potential* breakages *at some point* in the future.\n\nI understand that Ævar wants to increase test coverage. I am sympathetic\nto this cause.\n\nBut I completely disagree that increasing the test coverage beyond reason\nis a good thing. Tests *can* take too long, and they do, in practice, and\nthe results are always problematic: every developer who has to deal with\ntest suites that take too long... does not run them. As simple as that.\nAnd then you have *zero* test coverage. Pretty stupid, eh? And contrary to\nyour intentions, too.\n\nSo yes, I think that it has been proven beyond any doubt that t3070 takes\n*waaaaaaaaaay* too long on Windows, for dubitable benefit.\n\nI could see a reasonable compromise where\n\n- an extensive test matrix is hidden behind an EXPENSIVE_WILDMATCH prereq,\n\n- the test matrix would be written in a much more understandable way, i.e.\n  using English words rather than \"1\"s. If need be, there could be blocks\n  (\"test this with case-sensitive matching\", \"skip case-sensitive matching\",\n  you get the idea),\n\n- these magic skippings of certain test cases (where the (non-traced)\n  `create_test_file()` function returns 1 for certain things) still would\n  need to go away, in favor probably of prereqs and/or blocks where flags\n  are set accordingly in a preamble,\n\n- by default, i.e. without the EXPENSIVE_WILDMATCH prereq, it should test\n  a *tiny* subset that is indicative of the most likely bugs.\n\nAs it is, I like 8/7 in the present form for all the wrong reasons: it\nprotects me from the damage a full t3070 would do to me.\n\nCiao,\nDscho"},{"id":"336053","messageId":"87mv1raz9p.fsf@evledraar.gmail.com","threadId":"47493","inReplyTo":"nycvar.QRO.7.76.6.1801061337020.1337@wbunaarf-fpuvaqryva.tvgsbejvaqbjf.bet","subject":"Re: [PATCH v4 8/7] wildmatch test: skip file creation tests on Windows proper","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-06T13:32:34Z","receivedAt":"2018-01-06T13:32:43Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Sat, Jan 06 2018, Johannes Schindelin jotted:\n\n> Hi Junio,\n>\n> On Fri, 5 Jan 2018, Junio C Hamano wrote:\n>\n>> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>>\n>> > Skip the newly added file creation tests on Windows proper, these\n>> > already work under Cygwin, but as that involves a significant\n>> > emulation layer the results are different under Windows proper with\n>> > MinGW.\n>> > ...\n>> > diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\n>> > index f606f91acb..50a53e7a62 100755\n>> > --- a/t/t3070-wildmatch.sh\n>> > +++ b/t/t3070-wildmatch.sh\n>> > @@ -7,6 +7,14 @@ test_description='wildmatch tests'\n>> >  create_test_file() {\n>> >  \tfile=$1\n>> >\n>> > +\t# These tests limp along under Cygwin, but the failures on\n>> > +\t# native Windows are still too many. Skip file tests there\n>> > +\t# until they're sorted out.\n>> > +\tif test_have_prereq MINGW\n>> > +\tthen\n>> > +\t\treturn 1\n>> > +\tfi\n>> > +\n>>\n>> That looks to be a nuclear option.\n>\n> Indeed:\n>\n> \t# still have 84 known breakage(s)\n> \t# failed 52 among remaining 1428 test(s)\n> \t1..1512\n>\n> Let's just switch it off completely because 52 of those 1512 test cases\n> break only on Windows? Pretty heavy-handed.\n\nCan you please provide me with the output of the test under -v -x -d\nfrom github.com:avar/git.git wildmatch-refactor-8 branch?\n\nIt has some improvements that should make things a bit faster for you,\nbut also most of the logic is now in test_expect_success so -x is more\nhelpful.\n\nI should then be able to fix these 52 remaining cases (and at least 1 of\nthem should be fixed already).\n\n> But do read on.\n>\n>> For now it may be suffice, but somehow it feels that it goes directly\n>> against Dscho's wish to treat (or pretend to treat) Windows as\n>> first-class citizens and/or just like other platforms.\n>\n> It not only goes against my wish to treat Windows as a normal citizen\n> instead of like Rey's parents, it also goes against my wish to have a\n> focused and meaningful test suite. Nobody likes to run tests that take too\n> long. And look at this:\n>\n> \t...\n> \tok 1511 - ipathmatch: match 'Z' '[Z-y]'\n> \tok 1512 - ipathmatch(ls): match '[Z-y]' 'Z'\n> \t# still have 84 known breakage(s)\n> \t# failed 52 among remaining 1428 test(s)\n> \t1..1512\n>\n> \treal    5m51.432s\n> \tuser    0m33.986s\n> \tsys     2m13.162s\n>\n> Yep. It takes *over eight minutes*.\n>\n> And this is a *fast* machine.\n>\n> Why? Because of the completely overboard testing of all kinds of\n> *potential* breakages *at some point* in the future.\n>\n> I understand that Ævar wants to increase test coverage. I am sympathetic\n> to this cause.\n>\n> But I completely disagree that increasing the test coverage beyond reason\n> is a good thing. Tests *can* take too long, and they do, in practice, and\n> the results are always problematic: every developer who has to deal with\n> test suites that take too long... does not run them. As simple as that.\n> And then you have *zero* test coverage. Pretty stupid, eh? And contrary to\n> your intentions, too.\n>\n> So yes, I think that it has been proven beyond any doubt that t3070 takes\n> *waaaaaaaaaay* too long on Windows, for dubitable benefit.\n>\n> I could see a reasonable compromise where\n>\n> - an extensive test matrix is hidden behind an EXPENSIVE_WILDMATCH prereq,\n>\n> - the test matrix would be written in a much more understandable way, i.e.\n>   using English words rather than \"1\"s. If need be, there could be blocks\n>   (\"test this with case-sensitive matching\", \"skip case-sensitive matching\",\n>   you get the idea),\n\nI take your point with the readability of some of this stuff, and will\nget around to fixing that before the next submission.\n\n> - these magic skippings of certain test cases (where the (non-traced)\n>   `create_test_file()` function returns 1 for certain things) still would\n>   need to go away, in favor probably of prereqs and/or blocks where flags\n>   are set accordingly in a preamble,\n\nThis is a lot of work for dubious benefit. I'm not going to try to\nmaintain some exhaustive mapping that's potentially going to be a hash\n4-levels deep of:\n\n    os.os_version.fs.vs_version\n\nAnd that's before we'd get to the potential 6-level crazyness of:\n\n    os.os_version.os_flags.fs.vs_version.fs_flags\n\nIt's way easier and more portable (even to OSs or FSs nobody's invented\nyet) to just test whether a file can be created, and if not skip the\ntest.\n\nAs I explained in 20180105221222.28867-1-avarab@gmail.com the actual\nbenefit of this test is that as much as possible is tested\n*somewhere*. There's no reason to suspect that e.g. Linux will overnight\nmake the character \":\" illegal in filenames and we'll be the only ones\nwho notice it.\n\nSince we don't treat \":\" or any other character differently for the\npurposes of glob matching on Windows, but *do* treat the raw glob\nmatching differently than calling wildmatch() directly, as the current\ntests do, I really don't see what the point of this exercises would be.\n\n> - by default, i.e. without the EXPENSIVE_WILDMATCH prereq, it should test\n>   a *tiny* subset that is indicative of the most likely bugs.\n\n> As it is, I like 8/7 in the present form for all the wrong reasons: it\n> protects me from the damage a full t3070 would do to me.\n\nThis test takes around 8 seconds to run on a 3.4GHz i7 on Linux, and\naround 4 seconds on a 2.6GHz i5 on my SSD laptop on Linux.\n\nI agree that there should be some prerequisite to skip this on Windows\nby default since 6 minutes is clearly excessive (although I think you'll\nfind it runs a bit faster in the branch above), but that should be\nsomething like:\n\n    test_lazy_prereq EXPENSIVE_ON_WINDOWS '\n            test -n \"$GIT_TEST_LONG\" || test_have_prereq !MINGW,!CYGWIN\n    '\n\nAs the long runtime is not inherent to the test, but to excessive\nslowness caused by certain operations on certain platforms, or maybe it\nshould be EXPENSIVE_ON_SLOW_FS or EXPENSIVE_IF_FORKING_IS_SLOW or if\nwe'd like to generalize it.\n"},{"id":"336068","messageId":"nycvar.QRO.7.76.6.1801062116350.1337@wbunaarf-fpuvaqryva.tvgsbejvaqbjf.bet","threadId":"47493","inReplyTo":"87mv1raz9p.fsf@evledraar.gmail.com","subject":"Re: [PATCH v4 8/7] wildmatch test: skip file creation tests on Windows proper","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-01-06T20:46:26Z","receivedAt":"2018-01-06T20:46:42Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Ævar,\n\nOn Sat, 6 Jan 2018, Ævar Arnfjörð Bjarmason wrote:\n\n> As I explained in 20180105221222.28867-1-avarab@gmail.com the actual\n> benefit of this test is that as much as possible is tested\n> *somewhere*.\n\nAnd what I am trying to get across is that your tests are excessive. I do\nnot see the benefit in running such an excessive, overzealous test.\n\nYou say that Linux will not overnight stop supporting colons in filenames,\nwhich kind of misses the point that the question is more about new\nplatforms needing Git support with a *filesystem* that simply does not\nmeet one of your many tests' expectations.\n\nBut what is equally true is that few changes are to be expected in the\nwildmatch code. And you know as well as I that it is possible to come up\nwith a careful, small set of test cases that will most likely identify\nbreakages.\n\nAfter all, when there is a bug in some patch to the wildmatch machinery,\nyou do not need 512 test cases to fail. A single failing test case is\ndefinitely enough.\n\nI'll test the branch you indicated on Monday, just because you put effort\ninto it.\n\nBut please note that it does not change the fact that an effective test\nsuite requires a balance between the need to run fast (if *every* aspect\nof Git was tested as extensively as your current t3070, even on Linux it\nwould take hours and hours to finish the test suite, making it stupidly\nexpensive for everybody to run) and the need to catch regressions.\n\nIt is a well-established rule in effective DevOps that you want lean test\nsuites. Actionable test suites. It is enough for *one* test to fail. When\na test fails, it should be as easy to understand as possible what is going\nwrong. If there are no regressions, the test suite should be passing\n*fast*.\n\nOn Windows, it takes 70-90 minutes *on a fast* machine. That is a huge\nfailure on our part: this is the test suite we designed \"to be portable\".\nAll I am trying to do here is to prevent even more damage. I will\nappreciate any assistance to that end. I understand that most developers\non this list simply don't care. And that's just too bad, because we could\ndo a lot better. And we should, too.\n\nCiao,\nJohannes"},{"id":"336080","messageId":"CACsJy8CDz57RR+VHpaPb5YMhKG5kUgb9rt5TWKL8n+e7Xart3g@mail.gmail.com","threadId":"47493","inReplyTo":"nycvar.QRO.7.76.6.1801061337020.1337@wbunaarf-fpuvaqryva.tvgsbejvaqbjf.bet","subject":"Re: [PATCH v4 8/7] wildmatch test: skip file creation tests on Windows proper","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-07T02:51:39Z","receivedAt":"2018-01-07T02:53:26Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sat, Jan 6, 2018 at 7:51 PM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> Nobody likes to run tests that take too\n> long. And look at this:\n>\n>         ...\n>         ok 1511 - ipathmatch: match 'Z' '[Z-y]'\n>         ok 1512 - ipathmatch(ls): match '[Z-y]' 'Z'\n>         # still have 84 known breakage(s)\n>         # failed 52 among remaining 1428 test(s)\n>         1..1512\n>\n>         real    5m51.432s\n>         user    0m33.986s\n>         sys     2m13.162s\n>\n> Yep. It takes *over eight minutes*.\n\nI suppose this is because the sheer number of test cases adds a lot of\nshell overhead on Windows. I wonder if it's better to rewrite this\ntest in C instead. We start to do some more unit testing here and\nthere and kind of abuse the sh-based test framework for this. Having a\nproper unit test framework would be good anyway since it's sometimes\nhard to create a specific scenario with high level commands.\n-- \nDuy\n"},{"id":"336136","messageId":"nycvar.QRO.7.76.6.1801081319520.31@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz","threadId":"47493","inReplyTo":"CACsJy8CDz57RR+VHpaPb5YMhKG5kUgb9rt5TWKL8n+e7Xart3g@mail.gmail.com","subject":"Re: [PATCH v4 8/7] wildmatch test: skip file creation tests on Windows proper","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-01-08T12:25:04Z","receivedAt":"2018-01-08T12:25:21Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Duy,\n\nOn Sun, 7 Jan 2018, Duy Nguyen wrote:\n\n> On Sat, Jan 6, 2018 at 7:51 PM, Johannes Schindelin\n> <Johannes.Schindelin@gmx.de> wrote:\n> > Nobody likes to run tests that take too\n> > long. And look at this:\n> >\n> >         ...\n> >         ok 1511 - ipathmatch: match 'Z' '[Z-y]'\n> >         ok 1512 - ipathmatch(ls): match '[Z-y]' 'Z'\n> >         # still have 84 known breakage(s)\n> >         # failed 52 among remaining 1428 test(s)\n> >         1..1512\n> >\n> >         real    5m51.432s\n> >         user    0m33.986s\n> >         sys     2m13.162s\n> >\n> > Yep. It takes *over eight minutes*.\n> \n> I suppose this is because the sheer number of test cases adds a lot of\n> shell overhead on Windows. I wonder if it's better to rewrite this\n> test in C instead. We start to do some more unit testing here and\n> there and kind of abuse the sh-based test framework for this. Having a\n> proper unit test framework would be good anyway since it's sometimes\n> hard to create a specific scenario with high level commands.\n\nI agree that it would make a ton of sense to use a proper, portable test\nframework written in pure, portable C.\n\nHowever, this ship has long sailed, hasn't it?\n\nOf course, we do have useful stuff in t/helper/. And we have precedent for\nmore sensible bulk testing that does not require sh to generate or provide\nlists of test data, see e.g. the basename/dirname tests. And we could\norganize t/helper/ better, including a refactoring to have a single binary\nrather than tons and tons of binaries that all link to libgit.a and\ntake a lot of space (even with LZMA compression, the current test\nartifacts take about 90 megabyte!).\n\nIf I had the time I would write this up as a valuable GSoC project. Not\nthat Junio cares. But I do.\n\nCiao,\nDscho\n"},{"id":"336138","messageId":"nycvar.QRO.7.76.6.1801081331540.31@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz","threadId":"47493","inReplyTo":"87mv1raz9p.fsf@evledraar.gmail.com","subject":"Re: [PATCH v4 8/7] wildmatch test: skip file creation tests on Windows proper","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-01-08T12:46:24Z","receivedAt":"2018-01-08T12:46:38Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Ævar,\n\nOn Sat, 6 Jan 2018, Ævar Arnfjörð Bjarmason wrote:\n\n> Can you please provide me with the output of the test under -v -x -d\n> from github.com:avar/git.git wildmatch-refactor-8 branch?\n\nWith -v -x -i:\n\n-- snip --\n[...]\nexpecting success:\n                                printf '%s' '?a?b' >expect &&\n                                git --glob-pathspecs ls-files -z -- '\\??\\?b' >actual.raw 2>actual.err &&\n\n        tr -d '\\0' <actual.raw >actual &&\n        >expect.err &&\n        test_cmp expect.err actual.err &&\n        test_cmp expect actual\n\n++ printf %s '?a?b'\n++ git --glob-pathspecs ls-files -z -- '\\??\\?b'\n+ test_eval_ret_=128\n+ want_trace\n+ test t = t\n+ test t = t\n+ set +x\nerror: last command exited with $?=128\nnot ok 734 - wildmatch(ls): match '\\??\\?b' '?a?b'\n#\n#                                       printf '%s' '?a?b' >expect &&\n#                                       git --glob-pathspecs ls-files -z\n#                                       -- '\\??\\?b' >actual.raw\n#                                       2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\n\nreal    2m9.127s\nuser    0m10.026s\nsys     1m0.617s\n-- snap --\n\nand\n\n-- snip --\n$ cat ./trash\\ directory.t3070-wildmatch/actual.err\nfatal: Invalid path '/??': No such file or directory\n-- snap --\n\nAs to the speed:\n\n-- snip --\n# still have 144 known breakage(s)\n# failed 28 among remaining 1746 test(s)\n1..1890\n\nreal    5m55.162s\nuser    0m26.396s\nsys     2m34.152s\n-- snap --\n\n... seems to be in the same ballpark. You are just leaning way too heavily\non Unix shell scripting.\n\nFWIW the breakages are:\n\n-- snip --\nnot ok 734 - wildmatch(ls): match '\\??\\?b' '?a?b'\n#\n#                                       printf '%s' '?a?b' >expect &&\n#                                       git --glob-pathspecs ls-files -z\n#                                       -- '\\??\\?b' >actual.raw\n#                                       2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 735 - iwildmatch: match '?a?b' '\\??\\?b'\nnot ok 736 - iwildmatch(ls): match '\\??\\?b' '?a?b'\n#\n#                                       printf '%s' '?a?b' >expect &&\n#                                       git --glob-pathspecs\n#                                       --icase-pathspecs ls-files -z --\n#                                       '\\??\\?b' >actual.raw 2>actual.err\n#                                       &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 737 - pathmatch: match '?a?b' '\\??\\?b'\nnot ok 738 - pathmatch(ls): match '\\??\\?b' '?a?b'\n#\n#                                       printf '%s' '?a?b' >expect &&\n#                                       git ls-files -z -- '\\??\\?b'\n#                                       >actual.raw 2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 739 - ipathmatch: match '?a?b' '\\??\\?b'\nnot ok 740 - ipathmatch(ls): match '\\??\\?b' '?a?b'\n#\n#                                       printf '%s' '?a?b' >expect &&\n#                                       git --icase-pathspecs ls-files -z\n#                                       -- '\\??\\?b' >actual.raw\n#                                       2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 741 - cleanup after previous file test\nok 742 - setup wildtest file test for abc\nok 743 - wildmatch: match 'abc' '\\a\\b\\c'\nnot ok 744 - wildmatch(ls): match '\\a\\b\\c' 'abc'\n#\n#                                       printf '%s' 'abc' >expect &&\n#                                       git --glob-pathspecs ls-files -z\n#                                       -- '\\a\\b\\c' >actual.raw\n#                                       2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 745 - iwildmatch: match 'abc' '\\a\\b\\c'\nnot ok 746 - iwildmatch(ls): match '\\a\\b\\c' 'abc'\n#\n#                                       printf '%s' 'abc' >expect &&\n#                                       git --glob-pathspecs\n#                                       --icase-pathspecs ls-files -z --\n#                                       '\\a\\b\\c' >actual.raw 2>actual.err\n#                                       &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 747 - pathmatch: match 'abc' '\\a\\b\\c'\nnot ok 748 - pathmatch(ls): match '\\a\\b\\c' 'abc'\n#\n#                                       printf '%s' 'abc' >expect &&\n#                                       git ls-files -z -- '\\a\\b\\c'\n#                                       >actual.raw 2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 749 - ipathmatch: match 'abc' '\\a\\b\\c'\nnot ok 750 - ipathmatch(ls): match '\\a\\b\\c' 'abc'\n#\n#                                       printf '%s' 'abc' >expect &&\n#                                       git --icase-pathspecs ls-files -z\n#                                       -- '\\a\\b\\c' >actual.raw\n#                                       2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\n[...]\nnot ok 964 - wildmatch(ls): match '[\\-_]' '-'\n#\n#                                       printf '%s' '-' >expect &&\n#                                       git --glob-pathspecs ls-files -z\n#                                       -- '[\\-_]' >actual.raw\n#                                       2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 965 - iwildmatch: match '-' '[\\-_]'\nnot ok 966 - iwildmatch(ls): match '[\\-_]' '-'\n#\n#                                       printf '%s' '-' >expect &&\n#                                       git --glob-pathspecs\n#                                       --icase-pathspecs ls-files -z --\n#                                       '[\\-_]' >actual.raw 2>actual.err\n#                                       &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 967 - pathmatch: match '-' '[\\-_]'\nnot ok 968 - pathmatch(ls): match '[\\-_]' '-'\n#\n#                                       printf '%s' '-' >expect &&\n#                                       git ls-files -z -- '[\\-_]'\n#                                       >actual.raw 2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 969 - ipathmatch: match '-' '[\\-_]'\nnot ok 970 - ipathmatch(ls): match '[\\-_]' '-'\n#\n#                                       printf '%s' '-' >expect &&\n#                                       git --icase-pathspecs ls-files -z\n#                                       -- '[\\-_]' >actual.raw\n#                                       2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 971 - cleanup after previous file test\nok 972 - setup wildtest file test for ]\nok 973 - wildmatch: match ']' '[\\]]'\nnot ok 974 - wildmatch(ls): match '[\\]]' ']'\n#\n#                                       printf '%s' ']' >expect &&\n#                                       git --glob-pathspecs ls-files -z\n#                                       -- '[\\]]' >actual.raw 2>actual.err\n#                                       &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 975 - iwildmatch: match ']' '[\\]]'\nnot ok 976 - iwildmatch(ls): match '[\\]]' ']'\n#\n#                                       printf '%s' ']' >expect &&\n#                                       git --glob-pathspecs\n#                                       --icase-pathspecs ls-files -z --\n#                                       '[\\]]' >actual.raw 2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 977 - pathmatch: match ']' '[\\]]'\nnot ok 978 - pathmatch(ls): match '[\\]]' ']'\n#\n#                                       printf '%s' ']' >expect &&\n#                                       git ls-files -z -- '[\\]]'\n#                                       >actual.raw 2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 979 - ipathmatch: match ']' '[\\]]'\nnot ok 980 - ipathmatch(ls): match '[\\]]' ']'\n#\n#                                       printf '%s' ']' >expect &&\n#                                       git --icase-pathspecs ls-files -z\n#                                       -- '[\\]]' >actual.raw 2>actual.err\n#                                       &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\n[...]\nnot ok 1284 - wildmatch(ls): match '[A-\\\\]' 'G'\n#\n#                                       printf '%s' 'G' >expect &&\n#                                       git --glob-pathspecs ls-files -z\n#                                       -- '[A-\\\\]' >actual.raw\n#                                       2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 1285 - iwildmatch: match 'G' '[A-\\\\]'\nnot ok 1286 - iwildmatch(ls): match '[A-\\\\]' 'G'\n#\n#                                       printf '%s' 'G' >expect &&\n#                                       git --glob-pathspecs\n#                                       --icase-pathspecs ls-files -z --\n#                                       '[A-\\\\]' >actual.raw 2>actual.err\n#                                       &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 1287 - pathmatch: match 'G' '[A-\\\\]'\nnot ok 1288 - pathmatch(ls): match '[A-\\\\]' 'G'\n#\n#                                       printf '%s' 'G' >expect &&\n#                                       git ls-files -z -- '[A-\\\\]'\n#                                       >actual.raw 2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 1289 - ipathmatch: match 'G' '[A-\\\\]'\nnot ok 1290 - ipathmatch(ls): match '[A-\\\\]' 'G'\n#\n#                                       printf '%s' 'G' >expect &&\n#                                       git --icase-pathspecs ls-files -z\n#                                       -- '[A-\\\\]' >actual.raw\n#                                       2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\n[...]\nnot ok 1374 - wildmatch(ls): match '[\\1-\\3]' '2'\n#\n#                                       printf '%s' '2' >expect &&\n#                                       git --glob-pathspecs ls-files -z\n#                                       -- '[\\1-\\3]' >actual.raw\n#                                       2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 1375 - iwildmatch: match '2' '[\\1-\\3]'\nnot ok 1376 - iwildmatch(ls): match '[\\1-\\3]' '2'\n#\n#                                       printf '%s' '2' >expect &&\n#                                       git --glob-pathspecs\n#                                       --icase-pathspecs ls-files -z --\n#                                       '[\\1-\\3]' >actual.raw 2>actual.err\n#                                       &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 1377 - pathmatch: match '2' '[\\1-\\3]'\nnot ok 1378 - pathmatch(ls): match '[\\1-\\3]' '2'\n#\n#                                       printf '%s' '2' >expect &&\n#                                       git ls-files -z -- '[\\1-\\3]'\n#                                       >actual.raw 2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 1379 - ipathmatch: match '2' '[\\1-\\3]'\nnot ok 1380 - ipathmatch(ls): match '[\\1-\\3]' '2'\n#\n#                                       printf '%s' '2' >expect &&\n#                                       git --icase-pathspecs ls-files -z\n#                                       -- '[\\1-\\3]' >actual.raw\n#                                       2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\n[...]\nnot ok 1424 - wildmatch(ls): match '[[-\\]]' ']'\n#\n#                                       printf '%s' ']' >expect &&\n#                                       git --glob-pathspecs ls-files -z\n#                                       -- '[[-\\]]' >actual.raw\n#                                       2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 1425 - iwildmatch: match ']' '[[-\\]]'\nnot ok 1426 - iwildmatch(ls): match '[[-\\]]' ']'\n#\n#                                       printf '%s' ']' >expect &&\n#                                       git --glob-pathspecs\n#                                       --icase-pathspecs ls-files -z --\n#                                       '[[-\\]]' >actual.raw 2>actual.err\n#                                       &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 1427 - pathmatch: match ']' '[[-\\]]'\nnot ok 1428 - pathmatch(ls): match '[[-\\]]' ']'\n#\n#                                       printf '%s' ']' >expect &&\n#                                       git ls-files -z -- '[[-\\]]'\n#                                       >actual.raw 2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\nok 1429 - ipathmatch: match ']' '[[-\\]]'\nnot ok 1430 - ipathmatch(ls): match '[[-\\]]' ']'\n#\n#                                       printf '%s' ']' >expect &&\n#                                       git --icase-pathspecs ls-files -z\n#                                       -- '[[-\\]]' >actual.raw\n#                                       2>actual.err &&\n#\n#               tr -d '\\0' <actual.raw >actual &&\n#               >expect.err &&\n#               test_cmp expect.err actual.err &&\n#               test_cmp expect actual\n#\n-- snap --\n\nCiao,\nDscho"},{"id":"336168","messageId":"xmqqvagc89ti.fsf@gitster.mtv.corp.google.com","threadId":"47493","inReplyTo":"87mv1raz9p.fsf@evledraar.gmail.com","subject":"Re: [PATCH v4 8/7] wildmatch test: skip file creation tests on Windows proper","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-01-08T18:49:45Z","receivedAt":"2018-01-08T18:49:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> I agree that there should be some prerequisite to skip this on Windows\n> by default since 6 minutes is clearly excessive (although I think you'll\n> find it runs a bit faster in the branch above), but that should be\n> something like:\n>\n>     test_lazy_prereq EXPENSIVE_ON_WINDOWS '\n>             test -n \"$GIT_TEST_LONG\" || test_have_prereq !MINGW,!CYGWIN\n>     '\n>\n> As the long runtime is not inherent to the test, but to excessive\n> slowness caused by certain operations on certain platforms, or maybe it\n> should be EXPENSIVE_ON_SLOW_FS or EXPENSIVE_IF_FORKING_IS_SLOW or if\n> we'd like to generalize it.\n\nWe already do skip overly long tests everywhere unless explicitly\nasked to run them, and the above sounds like a good way to go.\n"},{"id":"336349","messageId":"20180110090724.GA2893@ash","threadId":"47493","inReplyTo":"nycvar.QRO.7.76.6.1801081319520.31@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz","subject":"Re: [PATCH v4 8/7] wildmatch test: skip file creation tests on Windows proper","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-10T09:07:24Z","receivedAt":"2018-01-10T09:07:46Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Mon, Jan 08, 2018 at 01:25:04PM +0100, Johannes Schindelin wrote:\n> I agree that it would make a ton of sense to use a proper, portable test\n> framework written in pure, portable C.\n> \n> However, this ship has long sailed, hasn't it?\n\nIf you meant converting the whole test suite, oh yeah that's not gonna\nhappen. But it's still possible to have some tests written in C.\n\nI played a bit with this. The assumption is if it's agreed that we can\nget something bare bone (but functional) in then we could start having\nmore and more C-based unit tests in future and also improve the C\nframework to be on par with shell one on the side.\n\nThere are still some minor problems with my patch, and a bunch of\noptional features not supported. But the numbers looks unexpectedly\npromising. 0.7 seconds on the shell version and 0.03 on the C one.\n\nOne disadvantage of this though, if this kind of framework does not\nget popular, then any new test feature must be added at both places\nbut it's a waste of time to support both. So...\n\nAnyway here it is. t3071 is the same as t3070 (this is on master)\n\n Makefile                             |   2 +\n t/helper/test-3071-wildmatch.c (new) | 273 ++++++++++++++++++++++++++++++++++++++++++++++++++\n t/t3071-wildmatch.sh (new +x)        |   3 +\n test-lib.c (new)                     |  97 ++++++++++++++++++\n test-lib.h (new)                     |   5 +\n\n-- 8< --\ndiff --git a/Makefile b/Makefile\nindex 2a81ae22e9..567387b558 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -644,6 +644,7 @@ X =\n \n PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))\n \n+TEST_PROGRAMS_NEED_X += test-3071-wildmatch\n TEST_PROGRAMS_NEED_X += test-chmtime\n TEST_PROGRAMS_NEED_X += test-ctype\n TEST_PROGRAMS_NEED_X += test-config\n@@ -895,6 +896,7 @@ LIB_OBJS += sub-process.o\n LIB_OBJS += symlinks.o\n LIB_OBJS += tag.o\n LIB_OBJS += tempfile.o\n+LIB_OBJS += test-lib.o\n LIB_OBJS += tmp-objdir.o\n LIB_OBJS += trace.o\n LIB_OBJS += trailer.o\ndiff --git a/t/helper/test-3071-wildmatch.c b/t/helper/test-3071-wildmatch.c\nnew file mode 100644\nindex 0000000000..24a657202d\n--- /dev/null\n+++ b/t/helper/test-3071-wildmatch.c\n@@ -0,0 +1,273 @@\n+#include \"cache.h\"\n+#include \"test-lib.h\"\n+\n+struct match_input {\n+\tint expect_true;\n+\tconst char *text;\n+\tconst char *pattern;\n+};\n+\n+static struct match_input match_tests[] = {\n+\t/* Basic wildmatch features */\n+\t{ 1, \"foo\", \"foo\" },\n+\t{ 0, \"foo\", \"bar\" },\n+\t{ 1, \"\", \"\" },\n+\t{ 1, \"foo\", \"???\" },\n+\t{ 0, \"foo\", \"??\" },\n+\t{ 1, \"foo\", \"*\" },\n+\t{ 1, \"foo\", \"f*\" },\n+\t{ 0, \"foo\", \"*f\" },\n+\t{ 1, \"foo\", \"*foo*\" },\n+\t{ 1, \"foobar\", \"*ob*a*r*\" },\n+\t{ 1, \"aaaaaaabababab\", \"*ab\" },\n+\t{ 1, \"foo*\", \"foo\\\\*\" },\n+\t{ 0, \"foobar\", \"foo\\\\*bar\" },\n+\t{ 1, \"f\\\\oo\", \"f\\\\\\\\oo\" },\n+\t{ 1, \"ball\", \"*[al]?\" },\n+\t{ 0, \"ten\", \"[ten]\" },\n+\t{ 0, \"ten\", \"**[!te]\" },\n+\t{ 0, \"ten\", \"**[!ten]\" },\n+\t{ 1, \"ten\", \"t[a-g]n\" },\n+\t{ 0, \"ten\", \"t[!a-g]n\" },\n+\t{ 1, \"ton\", \"t[!a-g]n\" },\n+\t{ 1, \"ton\", \"t[^a-g]n\" },\n+\t{ 1, \"a]b\", \"a[]]b\" },\n+\t{ 1, \"a-b\", \"a[]-]b\" },\n+\t{ 1, \"a]b\", \"a[]-]b\" },\n+\t{ 0, \"aab\", \"a[]-]b\" },\n+\t{ 1, \"aab\", \"a[]a-]b\" },\n+\t{ 1, \"]\", \"]\" },\n+\n+\t/* Extended slash-matching features */\n+\t{ 0, \"foo/baz/bar\", \"foo*bar\" },\n+\t{ 0, \"foo/baz/bar\", \"foo**bar\" },\n+\t{ 0, \"foobazbar\", \"foo**bar\" },\n+\t{ 1, \"foo/baz/bar\", \"foo/**/bar\" },\n+\t{ 1, \"foo/baz/bar\", \"foo/**/**/bar\" },\n+\t{ 1, \"foo/b/a/z/bar\", \"foo/**/bar\" },\n+\t{ 1, \"foo/b/a/z/bar\", \"foo/**/**/bar\" },\n+\t{ 1, \"foo/bar\", \"foo/**/bar\" },\n+\t{ 1, \"foo/bar\", \"foo/**/**/bar\" },\n+\t{ 0, \"foo/bar\", \"foo?bar\" },\n+\t{ 0, \"foo/bar\", \"foo[/]bar\" },\n+\t{ 0, \"foo/bar\", \"foo[^a-z]bar\" },\n+\t{ 0, \"foo/bar\", \"f[^eiu][^eiu][^eiu][^eiu][^eiu]r\" },\n+\t{ 1, \"foo-bar\", \"f[^eiu][^eiu][^eiu][^eiu][^eiu]r\" },\n+\t{ 1, \"foo\", \"**/foo\" },\n+\t{ 1, \"XXX/foo\", \"**/foo\" },\n+\t{ 1, \"bar/baz/foo\", \"**/foo\" },\n+\t{ 0, \"bar/baz/foo\", \"*/foo\" },\n+\t{ 0, \"foo/bar/baz\", \"**/bar*\" },\n+\t{ 1, \"deep/foo/bar/baz\", \"**/bar/*\" },\n+\t{ 0, \"deep/foo/bar/baz/\", \"**/bar/*\" },\n+\t{ 1, \"deep/foo/bar/baz/\", \"**/bar/**\" },\n+\t{ 0, \"deep/foo/bar\", \"**/bar/*\" },\n+\t{ 1, \"deep/foo/bar/\", \"**/bar/**\" },\n+\t{ 0, \"foo/bar/baz\", \"**/bar**\" },\n+\t{ 1, \"foo/bar/baz/x\", \"*/bar/**\" },\n+\t{ 0, \"deep/foo/bar/baz/x\", \"*/bar/**\" },\n+\t{ 1, \"deep/foo/bar/baz/x\", \"**/bar/*/*\" },\n+\n+\t/* Various additional tests */\n+\t{ 0, \"acrt\", \"a[c-c]st\" },\n+\t{ 1, \"acrt\", \"a[c-c]rt\" },\n+\t{ 0, \"]\", \"[!]-]\" },\n+\t{ 1, \"a\", \"[!]-]\" },\n+\t{ 0, \"\", \"\\\\\" },\n+\t{ 0, \"\\\\\", \"\\\\\" },\n+\t{ 0, \"XXX/\\\\\", \"*/\\\\\" },\n+\t{ 1, \"XXX/\\\\\", \"*/\\\\\\\\\" },\n+\t{ 1, \"foo\", \"foo\" },\n+\t{ 1, \"@foo\", \"@foo\" },\n+\t{ 0, \"foo\", \"@foo\" },\n+\t{ 1, \"[ab]\", \"\\\\[ab]\" },\n+\t{ 1, \"[ab]\", \"[[]ab]\" },\n+\t{ 1, \"[ab]\", \"[[:]ab]\" },\n+\t{ 0, \"[ab]\", \"[[::]ab]\" },\n+\t{ 1, \"[ab]\", \"[[:digit]ab]\" },\n+\t{ 1, \"[ab]\", \"[\\\\[:]ab]\" },\n+\t{ 1, \"?a?b\", \"\\\\??\\\\?b\" },\n+\t{ 1, \"abc\", \"\\\\a\\\\b\\\\c\" },\n+\t{ 0, \"foo\", \"\" },\n+\t{ 1, \"foo/bar/baz/to\", \"**/t[o]\" },\n+\n+\t/* Character class tests */\n+\t{ 1, \"a1B\", \"[[:alpha:]][[:digit:]][[:upper:]]\" },\n+\t{ 0, \"a\", \"[[:digit:][:upper:][:space:]]\" },\n+\t{ 1, \"A\", \"[[:digit:][:upper:][:space:]]\" },\n+\t{ 1, \"1\", \"[[:digit:][:upper:][:space:]]\" },\n+\t{ 0, \"1\", \"[[:digit:][:upper:][:spaci:]]\" },\n+\t{ 1, \" \", \"[[:digit:][:upper:][:space:]]\" },\n+\t{ 0, \".\", \"[[:digit:][:upper:][:space:]]\" },\n+\t{ 1, \".\", \"[[:digit:][:punct:][:space:]]\" },\n+\t{ 1, \"5\", \"[[:xdigit:]]\" },\n+\t{ 1, \"f\", \"[[:xdigit:]]\" },\n+\t{ 1, \"D\", \"[[:xdigit:]]\" },\n+\t{ 1, \"_\", \"[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]\" },\n+\t{ 1, \".\", \"[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]\" },\n+\t{ 1, \"5\", \"[a-c[:digit:]x-z]\" },\n+\t{ 1, \"b\", \"[a-c[:digit:]x-z]\" },\n+\t{ 1, \"y\", \"[a-c[:digit:]x-z]\" },\n+\t{ 0, \"q\", \"[a-c[:digit:]x-z]\" },\n+\n+\t/* Additional tests, including some malformed wildmats */\n+\t{ 1, \"]\", \"[\\\\\\\\-^]\" },\n+\t{ 0, \"[\", \"[\\\\\\\\-^]\" },\n+\t{ 1, \"-\", \"[\\\\-_]\" },\n+\t{ 1, \"]\", \"[\\\\]]\" },\n+\t{ 0, \"\\\\]\", \"[\\\\]]\" },\n+\t{ 0, \"\\\\\", \"[\\\\]]\" },\n+\t{ 0, \"ab\", \"a[]b\" },\n+\t{ 0, \"a[]b\", \"a[]b\" },\n+\t{ 0, \"ab[\", \"ab[\" },\n+\t{ 0, \"ab\", \"[!\" },\n+\t{ 0, \"ab\", \"[-\" },\n+\t{ 1, \"-\", \"[-]\" },\n+\t{ 0, \"-\", \"[a-\" },\n+\t{ 0, \"-\", \"[!a-\" },\n+\t{ 1, \"-\", \"[--A]\" },\n+\t{ 1, \"5\", \"[--A]\" },\n+\t{ 1, \" \", \"[ --]\" },\n+\t{ 1, \"$\", \"[ --]\" },\n+\t{ 1, \"-\", \"[ --]\" },\n+\t{ 0, \"0\", \"[ --]\" },\n+\t{ 1, \"-\", \"[---]\" },\n+\t{ 1, \"-\", \"[------]\" },\n+\t{ 0, \"j\", \"[a-e-n]\" },\n+\t{ 1, \"-\", \"[a-e-n]\" },\n+\t{ 1, \"a\", \"[!------]\" },\n+\t{ 0, \"[\", \"[]-a]\" },\n+\t{ 1, \"^\", \"[]-a]\" },\n+\t{ 0, \"^\", \"[!]-a]\" },\n+\t{ 1, \"[\", \"[!]-a]\" },\n+\t{ 1, \"^\", \"[a^bc]\" },\n+\t{ 1, \"-b]\", \"[a-]b]\" },\n+\t{ 0, \"\\\\\", \"[\\\\]\" },\n+\t{ 1, \"\\\\\", \"[\\\\\\\\]\" },\n+\t{ 0, \"\\\\\", \"[!\\\\\\\\]\" },\n+\t{ 1, \"G\", \"[A-\\\\\\\\]\" },\n+\t{ 0, \"aaabbb\", \"b*a\" },\n+\t{ 0, \"aabcaa\", \"*ba*\" },\n+\t{ 1, \",\", \"[,]\" },\n+\t{ 1, \",\", \"[\\\\\\\\,]\" },\n+\t{ 1, \"\\\\\", \"[\\\\\\\\,]\" },\n+\t{ 1, \"-\", \"[,-.]\" },\n+\t{ 0, \"+\", \"[,-.]\" },\n+\t{ 0, \"-.]\", \"[,-.]\" },\n+\t{ 1, \"2\", \"[\\\\1-\\\\3]\" },\n+\t{ 1, \"3\", \"[\\\\1-\\\\3]\" },\n+\t{ 0, \"4\", \"[\\\\1-\\\\3]\" },\n+\t{ 1, \"\\\\\", \"[[-\\\\]]\" },\n+\t{ 1, \"[\", \"[[-\\\\]]\" },\n+\t{ 1, \"]\", \"[[-\\\\]]\" },\n+\t{ 0, \"-\", \"[[-\\\\]]\" },\n+\n+\t/* Test recursion and the abort code (use \"wildtest -i\" to see iteration counts) */\n+\t{ 1, \"-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1\", \"-*-*-*-*-*-*-12-*-*-*-m-*-*-*\" },\n+\t{ 0, \"-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1\", \"-*-*-*-*-*-*-12-*-*-*-m-*-*-*\" },\n+\t{ 0, \"-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1\", \"-*-*-*-*-*-*-12-*-*-*-m-*-*-*\" },\n+\t{ 1, \"XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1\", \"XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*\" },\n+\t{ 0, \"XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1\", \"XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*\" },\n+\t{ 1, \"abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt\", \"**/*a*b*g*n*t\" },\n+\t{ 0, \"abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz\", \"**/*a*b*g*n*t\" },\n+\t{ 0, \"foo\", \"*/*/*\" },\n+\t{ 0, \"foo/bar\", \"*/*/*\" },\n+\t{ 1, \"foo/bba/arr\", \"*/*/*\" },\n+\t{ 0, \"foo/bb/aa/rr\", \"*/*/*\" },\n+\t{ 1, \"foo/bb/aa/rr\", \"**/**/**\" },\n+\t{ 1, \"abcXdefXghi\", \"*X*i\" },\n+\t{ 0, \"ab/cXd/efXg/hi\", \"*X*i\" },\n+\t{ 1, \"ab/cXd/efXg/hi\", \"*/*X*/*/*i\" },\n+\t{ 1, \"ab/cXd/efXg/hi\", \"**/*X*/**/*i\" },\n+\n+\t/* Case-sensitivity features */\n+\t{ 0, \"a\", \"[A-Z]\" },\n+\t{ 1, \"A\", \"[A-Z]\" },\n+\t{ 0, \"A\", \"[a-z]\" },\n+\t{ 1, \"a\", \"[a-z]\" },\n+\t{ 0, \"a\", \"[[:upper:]]\" },\n+\t{ 1, \"A\", \"[[:upper:]]\" },\n+\t{ 0, \"A\", \"[[:lower:]]\" },\n+\t{ 1, \"a\", \"[[:lower:]]\" },\n+\t{ 0, \"A\", \"[B-Za]\" },\n+\t{ 1, \"a\", \"[B-Za]\" },\n+\t{ 0, \"A\", \"[B-a]\" },\n+\t{ 1, \"a\", \"[B-a]\" },\n+\t{ 0, \"z\", \"[Z-y]\" },\n+\t{ 1, \"Z\", \"[Z-y]\" },\n+};\n+\n+static struct match_input pathmatch_tests[] = {\n+\t{ 1, \"foo\", \"foo\" },\n+\t{ 0, \"foo\", \"fo\" },\n+\t{ 1, \"foo/bar\", \"foo/bar\" },\n+\t{ 1, \"foo/bar\", \"foo/*\" },\n+\t{ 1, \"foo/bba/arr\", \"foo/*\" },\n+\t{ 1, \"foo/bba/arr\", \"foo/**\" },\n+\t{ 1, \"foo/bba/arr\", \"foo*\" },\n+\t{ 1, \"foo/bba/arr\", \"foo**\" },\n+\t{ 1, \"foo/bba/arr\", \"foo/*arr\" },\n+\t{ 1, \"foo/bba/arr\", \"foo/**arr\" },\n+\t{ 0, \"foo/bba/arr\", \"foo/*z\" },\n+\t{ 0, \"foo/bba/arr\", \"foo/**z\" },\n+\t{ 1, \"foo/bar\", \"foo?bar\" },\n+\t{ 1, \"foo/bar\", \"foo[/]bar\" },\n+\t{ 1, \"foo/bar\", \"foo[^a-z]bar\" },\n+\t{ 0, \"foo\", \"*/*/*\" },\n+\t{ 0, \"foo/bar\", \"*/*/*\" },\n+\t{ 1, \"foo/bba/arr\", \"*/*/*\" },\n+\t{ 1, \"foo/bb/aa/rr\", \"*/*/*\" },\n+\t{ 1, \"abcXdefXghi\", \"*X*i\" },\n+\t{ 1, \"ab/cXd/efXg/hi\", \"*/*X*/*/*i\" },\n+\t{ 1, \"ab/cXd/efXg/hi\", \"*Xg*i\" },\n+};\n+\n+static struct match_input icase_match_tests[] = {\n+\t{ 1, \"a\", \"[A-Z]\" },\n+\t{ 1, \"A\", \"[A-Z]\" },\n+\t{ 1, \"A\", \"[a-z]\" },\n+\t{ 1, \"a\", \"[a-z]\" },\n+\t{ 1, \"a\", \"[[:upper:]]\" },\n+\t{ 1, \"A\", \"[[:upper:]]\" },\n+\t{ 1, \"A\", \"[[:lower:]]\" },\n+\t{ 1, \"a\", \"[[:lower:]]\" },\n+\t{ 1, \"A\", \"[B-Za]\" },\n+\t{ 1, \"a\", \"[B-Za]\" },\n+\t{ 1, \"A\", \"[B-a]\" },\n+\t{ 1, \"a\", \"[B-a]\" },\n+\t{ 1, \"z\", \"[Z-y]\" },\n+\t{ 1, \"Z\", \"[Z-y]\" },\n+};\n+\n+static void test_match(const char *name,\n+\t\t       const struct match_input *input,\n+\t\t       unsigned flags)\n+{\n+\tint ret;\n+\n+\tstart_test(\"%s:  %s match '%s' '%s'\",\n+\t\t   name,\n+\t\t   input->expect_true ? \"  \" : \"no\",\n+\t\t   input->text, input->pattern);\n+\tret = wildmatch(input->pattern, input->text, flags);\n+\tend_test(input->expect_true ? ret == 0 : ret != 0);\n+}\n+\n+int cmd_main(int ac, const char **av)\n+{\n+\tint i;\n+\n+\tinit_test_suite(ac, av);\n+\n+\tfor (i = 0; i < ARRAY_SIZE(match_tests); i++)\n+\t\ttest_match(\"wildmatch\", match_tests + i, WM_PATHNAME);\n+\n+\tfor (i = 0; i < ARRAY_SIZE(pathmatch_tests); i++)\n+\t\ttest_match(\"pathmatch\", pathmatch_tests + i, 0);\n+\n+\tfor (i = 0; i < ARRAY_SIZE(icase_match_tests); i++)\n+\t\ttest_match(\"iwildmatch\", icase_match_tests + i,\n+\t\t\t   WM_PATHNAME | WM_CASEFOLD);\n+\n+\tall_tests_done();\n+}\ndiff --git a/t/t3071-wildmatch.sh b/t/t3071-wildmatch.sh\nnew file mode 100755\nindex 0000000000..6e83b4d684\n--- /dev/null\n+++ b/t/t3071-wildmatch.sh\n@@ -0,0 +1,3 @@\n+#!/bin/sh\n+\n+exec helper/test-3071-wildmatch t3071-wildmatch \"$@\"\ndiff --git a/test-lib.c b/test-lib.c\nnew file mode 100644\nindex 0000000000..8e8b7cd6df\n--- /dev/null\n+++ b/test-lib.c\n@@ -0,0 +1,97 @@\n+#include \"cache.h\"\n+#include \"test-lib.h\"\n+\n+static int test_failure;\n+static int test_count;\n+static int test_fixed;\n+static int test_broken;\n+static int test_success;\n+\n+static const char *suite_name;\n+static int harness_active;\n+static char *test_name;\n+\n+void init_test_suite(int ac, const char **av)\n+{\n+\tchar cwd[PATH_MAX];\n+\n+\tharness_active = getenv(\"HARNESS_ACTIVE\") != NULL;\n+\tsuite_name = av[1];\n+\n+\tgetcwd(cwd, sizeof(cwd));\n+\tsetenv(\"TEST_DIRECTORY\", cwd, 0);\n+\tsetenv(\"TEST_OUTPUT_DIRECTORY\", getenv(\"TEST_DIRECTORY\"), 0);\n+\n+\tac--;\n+\tav++;\n+\n+\tdup2(1, 3);\n+}\n+\n+static int skip_test(void)\n+{\n+\treturn 0; /* not supported yet */\n+}\n+\n+int start_test(const char *fmt, ...)\n+{\n+\tva_list ap;\n+\n+\tva_start(ap, fmt);\n+\ttest_name = xstrvfmt(fmt, ap);\n+\tva_end(ap);\n+\ttest_count++;\n+\n+\tif (skip_test())\n+\t\treturn 0;\n+\n+\treturn 1;\n+}\n+\n+void end_test(int ok)\n+{\n+\tif (ok) {\n+\t\ttest_success++;\n+\t\tdprintf(3, \"ok %d - %s\\n\", test_count, test_name);\n+\t} else {\n+\t\ttest_failure++;\n+\t\tdprintf(3, \"not ok %d - %s\\n\", test_count, test_name);\n+\t}\n+\n+\tfree(test_name);\n+\ttest_name = NULL;\n+\n+\t/* -i not supported yet */\n+}\n+\n+void all_tests_done(void)\n+{\n+\tif (!getenv(\"HARNESS_ACTIVE\")) {\n+\t\tstruct strbuf sb = STRBUF_INIT;\n+\t\tFILE *fp;\n+\n+\t\tstrbuf_addf(&sb, \"mkdir -p %s/test-results\",\n+\t\t\t    getenv(\"TEST_OUTPUT_DIRECTORY\"));\n+\t\tsystem(sb.buf);\n+\t\tstrbuf_release(&sb);\n+\n+\t\tstrbuf_addf(&sb, \"%s/test-results/%s.counts\",\n+\t\t\t    getenv(\"TEST_OUTPUT_DIRECTORY\"),\n+\t\t\t    suite_name);\n+\t\tfp = fopen(sb.buf, \"w\");\n+\t\tstrbuf_release(&sb);\n+\n+\t\tfprintf(fp, \"total %d\\nsuccess %d\\n\"\n+\t\t\t\"fixed %d\\nbroken %d\\nfailed %d\\n\\n\",\n+\t\t\ttest_count, test_success,\n+\t\t\ttest_fixed, test_broken, test_failure);\n+\t\tfclose(fp);\n+\t}\n+\tif (test_failure) {\n+\t\tdprintf(3, \"# failed %d among FIXME\\n\", test_failure);\n+\t} else {\n+\t\tdprintf(3, \"# passed all FIXME\\n\");\n+\t}\n+\tdprintf(3, \"1..%d\\n\", test_count);\n+\texit(0);\n+}\ndiff --git a/test-lib.h b/test-lib.h\nnew file mode 100644\nindex 0000000000..f8122c1719\n--- /dev/null\n+++ b/test-lib.h\n@@ -0,0 +1,5 @@\n+void init_test_suite(int ac, const char **av);\n+void all_tests_done(void) NORETURN;\n+\n+int start_test(const char *fmt, ...);\n+void end_test(int ok);\n-- 8< --\n\n--\nDuy\n"},{"id":"336371","messageId":"20180110103832.GA4018@dinwoodie.org","threadId":"47493","inReplyTo":"20180110090724.GA2893@ash","subject":"Re: [PATCH v4 8/7] wildmatch test: skip file creation tests on Windows proper","fromName":"Adam Dinwoodie","fromEmail":"adam@dinwoodie.org","sentAt":"2018-01-10T10:38:32Z","receivedAt":"2018-01-10T10:38:57Z","isPatch":true,"sender":{"key":"adam@dinwoodie.org","avatar":"https://avatars.githubusercontent.com/u/1397507?v=4"},"body":"On Wednesday 10 January 2018 at 04:07 pm +0700, Duy Nguyen wrote:\n> On Mon, Jan 08, 2018 at 01:25:04PM +0100, Johannes Schindelin wrote:\n> > I agree that it would make a ton of sense to use a proper, portable test\n> > framework written in pure, portable C.\n> > \n> > However, this ship has long sailed, hasn't it?\n> \n> If you meant converting the whole test suite, oh yeah that's not gonna\n> happen. But it's still possible to have some tests written in C.\n> \n> I played a bit with this. The assumption is if it's agreed that we can\n> get something bare bone (but functional) in then we could start having\n> more and more C-based unit tests in future and also improve the C\n> framework to be on par with shell one on the side.\n> \n> There are still some minor problems with my patch, and a bunch of\n> optional features not supported. But the numbers looks unexpectedly\n> promising. 0.7 seconds on the shell version and 0.03 on the C one.\n\nI see even more promising results from a single run on one of my Cygwin\nsystems: from 21.3 seconds for t3070 to 0.112 seconds for your t3071.  I\nexpect there's a similar improvement in Dscho's Git for Windows\nenvironment.\n\n> One disadvantage of this though, if this kind of framework does not\n> get popular, then any new test feature must be added at both places\n> but it's a waste of time to support both. So...\n\nI don't follow: if we end up implementing every test twice, as we have\nhere, then I agree, but I don't think there's much value in doing that\nexcept as a proof of concept, as in this immediate discussion.  The\nobvious-to-me way to do this would be following the precedent of the\ncore code: gradually migrate things away from shell code to C code.\n\nAdam\n"},{"id":"336373","messageId":"CACsJy8D+OdRxr5MazYUzJXKVCpfC=faWCKTYX+E20kYvg9Pt=Q@mail.gmail.com","threadId":"47493","inReplyTo":"20180110103832.GA4018@dinwoodie.org","subject":"Re: [PATCH v4 8/7] wildmatch test: skip file creation tests on Windows proper","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-10T10:52:22Z","receivedAt":"2018-01-10T10:53:25Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Jan 10, 2018 at 5:38 PM, Adam Dinwoodie <adam@dinwoodie.org> wrote:\n>> One disadvantage of this though, if this kind of framework does not\n>> get popular, then any new test feature must be added at both places\n>> but it's a waste of time to support both. So...\n>\n> I don't follow: if we end up implementing every test twice, as we have\n> here, then I agree, but I don't think there's much value in doing that\n> except as a proof of concept, as in this immediate discussion.  The\n> obvious-to-me way to do this would be following the precedent of the\n> core code: gradually migrate things away from shell code to C code.\n\nNot the tests themselves. Test features, like --valgrind, --debug,\n--verbose and that kind of stuff. These are handled by test-lib.sh. If\nwe add support for --new-fancy-thing to test-lib.sh then we need some\nmore code in test-lib.c as well.\n-- \nDuy\n"},{"id":"336420","messageId":"nycvar.QRO.7.76.6.1801102057110.31@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz","threadId":"47493","inReplyTo":"20180110090724.GA2893@ash","subject":"Re: [PATCH v4 8/7] wildmatch test: skip file creation tests on Windows proper","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-01-10T20:24:31Z","receivedAt":"2018-01-10T20:24:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Duy,\n\nOn Wed, 10 Jan 2018, Duy Nguyen wrote:\n\n> On Mon, Jan 08, 2018 at 01:25:04PM +0100, Johannes Schindelin wrote:\n> > I agree that it would make a ton of sense to use a proper, portable test\n> > framework written in pure, portable C.\n> > \n> > However, this ship has long sailed, hasn't it?\n> \n> If you meant converting the whole test suite, oh yeah that's not gonna\n> happen. But it's still possible to have some tests written in C.\n\nTrue.\n\n> I played a bit with this. The assumption is if it's agreed that we can\n> get something bare bone (but functional) in then we could start having\n> more and more C-based unit tests in future and also improve the C\n> framework to be on par with shell one on the side.\n\nWe can also start with something small that does not contend to replace\nthe entire test suite, and evolve from there as we have time.\n\nYour initial patch looks very good, I will give it a cursory review (only\ncursory because we are technically in a feature-freeze...)\n\n> diff --git a/Makefile b/Makefile\n> index 2a81ae22e9..567387b558 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -644,6 +644,7 @@ X =\n>  \n>  PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))\n>  \n> +TEST_PROGRAMS_NEED_X += test-3071-wildmatch\n\nI guess I can always work on unifying those gazillion of test executables\ninto a single one later.\n\nFor testing purposes, I have to bundle them (BusyBox-based MinGit is\nsupposed to be stand-alone, yet I want to test it to verify that it works\neven if it ships only a subset of Git for Windows), and they dominate the\npayload of any prerelease, as you can see e.g. here:\nhttps://github.com/git-for-windows/git/releases/tag/v2.16.0-rc1.windows.1\n\n> diff --git a/t/helper/test-3071-wildmatch.c b/t/helper/test-3071-wildmatch.c\n> new file mode 100644\n> index 0000000000..24a657202d\n> --- /dev/null\n> +++ b/t/helper/test-3071-wildmatch.c\n> @@ -0,0 +1,273 @@\n> +#include \"cache.h\"\n> +#include \"test-lib.h\"\n> +\n> +struct match_input {\n> +\tint expect_true;\n> +\tconst char *text;\n> +\tconst char *pattern;\n> +};\n> +\n> +static struct match_input match_tests[] = {\n> +\t/* Basic wildmatch features */\n> +\t{ 1, \"foo\", \"foo\" },\n> +\t{ 0, \"foo\", \"bar\" },\n> +\t{ 1, \"\", \"\" },\n\nThese patterns share the \"magic-ness\" of Ævar's test cases... although\nyour version is certainly more concise.\n\nBTW IIRC Ævar explicitly said that he needs to use `ls-files` in order to\ntest the interaction with the index, so that would probably take a little\nbit more work.\n\n> diff --git a/t/t3071-wildmatch.sh b/t/t3071-wildmatch.sh\n> new file mode 100755\n> index 0000000000..6e83b4d684\n> --- /dev/null\n> +++ b/t/t3071-wildmatch.sh\n> @@ -0,0 +1,3 @@\n> +#!/bin/sh\n> +\n> +exec helper/test-3071-wildmatch t3071-wildmatch \"$@\"\n\nShould it not be `exec test-3071-wildmatch \"${0%.sh}\" \"$@\"`?\n\n> diff --git a/test-lib.c b/test-lib.c\n> new file mode 100644\n> index 0000000000..8e8b7cd6df\n> --- /dev/null\n> +++ b/test-lib.c\n> @@ -0,0 +1,97 @@\n> [...]\n\nLots of good stuff in there. Definitely a good start.\n\nCiao,\nDscho"},{"id":"336446","messageId":"CACsJy8CZY0F2AkBMEQPNkJ+8FTjV4+4PqijiFBHSCJ4Vc1572g@mail.gmail.com","threadId":"47493","inReplyTo":"nycvar.QRO.7.76.6.1801102057110.31@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz","subject":"Re: [PATCH v4 8/7] wildmatch test: skip file creation tests on Windows proper","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-01-11T09:25:18Z","receivedAt":"2018-01-11T09:25:59Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Jan 11, 2018 at 3:24 AM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n>> diff --git a/Makefile b/Makefile\n>> index 2a81ae22e9..567387b558 100644\n>> --- a/Makefile\n>> +++ b/Makefile\n>> @@ -644,6 +644,7 @@ X =\n>>\n>>  PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))\n>>\n>> +TEST_PROGRAMS_NEED_X += test-3071-wildmatch\n>\n> I guess I can always work on unifying those gazillion of test executables\n> into a single one later.\n\nOh yeah. I did notice your remark about disk consumption but this was\na quick hack that I would not bother with it. For the record I'm\nslightly bothered with many test programs too, not due to disk size\nbut because it increases link time (disk i/o probably also plays part\nin that). This may help another thing... at the end of the mail\n\n>> +static struct match_input match_tests[] = {\n>> +     /* Basic wildmatch features */\n>> +     { 1, \"foo\", \"foo\" },\n>> +     { 0, \"foo\", \"bar\" },\n>> +     { 1, \"\", \"\" },\n>\n> These patterns share the \"magic-ness\" of Ævar's test cases... although\n> your version is certainly more concise.\n\nAnother thing will make me move away from this style is, you can't\nmark one test broken. In the end, we may have some macro that issue\none match() call per line, very similar to how t3070 does now. Then we\nhave more freedom in marking tests.\n\n> BTW IIRC Ævar explicitly said that he needs to use `ls-files` in order to\n> test the interaction with the index, so that would probably take a little\n> bit more work.\n\nYeah, run_command() and stuff, not super hard (but then it opens up\nanother aspect I didn't address in this quick hack: collecting output\nlog of a test and only showing it when the test fails, could be\ntricker to do in C than shell.\n\n>> diff --git a/t/t3071-wildmatch.sh b/t/t3071-wildmatch.sh\n>> new file mode 100755\n>> index 0000000000..6e83b4d684\n>> --- /dev/null\n>> +++ b/t/t3071-wildmatch.sh\n>> @@ -0,0 +1,3 @@\n>> +#!/bin/sh\n>> +\n>> +exec helper/test-3071-wildmatch t3071-wildmatch \"$@\"\n>\n> Should it not be `exec test-3071-wildmatch \"${0%.sh}\" \"$@\"`?\n\nNo, test-lib.sh is required to set up $PATH properly so you can run\ntest programs without path. This is another sticky point. Some\nintegration with test-lib.sh is needed. I would like to have something\nlike this\n\n-- 8< --\ncat >t3071-wildmatch-c.sh <<EOF\n#!/bin/sh\n. ./test-lib.sh\nEOF\n-- 8< --\n\nand test-lib.sh will take care of finding the right program, passing\nthe right test name as argument... (a single test program covering all\ntest groups, rather than one binary per test group, would simplify\nthings here). We need something though to let test-lib.sh know this is\nC-based not shell to activate this mode. The \"-c\" suffix in the file\nname is for that purpose, but maybe we will figure out something\nbetter later. If it's too magical, this would do\n\n-- 8< --\ncat >t3071-wildmatch.sh <<EOF\n#!/bin/sh\n\n. ./test-lib.sh\n\nexec_c_tests # new function defined in test-lib.sh\nEOF\n-- 8< --\n-- \nDuy\n"},{"id":"337816","messageId":"20180130212124.2099-1-avarab@gmail.com","threadId":"47493","inReplyTo":"20180104192657.28019-1-avarab@gmail.com","subject":"[PATCH v5 00/10] increase wildmatch test coverage","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-30T21:21:14Z","receivedAt":"2018-01-30T21:21:43Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"v5 has been a long time coming (20 days since I said I'd re-roll\nthis), but hopefully this is a version that works well for everyone,\nincluding Windows users. Changes:\n\nÆvar Arnfjörð Bjarmason (10):\n  wildmatch test: indent with tabs, not spaces\n  wildmatch test: use more standard shell style\n  wildmatch test: don't try to vertically align our output\n  wildmatch test: use a paranoia pattern from nul_match()\n  wildmatch test: remove dead fnmatch() test code\n\nNo changes.\n\n  wildmatch test: use test_must_fail, not ! for test-wildmatch\n\nNEW: Fix a tiny nit I spotted while re-rolling.\n\n  wildmatch test: perform all tests under all wildmatch() modes\n\nThe testing of various wildmatch modes got factored into a\nfunction. It makes no difference to this patch, but makes a huge\ndifference in readability to the follow-up patch.\n\nAlso I stopped renaming \"match\" to \"wildtest\", I can't remeber why I\ndid that in the first place, but no point in doing that, and this\nmakes things easier to review...\n\n  wildmatch test: create & test files on disk in addition to in-memory\n\nAlmost entirely based on feedback from Johannes:\n\na) This is now much more friendly under -x, as little test code as\npossible outside actual tests.\n\nb) Factored out into functions\n\nc) Gave variables better names\n\nd) Hopefully runs under Windows now without errors, due to a blacklist\nof filenames that aren't allowed on Windows. Commit message now\nmentions this.\n\ne) This should be a lot faster than before, since I factored out the\nsetup work being done for every test so it's only done\n\nf) At this point I can't remember who/where this was pointed out, but\nit was observed that I was using a very dangerous looking `rm -rf --\n*` pattern in the old test, turns out this could be replaced with a\nless scary `git clean -df`.\n\n  test-lib: add an EXPENSIVE_ON_WINDOWS prerequisite\n  wildmatch test: mark test as EXPENSIVE_ON_WINDOWS\n\nFollow-up my 87mv1raz9p.fsf@evledraar.gmail.com from the v4 thread,\nand create an EXPENSIVE_ON_WINDOWS prerequisite, which is then used\nfor the file tests so they're skipped on Windows by default.\n\nEven though 8/10 should be faster now, and hopefully passes on\nWindows, I still expect it to be quite slow on Windows, so let's not\nrun it there by default unless under GIT_TEST_LONG=1.\n\n t/helper/test-wildmatch.c |   2 +\n t/t3070-wildmatch.sh      | 655 +++++++++++++++++++++++++++++-----------------\n t/test-lib.sh             |   4 +\n 3 files changed, 416 insertions(+), 245 deletions(-)\n\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"337817","messageId":"20180130212124.2099-2-avarab@gmail.com","threadId":"47493","inReplyTo":"20180130212124.2099-1-avarab@gmail.com","subject":"[PATCH v5 01/10] wildmatch test: indent with tabs, not spaces","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-30T21:21:15Z","receivedAt":"2018-01-30T21:21:48Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Replace the 4-width mixed space & tab indentation in this file with\nindentation with tabs as we do in most of the rest of our tests.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 54 ++++++++++++++++++++++++++--------------------------\n 1 file changed, 27 insertions(+), 27 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 163a14a1c2..27fa878f6e 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -5,39 +5,39 @@ test_description='wildmatch tests'\n . ./test-lib.sh\n \n match() {\n-    if [ $1 = 1 ]; then\n-\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n-\t    test-wildmatch wildmatch '$3' '$4'\n-\t\"\n-    else\n-\ttest_expect_success \"wildmatch:  no match '$3' '$4'\" \"\n-\t    ! test-wildmatch wildmatch '$3' '$4'\n-\t\"\n-    fi\n+\tif [ $1 = 1 ]; then\n+\t\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n+\t\t\ttest-wildmatch wildmatch '$3' '$4'\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"wildmatch:  no match '$3' '$4'\" \"\n+\t\t\t! test-wildmatch wildmatch '$3' '$4'\n+\t\t\"\n+\tfi\n }\n \n imatch() {\n-    if [ $1 = 1 ]; then\n-\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n-\t    test-wildmatch iwildmatch '$2' '$3'\n-\t\"\n-    else\n-\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n-\t    ! test-wildmatch iwildmatch '$2' '$3'\n-\t\"\n-    fi\n+\tif [ $1 = 1 ]; then\n+\t\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n+\t\t\ttest-wildmatch iwildmatch '$2' '$3'\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n+\t\t\t! test-wildmatch iwildmatch '$2' '$3'\n+\t\t\"\n+\tfi\n }\n \n pathmatch() {\n-    if [ $1 = 1 ]; then\n-\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n-\t    test-wildmatch pathmatch '$2' '$3'\n-\t\"\n-    else\n-\ttest_expect_success \"pathmatch:  no match '$2' '$3'\" \"\n-\t    ! test-wildmatch pathmatch '$2' '$3'\n-\t\"\n-    fi\n+\tif [ $1 = 1 ]; then\n+\t\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n+\t\t\ttest-wildmatch pathmatch '$2' '$3'\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"pathmatch:  no match '$2' '$3'\" \"\n+\t\t\t! test-wildmatch pathmatch '$2' '$3'\n+\t\t\"\n+\tfi\n }\n \n # Basic wildmat features\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"337818","messageId":"20180130212124.2099-3-avarab@gmail.com","threadId":"47493","inReplyTo":"20180130212124.2099-1-avarab@gmail.com","subject":"[PATCH v5 02/10] wildmatch test: use more standard shell style","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-30T21:21:16Z","receivedAt":"2018-01-30T21:21:50Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the wildmatch test to use more standard shell style, usually we\nuse \"if test\" not \"if [\".\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 9 ++++++---\n 1 file changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 27fa878f6e..4d589d1f9a 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -5,7 +5,8 @@ test_description='wildmatch tests'\n . ./test-lib.sh\n \n match() {\n-\tif [ $1 = 1 ]; then\n+\tif test \"$1\" = 1\n+\tthen\n \t\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n \t\t\ttest-wildmatch wildmatch '$3' '$4'\n \t\t\"\n@@ -17,7 +18,8 @@ match() {\n }\n \n imatch() {\n-\tif [ $1 = 1 ]; then\n+\tif test \"$1\" = 1\n+\tthen\n \t\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n \t\t\ttest-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n@@ -29,7 +31,8 @@ imatch() {\n }\n \n pathmatch() {\n-\tif [ $1 = 1 ]; then\n+\tif test \"$1\" = 1\n+\tthen\n \t\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n \t\t\ttest-wildmatch pathmatch '$2' '$3'\n \t\t\"\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"337819","messageId":"20180130212124.2099-4-avarab@gmail.com","threadId":"47493","inReplyTo":"20180130212124.2099-1-avarab@gmail.com","subject":"[PATCH v5 03/10] wildmatch test: don't try to vertically align our output","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-30T21:21:17Z","receivedAt":"2018-01-30T21:21:53Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Don't try to vertically align the test output, which is futile anyway\nunder the TAP output where we're going to be emitting a number for\neach test without aligning the test count.\n\nThis makes subsequent changes of mine where I'm not going to be\naligning this output as I add new tests easier.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 4d589d1f9a..19ea64bba9 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -7,11 +7,11 @@ test_description='wildmatch tests'\n match() {\n \tif test \"$1\" = 1\n \tthen\n-\t\ttest_expect_success \"wildmatch:     match '$3' '$4'\" \"\n+\t\ttest_expect_success \"wildmatch: match '$3' '$4'\" \"\n \t\t\ttest-wildmatch wildmatch '$3' '$4'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"wildmatch:  no match '$3' '$4'\" \"\n+\t\ttest_expect_success \"wildmatch: no match '$3' '$4'\" \"\n \t\t\t! test-wildmatch wildmatch '$3' '$4'\n \t\t\"\n \tfi\n@@ -20,7 +20,7 @@ match() {\n imatch() {\n \tif test \"$1\" = 1\n \tthen\n-\t\ttest_expect_success \"iwildmatch:    match '$2' '$3'\" \"\n+\t\ttest_expect_success \"iwildmatch: match '$2' '$3'\" \"\n \t\t\ttest-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n \telse\n@@ -33,11 +33,11 @@ imatch() {\n pathmatch() {\n \tif test \"$1\" = 1\n \tthen\n-\t\ttest_expect_success \"pathmatch:     match '$2' '$3'\" \"\n+\t\ttest_expect_success \"pathmatch: match '$2' '$3'\" \"\n \t\t\ttest-wildmatch pathmatch '$2' '$3'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"pathmatch:  no match '$2' '$3'\" \"\n+\t\ttest_expect_success \"pathmatch: no match '$2' '$3'\" \"\n \t\t\t! test-wildmatch pathmatch '$2' '$3'\n \t\t\"\n \tfi\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"337820","messageId":"20180130212124.2099-5-avarab@gmail.com","threadId":"47493","inReplyTo":"20180130212124.2099-1-avarab@gmail.com","subject":"[PATCH v5 04/10] wildmatch test: use a paranoia pattern from nul_match()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-30T21:21:18Z","receivedAt":"2018-01-30T21:22:03Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Use a pattern from the nul_match() function in t7008-grep-binary.sh to\nmake sure that we don't just fall through to the \"else\" if there's an\nunknown parameter.\n\nThis is something I added in commit 77f6f4406f (\"grep: add a test\nhelper function for less verbose -f \\0 tests\", 2017-05-20) to grep\ntests, which were modeled on these wildmatch tests, and I'm now\nporting back to the original wildmatch tests.\n\nI am not using the \"say '...'; exit 1\" pattern from t0000-basic.sh\nbecause if I fail I want to run the rest of the tests (unless under\n-i), and doing this makes sure we do that and don't exit right away\nwithout fully reporting our errors.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 15 ++++++++++++---\n 1 file changed, 12 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 19ea64bba9..9691d8eda3 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -10,10 +10,13 @@ match() {\n \t\ttest_expect_success \"wildmatch: match '$3' '$4'\" \"\n \t\t\ttest-wildmatch wildmatch '$3' '$4'\n \t\t\"\n-\telse\n+\telif test \"$1\" = 0\n+\tthen\n \t\ttest_expect_success \"wildmatch: no match '$3' '$4'\" \"\n \t\t\t! test-wildmatch wildmatch '$3' '$4'\n \t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n \tfi\n }\n \n@@ -23,10 +26,13 @@ imatch() {\n \t\ttest_expect_success \"iwildmatch: match '$2' '$3'\" \"\n \t\t\ttest-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n-\telse\n+\telif test \"$1\" = 0\n+\tthen\n \t\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n \t\t\t! test-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n \tfi\n }\n \n@@ -36,10 +42,13 @@ pathmatch() {\n \t\ttest_expect_success \"pathmatch: match '$2' '$3'\" \"\n \t\t\ttest-wildmatch pathmatch '$2' '$3'\n \t\t\"\n-\telse\n+\telif test \"$1\" = 0\n+\tthen\n \t\ttest_expect_success \"pathmatch: no match '$2' '$3'\" \"\n \t\t\t! test-wildmatch pathmatch '$2' '$3'\n \t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n \tfi\n }\n \n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"337821","messageId":"20180130212124.2099-7-avarab@gmail.com","threadId":"47493","inReplyTo":"20180130212124.2099-1-avarab@gmail.com","subject":"[PATCH v5 06/10] wildmatch test: use test_must_fail, not ! for test-wildmatch","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-30T21:21:20Z","receivedAt":"2018-01-30T21:22:10Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Use of ! should be reserved for non-git programs that are assumed not\nto fail, see README. With this change only\nt/t0110-urlmatch-normalization.sh is still using this anti-pattern.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 2f8a681c72..fe0e5103a3 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -13,7 +13,7 @@ match() {\n \telif test \"$1\" = 0\n \tthen\n \t\ttest_expect_success \"wildmatch: no match '$2' '$3'\" \"\n-\t\t\t! test-wildmatch wildmatch '$2' '$3'\n+\t\t\ttest_must_fail test-wildmatch wildmatch '$2' '$3'\n \t\t\"\n \telse\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n@@ -29,7 +29,7 @@ imatch() {\n \telif test \"$1\" = 0\n \tthen\n \t\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n-\t\t\t! test-wildmatch iwildmatch '$2' '$3'\n+\t\t\ttest_must_fail test-wildmatch iwildmatch '$2' '$3'\n \t\t\"\n \telse\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n@@ -45,7 +45,7 @@ pathmatch() {\n \telif test \"$1\" = 0\n \tthen\n \t\ttest_expect_success \"pathmatch: no match '$2' '$3'\" \"\n-\t\t\t! test-wildmatch pathmatch '$2' '$3'\n+\t\t\ttest_must_fail test-wildmatch pathmatch '$2' '$3'\n \t\t\"\n \telse\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"337822","messageId":"20180130212124.2099-6-avarab@gmail.com","threadId":"47493","inReplyTo":"20180130212124.2099-1-avarab@gmail.com","subject":"[PATCH v5 05/10] wildmatch test: remove dead fnmatch() test code","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-30T21:21:19Z","receivedAt":"2018-01-30T21:22:12Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove the unused fnmatch() test parameter from the wildmatch\ntest. The code that used to test this was removed in 70a8fc999d (\"stop\nusing fnmatch (either native or compat)\", 2014-02-15).\n\nAs a --word-diff shows the only change to the body of the tests is the\nremoval of the second out of four parameters passed to match().\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 356 +++++++++++++++++++++++++--------------------------\n 1 file changed, 178 insertions(+), 178 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 9691d8eda3..2f8a681c72 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -7,13 +7,13 @@ test_description='wildmatch tests'\n match() {\n \tif test \"$1\" = 1\n \tthen\n-\t\ttest_expect_success \"wildmatch: match '$3' '$4'\" \"\n-\t\t\ttest-wildmatch wildmatch '$3' '$4'\n+\t\ttest_expect_success \"wildmatch: match '$2' '$3'\" \"\n+\t\t\ttest-wildmatch wildmatch '$2' '$3'\n \t\t\"\n \telif test \"$1\" = 0\n \tthen\n-\t\ttest_expect_success \"wildmatch: no match '$3' '$4'\" \"\n-\t\t\t! test-wildmatch wildmatch '$3' '$4'\n+\t\ttest_expect_success \"wildmatch: no match '$2' '$3'\" \"\n+\t\t\t! test-wildmatch wildmatch '$2' '$3'\n \t\t\"\n \telse\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n@@ -53,176 +53,176 @@ pathmatch() {\n }\n \n # Basic wildmat features\n-match 1 1 foo foo\n-match 0 0 foo bar\n-match 1 1 '' \"\"\n-match 1 1 foo '???'\n-match 0 0 foo '??'\n-match 1 1 foo '*'\n-match 1 1 foo 'f*'\n-match 0 0 foo '*f'\n-match 1 1 foo '*foo*'\n-match 1 1 foobar '*ob*a*r*'\n-match 1 1 aaaaaaabababab '*ab'\n-match 1 1 'foo*' 'foo\\*'\n-match 0 0 foobar 'foo\\*bar'\n-match 1 1 'f\\oo' 'f\\\\oo'\n-match 1 1 ball '*[al]?'\n-match 0 0 ten '[ten]'\n-match 0 1 ten '**[!te]'\n-match 0 0 ten '**[!ten]'\n-match 1 1 ten 't[a-g]n'\n-match 0 0 ten 't[!a-g]n'\n-match 1 1 ton 't[!a-g]n'\n-match 1 1 ton 't[^a-g]n'\n-match 1 x 'a]b' 'a[]]b'\n-match 1 x a-b 'a[]-]b'\n-match 1 x 'a]b' 'a[]-]b'\n-match 0 x aab 'a[]-]b'\n-match 1 x aab 'a[]a-]b'\n-match 1 1 ']' ']'\n+match 1 foo foo\n+match 0 foo bar\n+match 1 '' \"\"\n+match 1 foo '???'\n+match 0 foo '??'\n+match 1 foo '*'\n+match 1 foo 'f*'\n+match 0 foo '*f'\n+match 1 foo '*foo*'\n+match 1 foobar '*ob*a*r*'\n+match 1 aaaaaaabababab '*ab'\n+match 1 'foo*' 'foo\\*'\n+match 0 foobar 'foo\\*bar'\n+match 1 'f\\oo' 'f\\\\oo'\n+match 1 ball '*[al]?'\n+match 0 ten '[ten]'\n+match 0 ten '**[!te]'\n+match 0 ten '**[!ten]'\n+match 1 ten 't[a-g]n'\n+match 0 ten 't[!a-g]n'\n+match 1 ton 't[!a-g]n'\n+match 1 ton 't[^a-g]n'\n+match 1 'a]b' 'a[]]b'\n+match 1 a-b 'a[]-]b'\n+match 1 'a]b' 'a[]-]b'\n+match 0 aab 'a[]-]b'\n+match 1 aab 'a[]a-]b'\n+match 1 ']' ']'\n \n # Extended slash-matching features\n-match 0 0 'foo/baz/bar' 'foo*bar'\n-match 0 0 'foo/baz/bar' 'foo**bar'\n-match 0 1 'foobazbar' 'foo**bar'\n-match 1 1 'foo/baz/bar' 'foo/**/bar'\n-match 1 0 'foo/baz/bar' 'foo/**/**/bar'\n-match 1 0 'foo/b/a/z/bar' 'foo/**/bar'\n-match 1 0 'foo/b/a/z/bar' 'foo/**/**/bar'\n-match 1 0 'foo/bar' 'foo/**/bar'\n-match 1 0 'foo/bar' 'foo/**/**/bar'\n-match 0 0 'foo/bar' 'foo?bar'\n-match 0 0 'foo/bar' 'foo[/]bar'\n-match 0 0 'foo/bar' 'foo[^a-z]bar'\n-match 0 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 0 'foo' '**/foo'\n-match 1 x 'XXX/foo' '**/foo'\n-match 1 0 'bar/baz/foo' '**/foo'\n-match 0 0 'bar/baz/foo' '*/foo'\n-match 0 0 'foo/bar/baz' '**/bar*'\n-match 1 0 'deep/foo/bar/baz' '**/bar/*'\n-match 0 0 'deep/foo/bar/baz/' '**/bar/*'\n-match 1 0 'deep/foo/bar/baz/' '**/bar/**'\n-match 0 0 'deep/foo/bar' '**/bar/*'\n-match 1 0 'deep/foo/bar/' '**/bar/**'\n-match 0 0 'foo/bar/baz' '**/bar**'\n-match 1 0 'foo/bar/baz/x' '*/bar/**'\n-match 0 0 'deep/foo/bar/baz/x' '*/bar/**'\n-match 1 0 'deep/foo/bar/baz/x' '**/bar/*/*'\n+match 0 'foo/baz/bar' 'foo*bar'\n+match 0 'foo/baz/bar' 'foo**bar'\n+match 0 'foobazbar' 'foo**bar'\n+match 1 'foo/baz/bar' 'foo/**/bar'\n+match 1 'foo/baz/bar' 'foo/**/**/bar'\n+match 1 'foo/b/a/z/bar' 'foo/**/bar'\n+match 1 'foo/b/a/z/bar' 'foo/**/**/bar'\n+match 1 'foo/bar' 'foo/**/bar'\n+match 1 'foo/bar' 'foo/**/**/bar'\n+match 0 'foo/bar' 'foo?bar'\n+match 0 'foo/bar' 'foo[/]bar'\n+match 0 'foo/bar' 'foo[^a-z]bar'\n+match 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+match 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+match 1 'foo' '**/foo'\n+match 1 'XXX/foo' '**/foo'\n+match 1 'bar/baz/foo' '**/foo'\n+match 0 'bar/baz/foo' '*/foo'\n+match 0 'foo/bar/baz' '**/bar*'\n+match 1 'deep/foo/bar/baz' '**/bar/*'\n+match 0 'deep/foo/bar/baz/' '**/bar/*'\n+match 1 'deep/foo/bar/baz/' '**/bar/**'\n+match 0 'deep/foo/bar' '**/bar/*'\n+match 1 'deep/foo/bar/' '**/bar/**'\n+match 0 'foo/bar/baz' '**/bar**'\n+match 1 'foo/bar/baz/x' '*/bar/**'\n+match 0 'deep/foo/bar/baz/x' '*/bar/**'\n+match 1 'deep/foo/bar/baz/x' '**/bar/*/*'\n \n # Various additional tests\n-match 0 0 'acrt' 'a[c-c]st'\n-match 1 1 'acrt' 'a[c-c]rt'\n-match 0 0 ']' '[!]-]'\n-match 1 x 'a' '[!]-]'\n-match 0 0 '' '\\'\n-match 0 x '\\' '\\'\n-match 0 x 'XXX/\\' '*/\\'\n-match 1 x 'XXX/\\' '*/\\\\'\n-match 1 1 'foo' 'foo'\n-match 1 1 '@foo' '@foo'\n-match 0 0 'foo' '@foo'\n-match 1 1 '[ab]' '\\[ab]'\n-match 1 1 '[ab]' '[[]ab]'\n-match 1 x '[ab]' '[[:]ab]'\n-match 0 x '[ab]' '[[::]ab]'\n-match 1 x '[ab]' '[[:digit]ab]'\n-match 1 x '[ab]' '[\\[:]ab]'\n-match 1 1 '?a?b' '\\??\\?b'\n-match 1 1 'abc' '\\a\\b\\c'\n-match 0 0 'foo' ''\n-match 1 0 'foo/bar/baz/to' '**/t[o]'\n+match 0 'acrt' 'a[c-c]st'\n+match 1 'acrt' 'a[c-c]rt'\n+match 0 ']' '[!]-]'\n+match 1 'a' '[!]-]'\n+match 0 '' '\\'\n+match 0 '\\' '\\'\n+match 0 'XXX/\\' '*/\\'\n+match 1 'XXX/\\' '*/\\\\'\n+match 1 'foo' 'foo'\n+match 1 '@foo' '@foo'\n+match 0 'foo' '@foo'\n+match 1 '[ab]' '\\[ab]'\n+match 1 '[ab]' '[[]ab]'\n+match 1 '[ab]' '[[:]ab]'\n+match 0 '[ab]' '[[::]ab]'\n+match 1 '[ab]' '[[:digit]ab]'\n+match 1 '[ab]' '[\\[:]ab]'\n+match 1 '?a?b' '\\??\\?b'\n+match 1 'abc' '\\a\\b\\c'\n+match 0 'foo' ''\n+match 1 'foo/bar/baz/to' '**/t[o]'\n \n # Character class tests\n-match 1 x 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n-match 0 x 'a' '[[:digit:][:upper:][:space:]]'\n-match 1 x 'A' '[[:digit:][:upper:][:space:]]'\n-match 1 x '1' '[[:digit:][:upper:][:space:]]'\n-match 0 x '1' '[[:digit:][:upper:][:spaci:]]'\n-match 1 x ' ' '[[:digit:][:upper:][:space:]]'\n-match 0 x '.' '[[:digit:][:upper:][:space:]]'\n-match 1 x '.' '[[:digit:][:punct:][:space:]]'\n-match 1 x '5' '[[:xdigit:]]'\n-match 1 x 'f' '[[:xdigit:]]'\n-match 1 x 'D' '[[:xdigit:]]'\n-match 1 x '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n-match 1 x '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n-match 1 x '5' '[a-c[:digit:]x-z]'\n-match 1 x 'b' '[a-c[:digit:]x-z]'\n-match 1 x 'y' '[a-c[:digit:]x-z]'\n-match 0 x 'q' '[a-c[:digit:]x-z]'\n+match 1 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n+match 0 'a' '[[:digit:][:upper:][:space:]]'\n+match 1 'A' '[[:digit:][:upper:][:space:]]'\n+match 1 '1' '[[:digit:][:upper:][:space:]]'\n+match 0 '1' '[[:digit:][:upper:][:spaci:]]'\n+match 1 ' ' '[[:digit:][:upper:][:space:]]'\n+match 0 '.' '[[:digit:][:upper:][:space:]]'\n+match 1 '.' '[[:digit:][:punct:][:space:]]'\n+match 1 '5' '[[:xdigit:]]'\n+match 1 'f' '[[:xdigit:]]'\n+match 1 'D' '[[:xdigit:]]'\n+match 1 '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n+match 1 '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n+match 1 '5' '[a-c[:digit:]x-z]'\n+match 1 'b' '[a-c[:digit:]x-z]'\n+match 1 'y' '[a-c[:digit:]x-z]'\n+match 0 'q' '[a-c[:digit:]x-z]'\n \n # Additional tests, including some malformed wildmats\n-match 1 x ']' '[\\\\-^]'\n-match 0 0 '[' '[\\\\-^]'\n-match 1 x '-' '[\\-_]'\n-match 1 x ']' '[\\]]'\n-match 0 0 '\\]' '[\\]]'\n-match 0 0 '\\' '[\\]]'\n-match 0 0 'ab' 'a[]b'\n-match 0 x 'a[]b' 'a[]b'\n-match 0 x 'ab[' 'ab['\n-match 0 0 'ab' '[!'\n-match 0 0 'ab' '[-'\n-match 1 1 '-' '[-]'\n-match 0 0 '-' '[a-'\n-match 0 0 '-' '[!a-'\n-match 1 x '-' '[--A]'\n-match 1 x '5' '[--A]'\n-match 1 1 ' ' '[ --]'\n-match 1 1 '$' '[ --]'\n-match 1 1 '-' '[ --]'\n-match 0 0 '0' '[ --]'\n-match 1 x '-' '[---]'\n-match 1 x '-' '[------]'\n-match 0 0 'j' '[a-e-n]'\n-match 1 x '-' '[a-e-n]'\n-match 1 x 'a' '[!------]'\n-match 0 0 '[' '[]-a]'\n-match 1 x '^' '[]-a]'\n-match 0 0 '^' '[!]-a]'\n-match 1 x '[' '[!]-a]'\n-match 1 1 '^' '[a^bc]'\n-match 1 x '-b]' '[a-]b]'\n-match 0 0 '\\' '[\\]'\n-match 1 1 '\\' '[\\\\]'\n-match 0 0 '\\' '[!\\\\]'\n-match 1 1 'G' '[A-\\\\]'\n-match 0 0 'aaabbb' 'b*a'\n-match 0 0 'aabcaa' '*ba*'\n-match 1 1 ',' '[,]'\n-match 1 1 ',' '[\\\\,]'\n-match 1 1 '\\' '[\\\\,]'\n-match 1 1 '-' '[,-.]'\n-match 0 0 '+' '[,-.]'\n-match 0 0 '-.]' '[,-.]'\n-match 1 1 '2' '[\\1-\\3]'\n-match 1 1 '3' '[\\1-\\3]'\n-match 0 0 '4' '[\\1-\\3]'\n-match 1 1 '\\' '[[-\\]]'\n-match 1 1 '[' '[[-\\]]'\n-match 1 1 ']' '[[-\\]]'\n-match 0 0 '-' '[[-\\]]'\n+match 1 ']' '[\\\\-^]'\n+match 0 '[' '[\\\\-^]'\n+match 1 '-' '[\\-_]'\n+match 1 ']' '[\\]]'\n+match 0 '\\]' '[\\]]'\n+match 0 '\\' '[\\]]'\n+match 0 'ab' 'a[]b'\n+match 0 'a[]b' 'a[]b'\n+match 0 'ab[' 'ab['\n+match 0 'ab' '[!'\n+match 0 'ab' '[-'\n+match 1 '-' '[-]'\n+match 0 '-' '[a-'\n+match 0 '-' '[!a-'\n+match 1 '-' '[--A]'\n+match 1 '5' '[--A]'\n+match 1 ' ' '[ --]'\n+match 1 '$' '[ --]'\n+match 1 '-' '[ --]'\n+match 0 '0' '[ --]'\n+match 1 '-' '[---]'\n+match 1 '-' '[------]'\n+match 0 'j' '[a-e-n]'\n+match 1 '-' '[a-e-n]'\n+match 1 'a' '[!------]'\n+match 0 '[' '[]-a]'\n+match 1 '^' '[]-a]'\n+match 0 '^' '[!]-a]'\n+match 1 '[' '[!]-a]'\n+match 1 '^' '[a^bc]'\n+match 1 '-b]' '[a-]b]'\n+match 0 '\\' '[\\]'\n+match 1 '\\' '[\\\\]'\n+match 0 '\\' '[!\\\\]'\n+match 1 'G' '[A-\\\\]'\n+match 0 'aaabbb' 'b*a'\n+match 0 'aabcaa' '*ba*'\n+match 1 ',' '[,]'\n+match 1 ',' '[\\\\,]'\n+match 1 '\\' '[\\\\,]'\n+match 1 '-' '[,-.]'\n+match 0 '+' '[,-.]'\n+match 0 '-.]' '[,-.]'\n+match 1 '2' '[\\1-\\3]'\n+match 1 '3' '[\\1-\\3]'\n+match 0 '4' '[\\1-\\3]'\n+match 1 '\\' '[[-\\]]'\n+match 1 '[' '[[-\\]]'\n+match 1 ']' '[[-\\]]'\n+match 0 '-' '[[-\\]]'\n \n # Test recursion and the abort code (use \"wildtest -i\" to see iteration counts)\n-match 1 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 1 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n-match 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n-match 0 x foo '*/*/*'\n-match 0 x foo/bar '*/*/*'\n-match 1 x foo/bba/arr '*/*/*'\n-match 0 x foo/bb/aa/rr '*/*/*'\n-match 1 x foo/bb/aa/rr '**/**/**'\n-match 1 x abcXdefXghi '*X*i'\n-match 0 x ab/cXd/efXg/hi '*X*i'\n-match 1 x ab/cXd/efXg/hi '*/*X*/*/*i'\n-match 1 x ab/cXd/efXg/hi '**/*X*/**/*i'\n+match 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+match 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+match 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+match 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+match 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+match 1 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n+match 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n+match 0 foo '*/*/*'\n+match 0 foo/bar '*/*/*'\n+match 1 foo/bba/arr '*/*/*'\n+match 0 foo/bb/aa/rr '*/*/*'\n+match 1 foo/bb/aa/rr '**/**/**'\n+match 1 abcXdefXghi '*X*i'\n+match 0 ab/cXd/efXg/hi '*X*i'\n+match 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n+match 1 ab/cXd/efXg/hi '**/*X*/**/*i'\n \n pathmatch 1 foo foo\n pathmatch 0 foo fo\n@@ -248,20 +248,20 @@ pathmatch 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n pathmatch 1 ab/cXd/efXg/hi '*Xg*i'\n \n # Case-sensitivity features\n-match 0 x 'a' '[A-Z]'\n-match 1 x 'A' '[A-Z]'\n-match 0 x 'A' '[a-z]'\n-match 1 x 'a' '[a-z]'\n-match 0 x 'a' '[[:upper:]]'\n-match 1 x 'A' '[[:upper:]]'\n-match 0 x 'A' '[[:lower:]]'\n-match 1 x 'a' '[[:lower:]]'\n-match 0 x 'A' '[B-Za]'\n-match 1 x 'a' '[B-Za]'\n-match 0 x 'A' '[B-a]'\n-match 1 x 'a' '[B-a]'\n-match 0 x 'z' '[Z-y]'\n-match 1 x 'Z' '[Z-y]'\n+match 0 'a' '[A-Z]'\n+match 1 'A' '[A-Z]'\n+match 0 'A' '[a-z]'\n+match 1 'a' '[a-z]'\n+match 0 'a' '[[:upper:]]'\n+match 1 'A' '[[:upper:]]'\n+match 0 'A' '[[:lower:]]'\n+match 1 'a' '[[:lower:]]'\n+match 0 'A' '[B-Za]'\n+match 1 'a' '[B-Za]'\n+match 0 'A' '[B-a]'\n+match 1 'a' '[B-a]'\n+match 0 'z' '[Z-y]'\n+match 1 'Z' '[Z-y]'\n \n imatch 1 'a' '[A-Z]'\n imatch 1 'A' '[A-Z]'\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"337823","messageId":"20180130212124.2099-8-avarab@gmail.com","threadId":"47493","inReplyTo":"20180130212124.2099-1-avarab@gmail.com","subject":"[PATCH v5 07/10] wildmatch test: perform all tests under all wildmatch() modes","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-30T21:21:21Z","receivedAt":"2018-01-30T21:22:14Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Rewrite the wildmatch() test suite so that each test now tests all\ncombinations of the wildmatch() WM_CASEFOLD and WM_PATHNAME flags.\n\nBefore this change some test inputs were not tested on\ne.g. WM_PATHNAME. Now the function is stress tested on all possible\ninputs, and for each input we declare what the result should be if the\nmode is case-insensitive, or pathname matching, or case-sensitive or\nnot matching pathnames.\n\nAlso before this change, nothing was testing case-insensitive\nnon-pathname matching, so I've added that to test-wildmatch.c and made\nuse of it.\n\nThis yields a rather scary patch, but there are no functional changes\nhere, just more test coverage. Some now-redundant tests were deleted\nas a result of this change, since they were now duplicating an earlier\ntest.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/helper/test-wildmatch.c |   2 +\n t/t3070-wildmatch.sh      | 478 ++++++++++++++++++++++------------------------\n 2 files changed, 228 insertions(+), 252 deletions(-)\n\ndiff --git a/t/helper/test-wildmatch.c b/t/helper/test-wildmatch.c\nindex 921d7b3e7e..66d33dfcfd 100644\n--- a/t/helper/test-wildmatch.c\n+++ b/t/helper/test-wildmatch.c\n@@ -16,6 +16,8 @@ int cmd_main(int argc, const char **argv)\n \t\treturn !!wildmatch(argv[3], argv[2], WM_PATHNAME | WM_CASEFOLD);\n \telse if (!strcmp(argv[1], \"pathmatch\"))\n \t\treturn !!wildmatch(argv[3], argv[2], 0);\n+\telse if (!strcmp(argv[1], \"ipathmatch\"))\n+\t\treturn !!wildmatch(argv[3], argv[2], WM_CASEFOLD);\n \telse\n \t\treturn 1;\n }\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex fe0e5103a3..3e75cb0cbe 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -4,278 +4,252 @@ test_description='wildmatch tests'\n \n . ./test-lib.sh\n \n-match() {\n-\tif test \"$1\" = 1\n-\tthen\n-\t\ttest_expect_success \"wildmatch: match '$2' '$3'\" \"\n-\t\t\ttest-wildmatch wildmatch '$2' '$3'\n-\t\t\"\n-\telif test \"$1\" = 0\n-\tthen\n-\t\ttest_expect_success \"wildmatch: no match '$2' '$3'\" \"\n-\t\t\ttest_must_fail test-wildmatch wildmatch '$2' '$3'\n-\t\t\"\n-\telse\n-\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n-\tfi\n-}\n+match_with_function() {\n+\ttext=$1\n+\tpattern=$2\n+\tmatch_expect=$3\n+\tmatch_function=$4\n \n-imatch() {\n-\tif test \"$1\" = 1\n+\tif test \"$match_expect\" = 1\n \tthen\n-\t\ttest_expect_success \"iwildmatch: match '$2' '$3'\" \"\n-\t\t\ttest-wildmatch iwildmatch '$2' '$3'\n+\t\ttest_expect_success \"$match_function: match '$text' '$pattern'\" \"\n+\t\t\ttest-wildmatch $match_function '$text' '$pattern'\n \t\t\"\n-\telif test \"$1\" = 0\n+\telif test \"$match_expect\" = 0\n \tthen\n-\t\ttest_expect_success \"iwildmatch: no match '$2' '$3'\" \"\n-\t\t\ttest_must_fail test-wildmatch iwildmatch '$2' '$3'\n+\t\ttest_expect_success \"$match_function: no match '$text' '$pattern'\" \"\n+\t\t\ttest_must_fail test-wildmatch $match_function '$text' '$pattern'\n \t\t\"\n \telse\n-\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_expect\" 'false'\n \tfi\n+\n }\n \n-pathmatch() {\n-\tif test \"$1\" = 1\n-\tthen\n-\t\ttest_expect_success \"pathmatch: match '$2' '$3'\" \"\n-\t\t\ttest-wildmatch pathmatch '$2' '$3'\n-\t\t\"\n-\telif test \"$1\" = 0\n-\tthen\n-\t\ttest_expect_success \"pathmatch: no match '$2' '$3'\" \"\n-\t\t\ttest_must_fail test-wildmatch pathmatch '$2' '$3'\n-\t\t\"\n-\telse\n-\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $1\" 'false'\n-\tfi\n+match() {\n+\tmatch_glob=$1\n+\tmatch_iglob=$2\n+\tmatch_pathmatch=$3\n+\tmatch_pathmatchi=$4\n+\ttext=$5\n+\tpattern=$6\n+\n+\t# $1: Case sensitive glob match: test-wildmatch & ls-files\n+\tmatch_with_function \"$text\" \"$pattern\" $match_glob \"wildmatch\"\n+\n+\t# $2: Case insensitive glob match: test-wildmatch & ls-files\n+\tmatch_with_function \"$text\" \"$pattern\" $match_iglob \"iwildmatch\"\n+\n+\t# $3: Case sensitive path match: test-wildmatch & ls-files\n+\tmatch_with_function \"$text\" \"$pattern\" $match_pathmatch \"pathmatch\"\n+\n+\t# $4: Case insensitive path match: test-wildmatch & ls-files\n+\tmatch_with_function \"$text\" \"$pattern\" $match_pathmatchi \"ipathmatch\"\n }\n \n-# Basic wildmat features\n-match 1 foo foo\n-match 0 foo bar\n-match 1 '' \"\"\n-match 1 foo '???'\n-match 0 foo '??'\n-match 1 foo '*'\n-match 1 foo 'f*'\n-match 0 foo '*f'\n-match 1 foo '*foo*'\n-match 1 foobar '*ob*a*r*'\n-match 1 aaaaaaabababab '*ab'\n-match 1 'foo*' 'foo\\*'\n-match 0 foobar 'foo\\*bar'\n-match 1 'f\\oo' 'f\\\\oo'\n-match 1 ball '*[al]?'\n-match 0 ten '[ten]'\n-match 0 ten '**[!te]'\n-match 0 ten '**[!ten]'\n-match 1 ten 't[a-g]n'\n-match 0 ten 't[!a-g]n'\n-match 1 ton 't[!a-g]n'\n-match 1 ton 't[^a-g]n'\n-match 1 'a]b' 'a[]]b'\n-match 1 a-b 'a[]-]b'\n-match 1 'a]b' 'a[]-]b'\n-match 0 aab 'a[]-]b'\n-match 1 aab 'a[]a-]b'\n-match 1 ']' ']'\n+# Basic wildmatch features\n+match 1 1 1 1 foo foo\n+match 0 0 0 0 foo bar\n+match 1 1 1 1 '' \"\"\n+match 1 1 1 1 foo '???'\n+match 0 0 0 0 foo '??'\n+match 1 1 1 1 foo '*'\n+match 1 1 1 1 foo 'f*'\n+match 0 0 0 0 foo '*f'\n+match 1 1 1 1 foo '*foo*'\n+match 1 1 1 1 foobar '*ob*a*r*'\n+match 1 1 1 1 aaaaaaabababab '*ab'\n+match 1 1 1 1 'foo*' 'foo\\*'\n+match 0 0 0 0 foobar 'foo\\*bar'\n+match 1 1 1 1 'f\\oo' 'f\\\\oo'\n+match 1 1 1 1 ball '*[al]?'\n+match 0 0 0 0 ten '[ten]'\n+match 0 0 1 1 ten '**[!te]'\n+match 0 0 0 0 ten '**[!ten]'\n+match 1 1 1 1 ten 't[a-g]n'\n+match 0 0 0 0 ten 't[!a-g]n'\n+match 1 1 1 1 ton 't[!a-g]n'\n+match 1 1 1 1 ton 't[^a-g]n'\n+match 1 1 1 1 'a]b' 'a[]]b'\n+match 1 1 1 1 a-b 'a[]-]b'\n+match 1 1 1 1 'a]b' 'a[]-]b'\n+match 0 0 0 0 aab 'a[]-]b'\n+match 1 1 1 1 aab 'a[]a-]b'\n+match 1 1 1 1 ']' ']'\n \n # Extended slash-matching features\n-match 0 'foo/baz/bar' 'foo*bar'\n-match 0 'foo/baz/bar' 'foo**bar'\n-match 0 'foobazbar' 'foo**bar'\n-match 1 'foo/baz/bar' 'foo/**/bar'\n-match 1 'foo/baz/bar' 'foo/**/**/bar'\n-match 1 'foo/b/a/z/bar' 'foo/**/bar'\n-match 1 'foo/b/a/z/bar' 'foo/**/**/bar'\n-match 1 'foo/bar' 'foo/**/bar'\n-match 1 'foo/bar' 'foo/**/**/bar'\n-match 0 'foo/bar' 'foo?bar'\n-match 0 'foo/bar' 'foo[/]bar'\n-match 0 'foo/bar' 'foo[^a-z]bar'\n-match 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n-match 1 'foo' '**/foo'\n-match 1 'XXX/foo' '**/foo'\n-match 1 'bar/baz/foo' '**/foo'\n-match 0 'bar/baz/foo' '*/foo'\n-match 0 'foo/bar/baz' '**/bar*'\n-match 1 'deep/foo/bar/baz' '**/bar/*'\n-match 0 'deep/foo/bar/baz/' '**/bar/*'\n-match 1 'deep/foo/bar/baz/' '**/bar/**'\n-match 0 'deep/foo/bar' '**/bar/*'\n-match 1 'deep/foo/bar/' '**/bar/**'\n-match 0 'foo/bar/baz' '**/bar**'\n-match 1 'foo/bar/baz/x' '*/bar/**'\n-match 0 'deep/foo/bar/baz/x' '*/bar/**'\n-match 1 'deep/foo/bar/baz/x' '**/bar/*/*'\n+match 0 0 1 1 'foo/baz/bar' 'foo*bar'\n+match 0 0 1 1 'foo/baz/bar' 'foo**bar'\n+match 0 0 1 1 'foobazbar' 'foo**bar'\n+match 1 1 1 1 'foo/baz/bar' 'foo/**/bar'\n+match 1 1 0 0 'foo/baz/bar' 'foo/**/**/bar'\n+match 1 1 1 1 'foo/b/a/z/bar' 'foo/**/bar'\n+match 1 1 1 1 'foo/b/a/z/bar' 'foo/**/**/bar'\n+match 1 1 0 0 'foo/bar' 'foo/**/bar'\n+match 1 1 0 0 'foo/bar' 'foo/**/**/bar'\n+match 0 0 1 1 'foo/bar' 'foo?bar'\n+match 0 0 1 1 'foo/bar' 'foo[/]bar'\n+match 0 0 1 1 'foo/bar' 'foo[^a-z]bar'\n+match 0 0 1 1 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+match 1 1 1 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'\n+match 1 1 0 0 'foo' '**/foo'\n+match 1 1 1 1 'XXX/foo' '**/foo'\n+match 1 1 1 1 'bar/baz/foo' '**/foo'\n+match 0 0 1 1 'bar/baz/foo' '*/foo'\n+match 0 0 1 1 'foo/bar/baz' '**/bar*'\n+match 1 1 1 1 'deep/foo/bar/baz' '**/bar/*'\n+match 0 0 1 1 'deep/foo/bar/baz/' '**/bar/*'\n+match 1 1 1 1 'deep/foo/bar/baz/' '**/bar/**'\n+match 0 0 0 0 'deep/foo/bar' '**/bar/*'\n+match 1 1 1 1 'deep/foo/bar/' '**/bar/**'\n+match 0 0 1 1 'foo/bar/baz' '**/bar**'\n+match 1 1 1 1 'foo/bar/baz/x' '*/bar/**'\n+match 0 0 1 1 'deep/foo/bar/baz/x' '*/bar/**'\n+match 1 1 1 1 'deep/foo/bar/baz/x' '**/bar/*/*'\n \n # Various additional tests\n-match 0 'acrt' 'a[c-c]st'\n-match 1 'acrt' 'a[c-c]rt'\n-match 0 ']' '[!]-]'\n-match 1 'a' '[!]-]'\n-match 0 '' '\\'\n-match 0 '\\' '\\'\n-match 0 'XXX/\\' '*/\\'\n-match 1 'XXX/\\' '*/\\\\'\n-match 1 'foo' 'foo'\n-match 1 '@foo' '@foo'\n-match 0 'foo' '@foo'\n-match 1 '[ab]' '\\[ab]'\n-match 1 '[ab]' '[[]ab]'\n-match 1 '[ab]' '[[:]ab]'\n-match 0 '[ab]' '[[::]ab]'\n-match 1 '[ab]' '[[:digit]ab]'\n-match 1 '[ab]' '[\\[:]ab]'\n-match 1 '?a?b' '\\??\\?b'\n-match 1 'abc' '\\a\\b\\c'\n-match 0 'foo' ''\n-match 1 'foo/bar/baz/to' '**/t[o]'\n+match 0 0 0 0 'acrt' 'a[c-c]st'\n+match 1 1 1 1 'acrt' 'a[c-c]rt'\n+match 0 0 0 0 ']' '[!]-]'\n+match 1 1 1 1 'a' '[!]-]'\n+match 0 0 0 0 '' '\\'\n+match 0 0 0 0 '\\' '\\'\n+match 0 0 0 0 'XXX/\\' '*/\\'\n+match 1 1 1 1 'XXX/\\' '*/\\\\'\n+match 1 1 1 1 'foo' 'foo'\n+match 1 1 1 1 '@foo' '@foo'\n+match 0 0 0 0 'foo' '@foo'\n+match 1 1 1 1 '[ab]' '\\[ab]'\n+match 1 1 1 1 '[ab]' '[[]ab]'\n+match 1 1 1 1 '[ab]' '[[:]ab]'\n+match 0 0 0 0 '[ab]' '[[::]ab]'\n+match 1 1 1 1 '[ab]' '[[:digit]ab]'\n+match 1 1 1 1 '[ab]' '[\\[:]ab]'\n+match 1 1 1 1 '?a?b' '\\??\\?b'\n+match 1 1 1 1 'abc' '\\a\\b\\c'\n+match 0 0 0 0 'foo' ''\n+match 1 1 1 1 'foo/bar/baz/to' '**/t[o]'\n \n # Character class tests\n-match 1 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n-match 0 'a' '[[:digit:][:upper:][:space:]]'\n-match 1 'A' '[[:digit:][:upper:][:space:]]'\n-match 1 '1' '[[:digit:][:upper:][:space:]]'\n-match 0 '1' '[[:digit:][:upper:][:spaci:]]'\n-match 1 ' ' '[[:digit:][:upper:][:space:]]'\n-match 0 '.' '[[:digit:][:upper:][:space:]]'\n-match 1 '.' '[[:digit:][:punct:][:space:]]'\n-match 1 '5' '[[:xdigit:]]'\n-match 1 'f' '[[:xdigit:]]'\n-match 1 'D' '[[:xdigit:]]'\n-match 1 '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n-match 1 '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n-match 1 '5' '[a-c[:digit:]x-z]'\n-match 1 'b' '[a-c[:digit:]x-z]'\n-match 1 'y' '[a-c[:digit:]x-z]'\n-match 0 'q' '[a-c[:digit:]x-z]'\n-\n-# Additional tests, including some malformed wildmats\n-match 1 ']' '[\\\\-^]'\n-match 0 '[' '[\\\\-^]'\n-match 1 '-' '[\\-_]'\n-match 1 ']' '[\\]]'\n-match 0 '\\]' '[\\]]'\n-match 0 '\\' '[\\]]'\n-match 0 'ab' 'a[]b'\n-match 0 'a[]b' 'a[]b'\n-match 0 'ab[' 'ab['\n-match 0 'ab' '[!'\n-match 0 'ab' '[-'\n-match 1 '-' '[-]'\n-match 0 '-' '[a-'\n-match 0 '-' '[!a-'\n-match 1 '-' '[--A]'\n-match 1 '5' '[--A]'\n-match 1 ' ' '[ --]'\n-match 1 '$' '[ --]'\n-match 1 '-' '[ --]'\n-match 0 '0' '[ --]'\n-match 1 '-' '[---]'\n-match 1 '-' '[------]'\n-match 0 'j' '[a-e-n]'\n-match 1 '-' '[a-e-n]'\n-match 1 'a' '[!------]'\n-match 0 '[' '[]-a]'\n-match 1 '^' '[]-a]'\n-match 0 '^' '[!]-a]'\n-match 1 '[' '[!]-a]'\n-match 1 '^' '[a^bc]'\n-match 1 '-b]' '[a-]b]'\n-match 0 '\\' '[\\]'\n-match 1 '\\' '[\\\\]'\n-match 0 '\\' '[!\\\\]'\n-match 1 'G' '[A-\\\\]'\n-match 0 'aaabbb' 'b*a'\n-match 0 'aabcaa' '*ba*'\n-match 1 ',' '[,]'\n-match 1 ',' '[\\\\,]'\n-match 1 '\\' '[\\\\,]'\n-match 1 '-' '[,-.]'\n-match 0 '+' '[,-.]'\n-match 0 '-.]' '[,-.]'\n-match 1 '2' '[\\1-\\3]'\n-match 1 '3' '[\\1-\\3]'\n-match 0 '4' '[\\1-\\3]'\n-match 1 '\\' '[[-\\]]'\n-match 1 '[' '[[-\\]]'\n-match 1 ']' '[[-\\]]'\n-match 0 '-' '[[-\\]]'\n+match 1 1 1 1 'a1B' '[[:alpha:]][[:digit:]][[:upper:]]'\n+match 0 1 0 1 'a' '[[:digit:][:upper:][:space:]]'\n+match 1 1 1 1 'A' '[[:digit:][:upper:][:space:]]'\n+match 1 1 1 1 '1' '[[:digit:][:upper:][:space:]]'\n+match 0 0 0 0 '1' '[[:digit:][:upper:][:spaci:]]'\n+match 1 1 1 1 ' ' '[[:digit:][:upper:][:space:]]'\n+match 0 0 0 0 '.' '[[:digit:][:upper:][:space:]]'\n+match 1 1 1 1 '.' '[[:digit:][:punct:][:space:]]'\n+match 1 1 1 1 '5' '[[:xdigit:]]'\n+match 1 1 1 1 'f' '[[:xdigit:]]'\n+match 1 1 1 1 'D' '[[:xdigit:]]'\n+match 1 1 1 1 '_' '[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]'\n+match 1 1 1 1 '.' '[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]'\n+match 1 1 1 1 '5' '[a-c[:digit:]x-z]'\n+match 1 1 1 1 'b' '[a-c[:digit:]x-z]'\n+match 1 1 1 1 'y' '[a-c[:digit:]x-z]'\n+match 0 0 0 0 'q' '[a-c[:digit:]x-z]'\n \n-# Test recursion and the abort code (use \"wildtest -i\" to see iteration counts)\n-match 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n-match 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n-match 1 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n-match 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n-match 0 foo '*/*/*'\n-match 0 foo/bar '*/*/*'\n-match 1 foo/bba/arr '*/*/*'\n-match 0 foo/bb/aa/rr '*/*/*'\n-match 1 foo/bb/aa/rr '**/**/**'\n-match 1 abcXdefXghi '*X*i'\n-match 0 ab/cXd/efXg/hi '*X*i'\n-match 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n-match 1 ab/cXd/efXg/hi '**/*X*/**/*i'\n+# Additional tests, including some malformed wildmatch patterns\n+match 1 1 1 1 ']' '[\\\\-^]'\n+match 0 0 0 0 '[' '[\\\\-^]'\n+match 1 1 1 1 '-' '[\\-_]'\n+match 1 1 1 1 ']' '[\\]]'\n+match 0 0 0 0 '\\]' '[\\]]'\n+match 0 0 0 0 '\\' '[\\]]'\n+match 0 0 0 0 'ab' 'a[]b'\n+match 0 0 0 0 'a[]b' 'a[]b'\n+match 0 0 0 0 'ab[' 'ab['\n+match 0 0 0 0 'ab' '[!'\n+match 0 0 0 0 'ab' '[-'\n+match 1 1 1 1 '-' '[-]'\n+match 0 0 0 0 '-' '[a-'\n+match 0 0 0 0 '-' '[!a-'\n+match 1 1 1 1 '-' '[--A]'\n+match 1 1 1 1 '5' '[--A]'\n+match 1 1 1 1 ' ' '[ --]'\n+match 1 1 1 1 '$' '[ --]'\n+match 1 1 1 1 '-' '[ --]'\n+match 0 0 0 0 '0' '[ --]'\n+match 1 1 1 1 '-' '[---]'\n+match 1 1 1 1 '-' '[------]'\n+match 0 0 0 0 'j' '[a-e-n]'\n+match 1 1 1 1 '-' '[a-e-n]'\n+match 1 1 1 1 'a' '[!------]'\n+match 0 0 0 0 '[' '[]-a]'\n+match 1 1 1 1 '^' '[]-a]'\n+match 0 0 0 0 '^' '[!]-a]'\n+match 1 1 1 1 '[' '[!]-a]'\n+match 1 1 1 1 '^' '[a^bc]'\n+match 1 1 1 1 '-b]' '[a-]b]'\n+match 0 0 0 0 '\\' '[\\]'\n+match 1 1 1 1 '\\' '[\\\\]'\n+match 0 0 0 0 '\\' '[!\\\\]'\n+match 1 1 1 1 'G' '[A-\\\\]'\n+match 0 0 0 0 'aaabbb' 'b*a'\n+match 0 0 0 0 'aabcaa' '*ba*'\n+match 1 1 1 1 ',' '[,]'\n+match 1 1 1 1 ',' '[\\\\,]'\n+match 1 1 1 1 '\\' '[\\\\,]'\n+match 1 1 1 1 '-' '[,-.]'\n+match 0 0 0 0 '+' '[,-.]'\n+match 0 0 0 0 '-.]' '[,-.]'\n+match 1 1 1 1 '2' '[\\1-\\3]'\n+match 1 1 1 1 '3' '[\\1-\\3]'\n+match 0 0 0 0 '4' '[\\1-\\3]'\n+match 1 1 1 1 '\\' '[[-\\]]'\n+match 1 1 1 1 '[' '[[-\\]]'\n+match 1 1 1 1 ']' '[[-\\]]'\n+match 0 0 0 0 '-' '[[-\\]]'\n \n-pathmatch 1 foo foo\n-pathmatch 0 foo fo\n-pathmatch 1 foo/bar foo/bar\n-pathmatch 1 foo/bar 'foo/*'\n-pathmatch 1 foo/bba/arr 'foo/*'\n-pathmatch 1 foo/bba/arr 'foo/**'\n-pathmatch 1 foo/bba/arr 'foo*'\n-pathmatch 1 foo/bba/arr 'foo**'\n-pathmatch 1 foo/bba/arr 'foo/*arr'\n-pathmatch 1 foo/bba/arr 'foo/**arr'\n-pathmatch 0 foo/bba/arr 'foo/*z'\n-pathmatch 0 foo/bba/arr 'foo/**z'\n-pathmatch 1 foo/bar 'foo?bar'\n-pathmatch 1 foo/bar 'foo[/]bar'\n-pathmatch 1 foo/bar 'foo[^a-z]bar'\n-pathmatch 0 foo '*/*/*'\n-pathmatch 0 foo/bar '*/*/*'\n-pathmatch 1 foo/bba/arr '*/*/*'\n-pathmatch 1 foo/bb/aa/rr '*/*/*'\n-pathmatch 1 abcXdefXghi '*X*i'\n-pathmatch 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n-pathmatch 1 ab/cXd/efXg/hi '*Xg*i'\n+# Test recursion\n+match 1 1 1 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+match 0 0 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+match 0 0 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'\n+match 1 1 1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+match 0 0 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'\n+match 1 1 1 1 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'\n+match 0 0 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'\n+match 0 0 0 0 foo '*/*/*'\n+match 0 0 0 0 foo/bar '*/*/*'\n+match 1 1 1 1 foo/bba/arr '*/*/*'\n+match 0 0 1 1 foo/bb/aa/rr '*/*/*'\n+match 1 1 1 1 foo/bb/aa/rr '**/**/**'\n+match 1 1 1 1 abcXdefXghi '*X*i'\n+match 0 0 1 1 ab/cXd/efXg/hi '*X*i'\n+match 1 1 1 1 ab/cXd/efXg/hi '*/*X*/*/*i'\n+match 1 1 1 1 ab/cXd/efXg/hi '**/*X*/**/*i'\n \n-# Case-sensitivity features\n-match 0 'a' '[A-Z]'\n-match 1 'A' '[A-Z]'\n-match 0 'A' '[a-z]'\n-match 1 'a' '[a-z]'\n-match 0 'a' '[[:upper:]]'\n-match 1 'A' '[[:upper:]]'\n-match 0 'A' '[[:lower:]]'\n-match 1 'a' '[[:lower:]]'\n-match 0 'A' '[B-Za]'\n-match 1 'a' '[B-Za]'\n-match 0 'A' '[B-a]'\n-match 1 'a' '[B-a]'\n-match 0 'z' '[Z-y]'\n-match 1 'Z' '[Z-y]'\n+# Extra pathmatch tests\n+match 0 0 0 0 foo fo\n+match 1 1 1 1 foo/bar foo/bar\n+match 1 1 1 1 foo/bar 'foo/*'\n+match 0 0 1 1 foo/bba/arr 'foo/*'\n+match 1 1 1 1 foo/bba/arr 'foo/**'\n+match 0 0 1 1 foo/bba/arr 'foo*'\n+match 0 0 1 1 foo/bba/arr 'foo**'\n+match 0 0 1 1 foo/bba/arr 'foo/*arr'\n+match 0 0 1 1 foo/bba/arr 'foo/**arr'\n+match 0 0 0 0 foo/bba/arr 'foo/*z'\n+match 0 0 0 0 foo/bba/arr 'foo/**z'\n+match 0 0 1 1 foo/bar 'foo?bar'\n+match 0 0 1 1 foo/bar 'foo[/]bar'\n+match 0 0 1 1 foo/bar 'foo[^a-z]bar'\n+match 0 0 1 1 ab/cXd/efXg/hi '*Xg*i'\n \n-imatch 1 'a' '[A-Z]'\n-imatch 1 'A' '[A-Z]'\n-imatch 1 'A' '[a-z]'\n-imatch 1 'a' '[a-z]'\n-imatch 1 'a' '[[:upper:]]'\n-imatch 1 'A' '[[:upper:]]'\n-imatch 1 'A' '[[:lower:]]'\n-imatch 1 'a' '[[:lower:]]'\n-imatch 1 'A' '[B-Za]'\n-imatch 1 'a' '[B-Za]'\n-imatch 1 'A' '[B-a]'\n-imatch 1 'a' '[B-a]'\n-imatch 1 'z' '[Z-y]'\n-imatch 1 'Z' '[Z-y]'\n+# Extra case-sensitivity tests\n+match 0 1 0 1 'a' '[A-Z]'\n+match 1 1 1 1 'A' '[A-Z]'\n+match 0 1 0 1 'A' '[a-z]'\n+match 1 1 1 1 'a' '[a-z]'\n+match 0 1 0 1 'a' '[[:upper:]]'\n+match 1 1 1 1 'A' '[[:upper:]]'\n+match 0 1 0 1 'A' '[[:lower:]]'\n+match 1 1 1 1 'a' '[[:lower:]]'\n+match 0 1 0 1 'A' '[B-Za]'\n+match 1 1 1 1 'a' '[B-Za]'\n+match 0 1 0 1 'A' '[B-a]'\n+match 1 1 1 1 'a' '[B-a]'\n+match 0 1 0 1 'z' '[Z-y]'\n+match 1 1 1 1 'Z' '[Z-y]'\n \n test_done\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"337824","messageId":"20180130212124.2099-10-avarab@gmail.com","threadId":"47493","inReplyTo":"20180130212124.2099-1-avarab@gmail.com","subject":"[PATCH v5 09/10] test-lib: add an EXPENSIVE_ON_WINDOWS prerequisite","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-30T21:21:23Z","receivedAt":"2018-01-30T21:22:17Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add an EXPENSIVE_ON_WINDOWS prerequisite to mark those tests which are\nvery expensive to run on Windows, but cheap elsewhere.\n\nCertain tests that heavily stress the filesystem or run a lot of shell\ncommands are disproportionately expensive on Windows, this\nprerequisite will later be used by a tests that runs in 4-8 seconds on\na modern Linux system, but takes almost 10 minutes on Windows.\n\nThere's no reason to skip such tests by default on other platforms,\nbut Windows users shouldn't need to wait around while they finish.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/test-lib.sh | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 9a0a21f49a..a2703c7d36 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1132,6 +1132,10 @@ test_lazy_prereq EXPENSIVE '\n \ttest -n \"$GIT_TEST_LONG\"\n '\n \n+test_lazy_prereq EXPENSIVE_ON_WINDOWS '\n+\ttest_have_prereq EXPENSIVE || test_have_prereq !MINGW,!CYGWIN\n+'\n+\n test_lazy_prereq USR_BIN_TIME '\n \ttest -x /usr/bin/time\n '\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"337825","messageId":"20180130212124.2099-11-avarab@gmail.com","threadId":"47493","inReplyTo":"20180130212124.2099-1-avarab@gmail.com","subject":"[PATCH v5 10/10] wildmatch test: mark test as EXPENSIVE_ON_WINDOWS","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-30T21:21:24Z","receivedAt":"2018-01-30T21:22:20Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Mark the newly added test which creates test files on-disk as\nEXPENSIVE_ON_WINDOWS. According to [1] it takes almost ten minutes to\nrun this test file on Windows after this recent change, but just a few\nseconds on Linux as noted in my [2].\n\nThis could be done faster by exiting earlier, however by using this\npattern we'll emit \"skip\" lines for each skipped test, making it clear\nwe're not running a lot of them in the TAP output, at the cost of some\noverhead.\n\n1. nycvar.QRO.7.76.6.1801061337020.1337@wbunaarf-fpuvaqryva.tvgsbejvaqbjf.bet\n   (https://public-inbox.org/git/nycvar.QRO.7.76.6.1801061337020.1337@wbunaarf-fpuvaqryva.tvgsbejvaqbjf.bet/)\n\n2. 87mv1raz9p.fsf@evledraar.gmail.com\n   (https://public-inbox.org/git/87mv1raz9p.fsf@evledraar.gmail.com/)\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex bd11e5acb0..c1fc6ca730 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -109,36 +109,36 @@ match_with_ls_files() {\n \tthen\n \t\tif test -e .git/created_test_file\n \t\tthen\n-\t\t\ttest_expect_success \"$match_function (via ls-files): match dies on '$pattern' '$text'\" \"\n+\t\t\ttest_expect_success EXPENSIVE_ON_WINDOWS \"$match_function (via ls-files): match dies on '$pattern' '$text'\" \"\n \t\t\t\tprintf '%s' '$text' >expect &&\n \t\t\t\ttest_must_fail git$ls_files_args ls-files -z -- '$pattern'\n \t\t\t\"\n \t\telse\n-\t\t\ttest_expect_failure \"$match_function (via ls-files): match skip '$pattern' '$text'\" 'false'\n+\t\t\ttest_expect_failure EXPENSIVE_ON_WINDOWS \"$match_function (via ls-files): match skip '$pattern' '$text'\" 'false'\n \t\tfi\n \telif test \"$match_expect\" = 1\n \tthen\n \t\tif test -e .git/created_test_file\n \t\tthen\n-\t\t\ttest_expect_success \"$match_function (via ls-files): match '$pattern' '$text'\" \"\n+\t\t\ttest_expect_success EXPENSIVE_ON_WINDOWS \"$match_function (via ls-files): match '$pattern' '$text'\" \"\n \t\t\t\tprintf '%s' '$text' >expect &&\n \t\t\t\tgit$ls_files_args ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n \t\t\t\t$match_stdout_stderr_cmp\n \t\t\t\"\n \t\telse\n-\t\t\ttest_expect_failure \"$match_function (via ls-files): match skip '$pattern' '$text'\" 'false'\n+\t\t\ttest_expect_failure EXPENSIVE_ON_WINDOWS \"$match_function (via ls-files): match skip '$pattern' '$text'\" 'false'\n \t\tfi\n \telif test \"$match_expect\" = 0\n \tthen\n \t\tif test -e .git/created_test_file\n \t\tthen\n-\t\t\ttest_expect_success \"$match_function (via ls-files): no match '$pattern' '$text'\" \"\n+\t\t\ttest_expect_success EXPENSIVE_ON_WINDOWS \"$match_function (via ls-files): no match '$pattern' '$text'\" \"\n \t\t\t\t>expect &&\n \t\t\t\tgit$ls_files_args ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n \t\t\t\t$match_stdout_stderr_cmp\n \t\t\t\"\n \t\telse\n-\t\t\ttest_expect_failure \"$match_function (via ls-files): no match skip '$pattern' '$text'\" 'false'\n+\t\t\ttest_expect_failure EXPENSIVE_ON_WINDOWS \"$match_function (via ls-files): no match skip '$pattern' '$text'\" 'false'\n \t\tfi\n \telse\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_expect\" 'false'\n@@ -174,7 +174,7 @@ match() {\n \t\tpattern=${10}\n \tfi\n \n-\ttest_expect_success 'cleanup after previous file test' '\n+\ttest_expect_success EXPENSIVE_ON_WINDOWS 'cleanup after previous file test' '\n \t\tif test -e .git/created_test_file\n \t\tthen\n \t\t\tgit reset &&\n@@ -184,7 +184,7 @@ match() {\n \n \tprintf '%s' \"$text\" >.git/expected_test_file\n \n-\ttest_expect_success \"setup match file test for $text\" '\n+\ttest_expect_success EXPENSIVE_ON_WINDOWS \"setup match file test for $text\" '\n \t\tfile=$(cat .git/expected_test_file) &&\n \t\tif should_create_test_file \"$file\"\n \t\tthen\n-- \n2.15.1.424.g9478a66081\n\n"},{"id":"337826","messageId":"20180130212124.2099-9-avarab@gmail.com","threadId":"47493","inReplyTo":"20180130212124.2099-1-avarab@gmail.com","subject":"[PATCH v5 08/10] wildmatch test: create & test files on disk in addition to in-memory","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-01-30T21:21:22Z","receivedAt":"2018-01-30T21:22:46Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"There has never been any full roundtrip testing of what git-ls-files\nand other commands that use wildmatch() actually do, rather we've been\nsatisfied with just testing the underlying C function.\n\nDue to git-ls-files and friends having their own codepaths before they\ncall wildmatch() there's sometimes differences in the behavior between\nthe two. Even when we test for those (as with [1]), there was no one\nplace where you can review how these two modes differ.\n\nNow there is. We now attempt to create a file called $haystack and\nmatch $needle against it for each pair of $needle and $haystack that\nwe were passing to test-wildmatch.\n\nIf we can't create the file we skip the test. This ensures that we can\nrun this on all platforms and not maintain some infinitely growing\nwhitelist of e.g. platforms that don't support certain characters in\nfilenames.\n\nA notable exception to this is Windows, where due to the reasons\nexplained in [2] the shellscript emulation layer might fake the\ncreation of a file such as \"*\", and \"test -e\" for it will succeed\nsince it just got created with some character that maps to \"*\", but\ngit ls-files won't be fooled by this.\n\nThus we need to skip creating certain filenames entirely on Windows,\nthe list here might be overly aggressive. I don't have access to a\nWindows system to test this.\n\nAs a result of doing these tests we can now see the cases where these\ntwo ways of testing wildmatch differ:\n\n * Creating a file called 'a[]b' and running ls-files 'a[]b' will show\n   that file, but wildmatch(\"a[]b\", \"a[]b\") will not match\n\n * wildmatch() won't match a file called \\ against \\, but ls-files\n   will.\n\n * `git --glob-pathspecs ls-files 'foo**'` will match a file\n   'foo/bba/arr', but wildmatch won't, however pathmatch will.\n\n   This seems like a bug to me, the two are otherwise equivalent as\n   these tests show.\n\nThis also reveals the case discussed in [1], since 2.16.0 '' is now an\nerror as far as ls-files is concerned, but wildmatch() itself happily\naccepts it.\n\n1. 9e4e8a64c2 (\"pathspec: die on empty strings as pathspec\",\n   2017-06-06)\n\n2. nycvar.QRO.7.76.6.1801052133380.1337@wbunaarf-fpuvaqryva.tvgsbejvaqbjf.bet\n   (https://public-inbox.org/git/?q=nycvar.QRO.7.76.6.1801052133380.1337%40wbunaarf-fpuvaqryva.tvgsbejvaqbjf.bet)\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t3070-wildmatch.sh | 201 ++++++++++++++++++++++++++++++++++++++++++++++++---\n 1 file changed, 190 insertions(+), 11 deletions(-)\n\ndiff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh\nindex 3e75cb0cbe..bd11e5acb0 100755\n--- a/t/t3070-wildmatch.sh\n+++ b/t/t3070-wildmatch.sh\n@@ -4,6 +4,72 @@ test_description='wildmatch tests'\n \n . ./test-lib.sh\n \n+should_create_test_file() {\n+\tfile=$1\n+\n+\tcase $file in\n+\t# `touch .` will succeed but obviously not do what we intend\n+\t# here.\n+\t\".\")\n+\t\treturn 1\n+\t\t;;\n+\t# We cannot create a file with an empty filename.\n+\t\"\")\n+\t\treturn 1\n+\t\t;;\n+\t# The tests that are testing that e.g. foo//bar is matched by\n+\t# foo/*/bar can't be tested on filesystems since there's no\n+\t# way we're getting a double slash.\n+\t*//*)\n+\t\treturn 1\n+\t\t;;\n+\t# When testing the difference between foo/bar and foo/bar/ we\n+\t# can't test the latter.\n+\t*/)\n+\t\treturn 1\n+\t\t;;\n+\t# On Windows, \\ in paths is silently converted to /, which\n+\t# would result in the \"touch\" below working, but the test\n+\t# itself failing. See 6fd1106aa4 (\"t3700: Skip a test with\n+\t# backslashes in pathspec\", 2009-03-13) for prior art and\n+\t# details.\n+\t*\\\\*)\n+\t\tif ! test_have_prereq BSLASHPSPEC\n+\t\tthen\n+\t\t\treturn 1\n+\t\tfi\n+\t\t# NOTE: The ;;& bash extension is not portable, so\n+\t\t# this test needs to be at the end of the pattern\n+\t\t# list.\n+\t\t#\n+\t\t# If we want to add more conditional returns we either\n+\t\t# need a new case statement, or turn this whole thing\n+\t\t# into a series of \"if\" tests.\n+\t\t;;\n+\tesac\n+\n+\n+\t# On Windows proper (i.e. not Cygwin) many file names which\n+\t# under Cygwin would be emulated don't work.\n+\tif test_have_prereq MINGW\n+\tthen\n+\t\tcase $file in\n+\t\t\" \")\n+\t\t\t# Files called \" \" are forbidden on Windows\n+\t\t\treturn 1\n+\t\t\t;;\n+\t\t*\\<*|*\\>*|*:*|*\\\"*|*\\|*|*\\?*|*\\**)\n+\t\t\t# Files with various special characters aren't\n+\t\t\t# allowed on Windows. Sourced from\n+\t\t\t# https://stackoverflow.com/a/31976060\n+\t\t\treturn 1\n+\t\t\t;;\n+\t\tesac\n+\tfi\n+\n+\treturn 0\n+}\n+\n match_with_function() {\n \ttext=$1\n \tpattern=$2\n@@ -26,25 +92,133 @@ match_with_function() {\n \n }\n \n+match_with_ls_files() {\n+\ttext=$1\n+\tpattern=$2\n+\tmatch_expect=$3\n+\tmatch_function=$4\n+\tls_files_args=$5\n+\n+\tmatch_stdout_stderr_cmp=\"\n+\t\ttr -d '\\0' <actual.raw >actual &&\n+\t\t>expect.err &&\n+\t\ttest_cmp expect.err actual.err &&\n+\t\ttest_cmp expect actual\"\n+\n+\tif test \"$match_expect\" = 'E'\n+\tthen\n+\t\tif test -e .git/created_test_file\n+\t\tthen\n+\t\t\ttest_expect_success \"$match_function (via ls-files): match dies on '$pattern' '$text'\" \"\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\ttest_must_fail git$ls_files_args ls-files -z -- '$pattern'\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"$match_function (via ls-files): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_expect\" = 1\n+\tthen\n+\t\tif test -e .git/created_test_file\n+\t\tthen\n+\t\t\ttest_expect_success \"$match_function (via ls-files): match '$pattern' '$text'\" \"\n+\t\t\t\tprintf '%s' '$text' >expect &&\n+\t\t\t\tgit$ls_files_args ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\t$match_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"$match_function (via ls-files): match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telif test \"$match_expect\" = 0\n+\tthen\n+\t\tif test -e .git/created_test_file\n+\t\tthen\n+\t\t\ttest_expect_success \"$match_function (via ls-files): no match '$pattern' '$text'\" \"\n+\t\t\t\t>expect &&\n+\t\t\t\tgit$ls_files_args ls-files -z -- '$pattern' >actual.raw 2>actual.err &&\n+\t\t\t\t$match_stdout_stderr_cmp\n+\t\t\t\"\n+\t\telse\n+\t\t\ttest_expect_failure \"$match_function (via ls-files): no match skip '$pattern' '$text'\" 'false'\n+\t\tfi\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $match_expect\" 'false'\n+\tfi\n+}\n+\n match() {\n-\tmatch_glob=$1\n-\tmatch_iglob=$2\n-\tmatch_pathmatch=$3\n-\tmatch_pathmatchi=$4\n-\ttext=$5\n-\tpattern=$6\n+\tif test \"$#\" = 6\n+\tthen\n+\t\t# When test-wildmatch and git ls-files produce the same\n+\t\t# result.\n+\t\tmatch_glob=$1\n+\t\tmatch_file_glob=$match_glob\n+\t\tmatch_iglob=$2\n+\t\tmatch_file_iglob=$match_iglob\n+\t\tmatch_pathmatch=$3\n+\t\tmatch_file_pathmatch=$match_pathmatch\n+\t\tmatch_pathmatchi=$4\n+\t\tmatch_file_pathmatchi=$match_pathmatchi\n+\t\ttext=$5\n+\t\tpattern=$6\n+\telif test \"$#\" = 10\n+\tthen\n+\t\tmatch_glob=$1\n+\t\tmatch_iglob=$2\n+\t\tmatch_pathmatch=$3\n+\t\tmatch_pathmatchi=$4\n+\t\tmatch_file_glob=$5\n+\t\tmatch_file_iglob=$6\n+\t\tmatch_file_pathmatch=$7\n+\t\tmatch_file_pathmatchi=$8\n+\t\ttext=$9\n+\t\tpattern=${10}\n+\tfi\n+\n+\ttest_expect_success 'cleanup after previous file test' '\n+\t\tif test -e .git/created_test_file\n+\t\tthen\n+\t\t\tgit reset &&\n+\t\t\tgit clean -df\n+\t\tfi\n+\t'\n+\n+\tprintf '%s' \"$text\" >.git/expected_test_file\n+\n+\ttest_expect_success \"setup match file test for $text\" '\n+\t\tfile=$(cat .git/expected_test_file) &&\n+\t\tif should_create_test_file \"$file\"\n+\t\tthen\n+\t\t\tdirs=${file%/*}\n+\t\t\tif test \"$file\" != \"$dirs\"\n+\t\t\tthen\n+\t\t\t\tmkdir -p -- \"$dirs\" &&\n+\t\t\t\ttouch -- \"./$text\"\n+\t\t\telse\n+\t\t\t\ttouch -- \"./$file\"\n+\t\t\tfi &&\n+\t\t\tgit add -A &&\n+\t\t\tprintf \"%s\" \"$file\" >.git/created_test_file\n+\t\telif test -e .git/created_test_file\n+\t\tthen\n+\t\t\trm .git/created_test_file\n+\t\tfi\n+\t'\n \n \t# $1: Case sensitive glob match: test-wildmatch & ls-files\n \tmatch_with_function \"$text\" \"$pattern\" $match_glob \"wildmatch\"\n+\tmatch_with_ls_files \"$text\" \"$pattern\" $match_file_glob \"wildmatch\" \" --glob-pathspecs\"\n \n \t# $2: Case insensitive glob match: test-wildmatch & ls-files\n \tmatch_with_function \"$text\" \"$pattern\" $match_iglob \"iwildmatch\"\n+\tmatch_with_ls_files \"$text\" \"$pattern\" $match_file_iglob \"iwildmatch\" \" --glob-pathspecs --icase-pathspecs\"\n \n \t# $3: Case sensitive path match: test-wildmatch & ls-files\n \tmatch_with_function \"$text\" \"$pattern\" $match_pathmatch \"pathmatch\"\n+\tmatch_with_ls_files \"$text\" \"$pattern\" $match_file_pathmatch \"pathmatch\" \"\"\n \n \t# $4: Case insensitive path match: test-wildmatch & ls-files\n \tmatch_with_function \"$text\" \"$pattern\" $match_pathmatchi \"ipathmatch\"\n+\tmatch_with_ls_files \"$text\" \"$pattern\" $match_file_pathmatchi \"ipathmatch\" \" --icase-pathspecs\"\n }\n \n # Basic wildmatch features\n@@ -113,7 +287,8 @@ match 1 1 1 1 'acrt' 'a[c-c]rt'\n match 0 0 0 0 ']' '[!]-]'\n match 1 1 1 1 'a' '[!]-]'\n match 0 0 0 0 '' '\\'\n-match 0 0 0 0 '\\' '\\'\n+match 0 0 0 0 \\\n+      1 1 1 1 '\\' '\\'\n match 0 0 0 0 'XXX/\\' '*/\\'\n match 1 1 1 1 'XXX/\\' '*/\\\\'\n match 1 1 1 1 'foo' 'foo'\n@@ -127,7 +302,8 @@ match 1 1 1 1 '[ab]' '[[:digit]ab]'\n match 1 1 1 1 '[ab]' '[\\[:]ab]'\n match 1 1 1 1 '?a?b' '\\??\\?b'\n match 1 1 1 1 'abc' '\\a\\b\\c'\n-match 0 0 0 0 'foo' ''\n+match 0 0 0 0 \\\n+      E E E E 'foo' ''\n match 1 1 1 1 'foo/bar/baz/to' '**/t[o]'\n \n # Character class tests\n@@ -157,8 +333,10 @@ match 1 1 1 1 ']' '[\\]]'\n match 0 0 0 0 '\\]' '[\\]]'\n match 0 0 0 0 '\\' '[\\]]'\n match 0 0 0 0 'ab' 'a[]b'\n-match 0 0 0 0 'a[]b' 'a[]b'\n-match 0 0 0 0 'ab[' 'ab['\n+match 0 0 0 0 \\\n+      1 1 1 1 'a[]b' 'a[]b'\n+match 0 0 0 0 \\\n+      1 1 1 1 'ab[' 'ab['\n match 0 0 0 0 'ab' '[!'\n match 0 0 0 0 'ab' '[-'\n match 1 1 1 1 '-' '[-]'\n@@ -226,7 +404,8 @@ match 1 1 1 1 foo/bar 'foo/*'\n match 0 0 1 1 foo/bba/arr 'foo/*'\n match 1 1 1 1 foo/bba/arr 'foo/**'\n match 0 0 1 1 foo/bba/arr 'foo*'\n-match 0 0 1 1 foo/bba/arr 'foo**'\n+match 0 0 1 1 \\\n+      1 1 1 1 foo/bba/arr 'foo**'\n match 0 0 1 1 foo/bba/arr 'foo/*arr'\n match 0 0 1 1 foo/bba/arr 'foo/**arr'\n match 0 0 0 0 foo/bba/arr 'foo/*z'\n-- \n2.15.1.424.g9478a66081\n\n"}]}