{"thread":{"id":"15222","subject":"[PATCH] t9700-perl-git.sh: Fix a test failure on cygwin","startedAt":"2008-08-27T18:09:15Z","lastAt":"2008-08-29T20:56:55Z","messageCount":3,"participants":["Ramsay Jones","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"88744","messageId":"48B5984B.4020901@ramsay1.demon.co.uk","threadId":"15222","inReplyTo":null,"subject":"[PATCH] t9700-perl-git.sh: Fix a test failure on cygwin","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2008-08-27T18:09:15Z","receivedAt":"2008-08-27T18:09:15Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n\nThis patch fixes the t9700 test failure on cygwin. Don't ask me to\nexplain why the original test.pl fails on cygwin, but passes on Linux!\n\nMy perl version:\n\n    $ perl --version\n\n    This is perl, v5.8.7 built for cygwin-thread-multi-64int\n    (with 1 registered patch, see perl -V for more detail)\n\n    Copyright 1987-2005, Larry Wall\n\n    Perl may be copied only under the terms of either the Artistic License or the\n    GNU General Public License, which may be found in the Perl 5 source kit.\n\n    Complete documentation for Perl, including FAQ lists, should be found on\n    this system using `man perl' or `perldoc perl'.  If you have access to the\n    Internet, point your browser at http://www.perl.org/, the Perl Home Page.\n    $ \n\n[My perl version on Linux is whatever comes with Ubuntu 7.04]\n\nATB,\n\nRamsay Jones\n\n t/t9700/test.pl |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t9700/test.pl b/t/t9700/test.pl\nindex 4d23125..6d59356 100755\n--- a/t/t9700/test.pl\n+++ b/t/t9700/test.pl\n@@ -15,9 +15,9 @@ BEGIN { use_ok('Git') }\n \n # set up\n our $repo_dir = \"trash directory\";\n-our $abs_repo_dir = Cwd->cwd;\n+our $abs_repo_dir = cwd();\n die \"this must be run by calling the t/t97* shell script(s)\\n\"\n-    if basename(Cwd->cwd) ne $repo_dir;\n+    if basename($abs_repo_dir) ne $repo_dir;\n ok(our $r = Git->repository(Directory => \".\"), \"open repository\");\n \n # config\n-- \n1.6.0\n"},{"id":"88761","messageId":"7vd4jup800.fsf@gitster.siamese.dyndns.org","threadId":"15222","inReplyTo":"48B5984B.4020901@ramsay1.demon.co.uk","subject":"Re: [PATCH] t9700-perl-git.sh: Fix a test failure on cygwin","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-08-27T19:34:23Z","receivedAt":"2008-08-27T19:34:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:\n\n> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n> ---\n>\n> This patch fixes the t9700 test failure on cygwin. Don't ask me to\n> explain why the original test.pl fails on cygwin, but passes on Linux!\n>\n> My perl version:\n>\n>     $ perl --version\n>\n>     This is perl, v5.8.7 built for cygwin-thread-multi-64int\n>     (with 1 registered patch, see perl -V for more detail)\n>\n>     Copyright 1987-2005, Larry Wall\n>\n>     Perl may be copied only under the terms of either the Artistic License or the\n>     GNU General Public License, which may be found in the Perl 5 source kit.\n>\n>     Complete documentation for Perl, including FAQ lists, should be found on\n>     this system using `man perl' or `perldoc perl'.  If you have access to the\n>     Internet, point your browser at http://www.perl.org/, the Perl Home Page.\n>     $ \n>\n> [My perl version on Linux is whatever comes with Ubuntu 7.04]\n\nCurious.\n\nWhat does this give you:\n\n\t$ cd t\n        $ sh t9700-perl-git.sh -v\n\nwith the attached patch?  Unfortunately this cannot be run with \"-i -v\"\nbecause 'test_external_without_stderr' uses test_external which in turn\nexits upon failure when -i is given, without letting the former to report\nwhat was given to the standard error stream (this is slightly offtopic but\npertains to debuggability of tests, so Lea is Cc'ed).\n\nFor me, cwd() is the same as Cwd->cwd (this is from Perl 5.8.8); perhaps\nit behaves differently on Cygwin?\n\n t/t9700/test.pl |    6 ++++++\n 1 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git i/t/t9700/test.pl w/t/t9700/test.pl\nindex 851cea4..139711d 100755\n--- i/t/t9700/test.pl\n+++ w/t/t9700/test.pl\n@@ -15,6 +15,12 @@ BEGIN { use_ok('Git') }\n \n # set up\n our $abs_repo_dir = Cwd->cwd;\n+our $cwd = cwd();\n+print STDERR \"Cwd->cwd says '$abs_repo_dir'\\n\";\n+print STDERR \"cwd() says '$cwd'\\n\";\n+\n+exit(1);\n+\n ok(our $r = Git->repository(Directory => \".\"), \"open repository\");\n \n # config\n"},{"id":"89160","messageId":"48B86297.7080204@ramsay1.demon.co.uk","threadId":"15222","inReplyTo":"7vd4jup800.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] t9700-perl-git.sh: Fix a test failure on cygwin","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2008-08-29T20:56:55Z","receivedAt":"2008-08-29T20:56:55Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Junio C Hamano wrote:\n> Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:\n>> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n>> ---\n>>\n>> This patch fixes the t9700 test failure on cygwin. Don't ask me to\n>> explain why the original test.pl fails on cygwin, but passes on Linux!\n>>\n> Curious.\n> \n> What does this give you:\n> \n> \t$ cd t\n>         $ sh t9700-perl-git.sh -v\n> \n> with the attached patch?  \n[snip]\n> For me, cwd() is the same as Cwd->cwd (this is from Perl 5.8.8); perhaps\n> it behaves differently on Cygwin?\n> \n\nYes, sorry, I should have spent a few minutes explaining the cause of the\nbug and why the patch fixes it; my bad!\n\n(I was in a bit of a hurry; I had just re-booted twice in quick succession,\nonce into Linux so that I could pull the patch over to test it there, before\ngoing back to Windows, in order to format-patch and send it to the ML. Yes\nit is a PITA 8-)\n\nI haven't tried your patch because, well, I already know what it will say!\n\nOnce I determined that the problem must be in the following four lines\nof the t/t9700/test.pl script:\n\n17 our $repo_dir = \"trash directory\";\n18 our $abs_repo_dir = Cwd->cwd;\n19 die \"this must be run by calling the t/t97* shell script(s)\\n\"\n20     if basename(Cwd->cwd) ne $repo_dir;\n\nthen the problem and the solution was immediately obvious. Well, maybe that is\noverstating it slightly. After all, I still indulged in a spot of \"printf\ndebugging\" just to make sure! I'm sure you can imagine what it looked like ;-)\n[BTW, the reason it was obvious, is that I have met this problem *too many*\ntimes in the past, so I'm \"attuned\" to it. Don't worry, I will dispense with\nthe rant this time :-P]\n\nI won't repeat that here, but offer a quick script:\n\n    $ cat test-cwd.pl\n    use Cwd;\n\n    print \"cwd():      \", cwd(),      \"\\n\";\n    print \"Cwd::cwd(): \", Cwd::cwd(), \"\\n\";\n    print \"Cwd->cwd:   \", Cwd->cwd,   \"\\n\";\n    $\non cygwin:\n    $ perl test-cwd.pl\n    cwd():      /home/ramsay\n    Cwd::cwd(): /home/ramsay\n    Usage: Cwd::cwd() at test-cwd.pl line 5.\n    $\nand on Linux:\n    $ perl test-cwd.pl\n    cwd():      /home/ramsay\n    Cwd::cwd(): /home/ramsay\n    Cwd->cwd:   /home/ramsay\n    $\n\nSo it is clear, the problem is caused by the \"method invocation syntax\".\nAmong other things, this mechanism auto-magically inserts a new (in this\ncase only) first parameter which represents the \"class\" Cwd to the cwd()\n\"method-call\".\n\nSo, do a \"perldoc Cwd\" and take a look at the example usage. So is cwd()\na method of the Cwd class, or is it a function in the Cwd namespace?\nExactly, hence the patch. (Well, some may prefer to see the Cwd::cwd()\nsyntax used instead. Dunno)\n\nSo, the bug is inappropriate use of the method invocation syntax.\nBut that didn't explain the difference in behaviour on the two platforms,\nhence my \"Don't ask me to explain ...\" comment.\n\nNow it just so happens that I have the source code to perl v5.8.8 in my\nhome directory (no really!) on Linux, so I spent a little time rooting\naround to try and explain it.\n\nThe changelog type files, perl-5.8.8/Changes and perl-5.8.8/ext/Cwd/Changes\ndidn't show much of interest.  The module impl. in perl-5.8.8/lib/Cwd.pm was\nan interesting read but didn't explain it. Then I bumped into the cygwin\nspecific file perl-5.8.8/cygwin/cygwin.c, part of which I include below:\n\n---perl-5.8.8/cygwin/cygwin.c:139-157---\n/* see also Cwd.pm */\nstatic\nXS(Cygwin_cwd)\n{\n    dXSARGS;\n    char *cwd;\n\n    if(items != 0)\n\tPerl_croak(aTHX_ \"Usage: Cwd::cwd()\");\n    if((cwd = getcwd(NULL, -1))) {\n\tST(0) = sv_2mortal(newSVpv(cwd, 0));\n\tfree(cwd);\n#ifndef INCOMPLETE_TAINTS\n\tSvTAINTED_on(ST(0));\n#endif\n\tXSRETURN(1);\n    }\n    XSRETURN_UNDEF;\n}\n------\n\nSo, that explains it.\n\nATB,\n\nRamsay Jones\n\nP.S. I'm sure someone will say that \"the real bug here\" is that the cygwin\nplatform should support the method invocation syntax just like all the\nother platforms. Well, I guess I don't really care that much. But If you\nwere to push me, I would tend to go the other way, and say the other platforms\nshould not allow an incorrect invocation to go unnoticed!\nWhatever.\n"}]}