{"thread":{"id":"11348","subject":"[PATCH] Fix tests for broken sed on Leopard","startedAt":"2007-12-18T19:45:58Z","lastAt":"2007-12-18T19:45:58Z","messageCount":1,"participants":["Wincent Colaiuta"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"63657","messageId":"1198007158-27576-1-git-send-email-win@wincent.com","threadId":"11348","inReplyTo":"7vzlw7zwj8.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] Fix tests for broken sed on Leopard","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-12-18T19:45:58Z","receivedAt":"2007-12-18T19:45:58Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 18/12/2007, a las 19:29, Junio C Hamano escribiÃ³:\n\n> Could you work it around not by changing what is tested, but by changing\n> the way the result (actual and expect) are compared, please?  I actually\n> wanted to enhance this to test with values 1023, 2047, and 4095, and\n> your change will close the door for such changes.\n\nHow about the following? This swaps in perl in place of sed, which we can\nhopefully rely upon to work across platforms.\n\nCheers,\nWincent\n\n-------- 8< --------\nFix tests for broken sed on Leopard\n\nThe newly-added common-tail-optimization test fails on Leopard because\nthe broken sed implementation bails with a spurious \"unterminated\nsubstitute pattern\" error because of the length of one of the\narguments.\n\nSo use perl instead of sed, and at the same time add test cases for\n1024 - 1 and 4096 - 1 as suggested by Junio.\n\nSigned-off-by: Wincent Colaiuta <win@wincent.com>\n---\n t/t4024-diff-optimize-common.sh |  104 ++++++++++++++++++++++++++++++---------\n 1 files changed, 80 insertions(+), 24 deletions(-)\n\ndiff --git a/t/t4024-diff-optimize-common.sh b/t/t4024-diff-optimize-common.sh\nindex 20fe87b..84dfb05 100755\n--- a/t/t4024-diff-optimize-common.sh\n+++ b/t/t4024-diff-optimize-common.sh\n@@ -7,28 +7,12 @@ test_description='common tail optimization'\n z=zzzzzzzz ;# 8\n z=\"$z$z$z$z$z$z$z$z\" ;# 64\n z=\"$z$z$z$z$z$z$z$z\" ;# 512\n-z=\"$z$z$z$z\" ;# 2048\n-z2047=$(expr \"$z\" : '.\\(.*\\)') ; #2047\n-\n-test_expect_success setup '\n-\n-\techo \"a$z2047\" >file-a &&\n-\techo \"b\" >file-b &&\n-\techo \"$z2047\" >>file-b &&\n-\techo \"c$z2047\" | tr -d \"\\012\" >file-c &&\n-\techo \"d\" >file-d &&\n-\techo \"$z2047\" | tr -d \"\\012\" >>file-d &&\n-\n-\tgit add file-a file-b file-c file-d &&\n-\n-\techo \"A$z2047\" >file-a &&\n-\techo \"B\" >file-b &&\n-\techo \"$z2047\" >>file-b &&\n-\techo \"C$z2047\" | tr -d \"\\012\" >file-c &&\n-\techo \"D\" >file-d &&\n-\techo \"$z2047\" | tr -d \"\\012\" >>file-d\n-\n-'\n+z1024=\"$z$z\"\n+z1023=$(expr \"$z1024\" : '.\\(.*\\)')\n+z2048=\"$z1024$z1024\"\n+z2047=$(expr \"$z2048\" : '.\\(.*\\)')\n+z4096=\"$z2048$z2048\"\n+z4095=$(expr \"$z4096\" : '.\\(.*\\)')\n \n cat >expect <<\\EOF\n diff --git a/file-a b/file-a\n@@ -59,11 +43,83 @@ diff --git a/file-d b/file-d\n +D\n EOF\n \n-test_expect_success 'diff -U0' '\n+test_expect_success 'setup (1023-char sequence)' '\n+\n+\techo \"a$z1023\" >file-a &&\n+\techo \"b\" >file-b &&\n+\techo \"$z1023\" >>file-b &&\n+\techo \"c$z1023\" | tr -d \"\\012\" >file-c &&\n+\techo \"d\" >file-d &&\n+\techo \"$z1023\" | tr -d \"\\012\" >>file-d &&\n+\n+\tgit add file-a file-b file-c file-d &&\n+\n+\techo \"A$z1023\" >file-a &&\n+\techo \"B\" >file-b &&\n+\techo \"$z1023\" >>file-b &&\n+\techo \"C$z1023\" | tr -d \"\\012\" >file-c &&\n+\techo \"D\" >file-d &&\n+\techo \"$z1023\" | tr -d \"\\012\" >>file-d\n+\n+'\n+\n+test_expect_success 'diff -U0 (1023-char sequence)' '\n+\tgit diff -U0 | perl -pe \"s/^index.+\\n//g; s/$z1023/Z/g\" >actual &&\n+\tdiff -u expect actual\n+\n+'\n+\n+test_expect_success 'setup (2047-char sequence)' '\n \n-\tgit diff -U0 | sed -e \"/^index/d\" -e \"s/$z2047/Z/g\" >actual &&\n+\techo \"a$z2047\" >file-a &&\n+\techo \"b\" >file-b &&\n+\techo \"$z2047\" >>file-b &&\n+\techo \"c$z2047\" | tr -d \"\\012\" >file-c &&\n+\techo \"d\" >file-d &&\n+\techo \"$z2047\" | tr -d \"\\012\" >>file-d &&\n+\n+\tgit add file-a file-b file-c file-d &&\n+\n+\techo \"A$z2047\" >file-a &&\n+\techo \"B\" >file-b &&\n+\techo \"$z2047\" >>file-b &&\n+\techo \"C$z2047\" | tr -d \"\\012\" >file-c &&\n+\techo \"D\" >file-d &&\n+\techo \"$z2047\" | tr -d \"\\012\" >>file-d\n+\n+'\n+\n+test_expect_success 'diff -U0 (2047-char sequence)' '\n+\n+\tgit diff -U0 | perl -pe \"s/^index.+\\n//g; s/$z2047/Z/g\" >actual &&\n \tdiff -u expect actual\n \n '\n \n+test_expect_success 'setup (4095-char sequence)' '\n+\n+\techo \"a$z4095\" >file-a &&\n+\techo \"b\" >file-b &&\n+\techo \"$z4095\" >>file-b &&\n+\techo \"c$z4095\" | tr -d \"\\012\" >file-c &&\n+\techo \"d\" >file-d &&\n+\techo \"$z4095\" | tr -d \"\\012\" >>file-d &&\n+\n+\tgit add file-a file-b file-c file-d &&\n+\n+\techo \"A$z4095\" >file-a &&\n+\techo \"B\" >file-b &&\n+\techo \"$z4095\" >>file-b &&\n+\techo \"C$z4095\" | tr -d \"\\012\" >file-c &&\n+\techo \"D\" >file-d &&\n+\techo \"$z4095\" | tr -d \"\\012\" >>file-d\n+\n+'\n+\n+test_expect_success 'diff -U0 (4095-char sequence)' '\n+\n+\tgit diff -U0 | perl -pe \"s/^index.+\\n//g; s/$z4095/Z/g\" >actual &&\n+\tdiff -u expect actual\n+\n+'\n test_done\n-- \n1.5.4.rc0.68.g15eb8-dirty\n"}]}