{"thread":{"id":"13995","subject":"[PATCH 1/2 v2] t/test-lib.sh: add test_external and test_external_without_stderr","startedAt":"2008-06-17T06:59:50Z","lastAt":"2008-06-19T23:55:16Z","messageCount":13,"participants":["Lea Wiemann","Junio C Hamano","Olivier Marin","Jakub Narebski"],"isPatch":true,"patchVersion":2,"patchTotal":2},"messages":[{"id":"80106","messageId":"d94c2a62edfdec22c32ef5d9649078430b30ecfd.1213685306.git.LeWiemann@gmail.com","threadId":"13995","inReplyTo":null,"subject":"[PATCH 1/2 v2] t/test-lib.sh: add test_external and test_external_without_stderr","fromName":"Lea Wiemann","fromEmail":"lewiemann@gmail.com","sentAt":"2008-06-17T06:59:50Z","receivedAt":"2008-06-17T06:59:50Z","isPatch":true,"sender":{"key":"lewiemann@gmail.com","avatar":null},"body":"This is for running external test scripts in other programming\nlanguages that provide continuous output about their tests.  Using\ntest_expect_success (like \"test_expect_success 'description' 'perl\ntest-script.pl'\") doesn't suffice here because test_expect_success\neats stdout in non-verbose mode, which is not fixable without major\nfile descriptor trickery.\n\nSigned-off-by: Lea Wiemann <LeWiemann@gmail.com>\n---\nChanged since v1\n<http://article.gmane.org/gmane.comp.version-control.git/83415>: Fixed\nwhitespace.\n\nBoth functions have been tested with real perl tests and are working\nfine.\n\nThese two patches apply on master.\n\n t/test-lib.sh |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 58 insertions(+), 0 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex c861141..b46fe68 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -302,6 +302,64 @@ test_expect_code () {\n \techo >&3 \"\"\n }\n \n+# test_external runs external test scripts that provide continuous\n+# test output about their progress, and succeeds/fails on\n+# zero/non-zero exit code.  It outputs the test output on stdout even\n+# in non-verbose mode, and announces the external script with \"* run\n+# <n>: ...\" before running it.  When providing relative paths, keep in\n+# mind that all scripts run in \"trash directory\".\n+# Usage: test_external description command arguments...\n+# Example: test_external 'Perl API' perl ../path/to/test.pl\n+test_external () {\n+\ttest \"$#\" -eq 3 ||\n+\terror >&5 \"bug in the test script: not 3 parameters to test_external\"\n+\tdescr=\"$1\"\n+\tshift\n+\tif ! test_skip \"$descr\" \"$@\"\n+\tthen\n+\t\t# Announce the script to reduce confusion about the\n+\t\t# test output that follows.\n+\t\tsay_color \"\" \" run $(expr \"$test_count\" + 1): $descr ($*)\"\n+\t\t# Run command; redirect its stderr to &4 as in\n+\t\t# test_run_, but keep its stdout on our stdout even in\n+\t\t# non-verbose mode.\n+\t\t\"$@\" 2>&4\n+\t\tif [ \"$?\" = 0 ]\n+\t\tthen\n+\t\t\ttest_ok_ \"$descr\"\n+\t\telse\n+\t\t\ttest_failure_ \"$descr\" \"$@\"\n+\t\tfi\n+\tfi\n+}\n+\n+# Like test_external, but in addition tests that the command generated\n+# no output on stderr.\n+test_external_without_stderr () {\n+\t# The temporary file has no (and must have no) security\n+\t# implications.\n+\ttmp=\"$TMPDIR\"; if [ -z \"$tmp\" ]; then tmp=/tmp; fi\n+\tstderr=\"$tmp/git-external-stderr.$$.tmp\"\n+\ttest_external \"$@\" 4> \"$stderr\"\n+\t[ -f \"$stderr\" ] || eror \"Internal error: $stderr disappeared.\"\n+\tdescr=\"no stderr: $1\"\n+\tshift\n+\tsay >&3 \"expecting no stderr from previous command\"\n+\tif [ ! -s \"$stderr\" ]; then\n+\t\trm \"$stderr\"\n+\t\ttest_ok_ \"$descr\"\n+\telse\n+\t\tif [ \"$verbose\" = t ]; then\n+\t\t\toutput=`echo; echo Stderr is:; cat \"$stderr\"`\n+\t\telse\n+\t\t\toutput=\n+\t\tfi\n+\t\t# rm first in case test_failure exits.\n+\t\trm \"$stderr\"\n+\t\ttest_failure_ \"$descr\" \"$@\" \"$output\"\n+\tfi\n+}\n+\n # This is not among top-level (test_expect_success | test_expect_failure)\n # but is a prefix that can be used in the test script, like:\n #\n-- \n1.5.6.rc3.7.ged9620\n"},{"id":"80107","messageId":"4db23d5b625de1aa026cf4630d49b57fd3a09d07.1213685306.git.LeWiemann@gmail.com","threadId":"13995","inReplyTo":"d94c2a62edfdec22c32ef5d9649078430b30ecfd.1213685306.git.LeWiemann@gmail.com","subject":"[PATCH 2/2 v4] Git.pm: add test suite","fromName":"Lea Wiemann","fromEmail":"lewiemann@gmail.com","sentAt":"2008-06-17T06:59:51Z","receivedAt":"2008-06-17T06:59:51Z","isPatch":true,"sender":{"key":"lewiemann@gmail.com","avatar":null},"body":"Add a shell script (t/t9700-perl-git.sh) that sets up a git repository\nand a perl script (t/t9700/test.pl) that runs the actual tests.\n\nSigned-off-by: Lea Wiemann <LeWiemann@gmail.com>\n---\nChanged since v3\n<http://thread.gmane.org/gmane.comp.version-control.git/83425/focus=83480>:\nOnly test the vanilla Git.pm, as I'm not intending to extend it right\nnow.  So no Git::get_hash (or Git::rev_parse) method there.\n\nI also simplified the test repository setup code a bit.\n\n t/t9700-perl-git.sh |   39 ++++++++++++++++++++\n t/t9700/test.pl     |   99 +++++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 138 insertions(+), 0 deletions(-)\n create mode 100755 t/t9700-perl-git.sh\n create mode 100755 t/t9700/test.pl\n\ndiff --git a/t/t9700-perl-git.sh b/t/t9700-perl-git.sh\nnew file mode 100755\nindex 0000000..592d79a\n--- /dev/null\n+++ b/t/t9700-perl-git.sh\n@@ -0,0 +1,39 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2008 Lea Wiemann\n+#\n+\n+test_description='perl interface (Git.pm)'\n+. ./test-lib.sh\n+\n+# set up test repository\n+\n+test_expect_success \\\n+    'set up test repository' \\\n+    'echo \"test file 1\" > file1 &&\n+     echo \"test file 2\" > file2 &&\n+     mkdir directory1 &&\n+     echo \"in directory1\" >> directory1/file &&\n+     mkdir directory2 &&\n+     echo \"in directory2\" >> directory2/file &&\n+     git add . &&\n+     git commit -m \"first commit\" &&\n+\n+     echo \"changed file 1\" > file1 &&\n+     git commit -a -m \"second commit\" &&\n+\n+     git-config --add color.test.slot1 green &&\n+     git-config --add test.string value &&\n+     git-config --add test.dupstring value1 &&\n+     git-config --add test.dupstring value2 &\n+     git-config --add test.booltrue true &&\n+     git-config --add test.boolfalse no &&\n+     git-config --add test.boolother other &&\n+     git-config --add test.int 2k\n+     '\n+\n+test_external_without_stderr \\\n+    'Perl API' \\\n+    perl ../t9700/test.pl\n+\n+test_done\ndiff --git a/t/t9700/test.pl b/t/t9700/test.pl\nnew file mode 100755\nindex 0000000..8318fec\n--- /dev/null\n+++ b/t/t9700/test.pl\n@@ -0,0 +1,99 @@\n+#!/usr/bin/perl\n+use lib (split(/:/, $ENV{GITPERLLIB}));\n+\n+use warnings;\n+use strict;\n+\n+use Test::More qw(no_plan);\n+\n+use Cwd;\n+use File::Basename;\n+use File::Temp;\n+use IO::String;\n+\n+BEGIN { use_ok('Git') }\n+\n+# set up\n+our $repo_dir = \"trash directory\";\n+our $abs_repo_dir = Cwd->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+ok(our $r = Git->repository(Directory => \".\"), \"open repository\");\n+\n+# config\n+is($r->config(\"test.string\"), \"value\", \"config scalar: string\");\n+is_deeply([$r->config(\"test.dupstring\")], [\"value1\", \"value2\"],\n+\t  \"config array: string\");\n+is($r->config(\"test.nonexistent\"), undef, \"config scalar: nonexistent\");\n+is_deeply([$r->config(\"test.nonexistent\")], [], \"config array: nonexistent\");\n+is($r->config_int(\"test.int\"), 2048, \"config_int: integer\");\n+is($r->config_int(\"test.nonexistent\"), undef, \"config_int: nonexistent\");\n+ok($r->config_bool(\"test.booltrue\"), \"config_bool: true\");\n+ok(!$r->config_bool(\"test.boolfalse\"), \"config_bool: false\");\n+our $ansi_green = \"\\x1b[32m\";\n+is($r->get_color(\"color.test.slot1\", \"red\"), $ansi_green, \"get_color\");\n+# Cannot test $r->get_colorbool(\"color.foo\")) because we do not\n+# control whether our STDOUT is a terminal.\n+\n+# Failure cases for config:\n+# Save and restore STDERR; we will probably extract this into a\n+# \"dies_ok\" method and possibly move the STDERR handling to Git.pm.\n+open our $tmpstderr, \">&\", STDERR or die \"cannot save STDERR\"; close STDERR;\n+eval { $r->config(\"test.dupstring\") };\n+ok($@, \"config: duplicate entry in scalar context fails\");\n+eval { $r->config_bool(\"test.boolother\") };\n+ok($@, \"config_bool: non-boolean values fail\");\n+open STDERR, \">&\", $tmpstderr or die \"cannot restore STDERR\";\n+\n+# ident\n+like($r->ident(\"aUthor\"), qr/^A U Thor <author\\@example.com> [0-9]+ \\+0000$/,\n+     \"ident scalar: author (type)\");\n+like($r->ident(\"cOmmitter\"), qr/^C O Mitter <committer\\@example.com> [0-9]+ \\+0000$/,\n+     \"ident scalar: committer (type)\");\n+is($r->ident(\"invalid\"), \"invalid\", \"ident scalar: invalid ident string (no parsing)\");\n+my ($name, $email, $time_tz) = $r->ident('author');\n+is_deeply([$name, $email], [\"A U Thor\", \"author\\@example.com\"],\n+\t \"ident array: author\");\n+like($time_tz, qr/[0-9]+ \\+0000/, \"ident array: author\");\n+is_deeply([$r->ident(\"Name <email> 123 +0000\")], [\"Name\", \"email\", \"123 +0000\"],\n+\t  \"ident array: ident string\");\n+is_deeply([$r->ident(\"invalid\")], [], \"ident array: invalid ident string\");\n+\n+# ident_person\n+is($r->ident_person(\"aUthor\"), \"A U Thor <author\\@example.com>\",\n+   \"ident_person: author (type)\");\n+is($r->ident_person(\"Name <email> 123 +0000\"), \"Name <email>\",\n+   \"ident_person: ident string\");\n+is($r->ident_person(\"Name\", \"email\", \"123 +0000\"), \"Name <email>\",\n+   \"ident_person: array\");\n+\n+# objects and hashes\n+ok(our $file1hash = $r->command_oneline('rev-parse', \"HEAD:file1\"), \"(get file hash)\");\n+our $iostring = IO::String->new;\n+is($r->cat_blob($file1hash, $iostring), 15, \"cat_blob: size\");\n+is(${$iostring->string_ref}, \"changed file 1\\n\", \"cat_blob: data\");\n+our $tmpfile = File::Temp->new();\n+print $tmpfile ${$iostring->string_ref};\n+is(Git::hash_object(\"blob\", $tmpfile), $file1hash, \"hash_object: roundtrip\");\n+$tmpfile = File::Temp->new();\n+print $tmpfile my $test_text = \"test blob, to be inserted\\n\";\n+$tmpfile->close;\n+like(our $newhash = $r->hash_and_insert_object($tmpfile), qr/[0-9a-fA-F]{40}/,\n+     \"hash_and_insert_object: returns hash\");\n+$iostring = IO::String->new;\n+is($r->cat_blob($newhash, $iostring), length $test_text, \"cat_blob: roundtrip size\");\n+is(${$iostring->string_ref}, $test_text, \"cat_blob: roundtrip data\");\n+\n+# paths\n+is($r->repo_path, \"./.git\", \"repo_path\");\n+is($r->wc_path, $abs_repo_dir . \"/\", \"wc_path\");\n+is($r->wc_subdir, \"\", \"wc_subdir initial\");\n+$r->wc_chdir(\"directory1\");\n+is($r->wc_subdir, \"directory1\", \"wc_subdir after wc_chdir\");\n+TODO: {\n+\tlocal $TODO = \"commands do not work after wc_chdir\";\n+\t# Failure output is active even in non-verbose mode and thus\n+\t# annoying.  Hence we skip these tests as long as they fail.\n+\ttodo_skip 'config after wc_chdir', 1;\n+\tis($r->config(\"color.string\"), \"value\", \"config after wc_chdir\");\n+}\n-- \n1.5.6.rc3.7.ged9620\n"},{"id":"80197","messageId":"7v63s7301m.fsf@gitster.siamese.dyndns.org","threadId":"13995","inReplyTo":"4db23d5b625de1aa026cf4630d49b57fd3a09d07.1213685306.git.LeWiemann@gmail.com","subject":"Re: [PATCH 2/2 v4] Git.pm: add test suite","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-06-18T03:16:21Z","receivedAt":"2008-06-18T03:16:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lea Wiemann <lewiemann@gmail.com> writes:\n\n> diff --git a/t/t9700/test.pl b/t/t9700/test.pl\n> new file mode 100755\n> index 0000000..8318fec\n> --- /dev/null\n> +++ b/t/t9700/test.pl\n> @@ -0,0 +1,99 @@\n> +#!/usr/bin/perl\n> +use lib (split(/:/, $ENV{GITPERLLIB}));\n> +\n> +use warnings;\n> +use strict;\n> +\n> +use Test::More qw(no_plan);\n> +\n> +use Cwd;\n> +use File::Basename;\n> +use File::Temp;\n> +use IO::String;\n\nThe system I first tried this did not have IO::String installed.  Is this\nsomething we would want to rely on being available?\n\nIt also indicates a slight problem in test_external.  Can it become a bit\neasier to tell such a basic problem apart from real test errors?  I needed\nto look into /tmp/* to see where it is failing but it would be nice if we\ncan somehow see the breakage with \"sh t9700-*.sh -v\".\n"},{"id":"80235","messageId":"48594E42.2050402@gmail.com","threadId":"13995","inReplyTo":"7v63s7301m.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 2/2 v4] Git.pm: add test suite","fromName":"Lea Wiemann","fromEmail":"lewiemann@gmail.com","sentAt":"2008-06-18T18:04:50Z","receivedAt":"2008-06-18T18:04:50Z","isPatch":true,"sender":{"key":"lewiemann@gmail.com","avatar":null},"body":"Junio C Hamano wrote:\n> The system I first tried this did not have IO::String installed.\n\nMy bad, I should've checked this before sending it off.  I guess we'll \nsolve this in Michael's patch thread; don't expect a reply from me in \nthe next 12h though, I'm way tired and utterly unproductive right now.\n\n> [test_external:] Can it become a bit easier to tell such a basic\n> problem apart from real test errors?  I needed to look into\n> /tmp/* to see where it is failing\n\nHm, is your test output somehow different from the following?  It states \nthe error quite clearly at the bottom.\n\n$ ./t9700-perl-git.sh -v\n* expecting success: echo \"test file 1\" > file1 &&\n      echo \"test file 2\" > file2 &&\n      [...]\n      git-config --add test.int 2k\n\n*   ok 1: set up test repository\n[...]\n*  run 2: Perl API (perl ../t9700/test.pl)\n* FAIL 2: Perl API\n\tperl ../t9700/test.pl\n* expecting no stderr from previous command\n* FAIL 3: no stderr: Perl API\n\tperl ../t9700/test.pl\n\tStderr is:\n\tCan't locate IO/String.pm in @INC (@INC contains: \n/home/lea/G/t/../perl/blib/lib /home/lea/G/t/../perl/blib/arch/auto/Git \n/home/lea/.perl/lib /etc/perl /usr/local/lib/perl/5.10.0 \n/usr/local/share/perl/5.10.0 /usr/lib/perl5 /usr/share/perl5 \n/usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at \n../t9700/test.pl line 12.\n\tBEGIN failed--compilation aborted at ../t9700/test.pl line 12.\n\t# Looks like your test died before it could output anything.\n* failed 2 among 3 test(s)\n\n-- Lea\n"},{"id":"80244","messageId":"7vve06y1j0.fsf@gitster.siamese.dyndns.org","threadId":"13995","inReplyTo":"48594E42.2050402@gmail.com","subject":"Re: [PATCH 2/2 v4] Git.pm: add test suite","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-06-18T19:40:51Z","receivedAt":"2008-06-18T19:40:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lea Wiemann <lewiemann@gmail.com> writes:\n\n> Junio C Hamano wrote:\n>> The system I first tried this did not have IO::String installed.\n>\n> My bad, I should've checked this before sending it off.  I guess we'll\n> solve this in Michael's patch thread; don't expect a reply from me in\n> the next 12h though, I'm way tired and utterly unproductive right now.\n>\n>> [test_external:] Can it become a bit easier to tell such a basic\n>> problem apart from real test errors?  I needed to look into\n>> /tmp/* to see where it is failing\n>\n> Hm, is your test output somehow different from the following?  It\n> states the error quite clearly at the bottom.\n> ...\n> * expecting no stderr from previous command\n> * FAIL 3: no stderr: Perl API\n> \tperl ../t9700/test.pl\n> \tStderr is:\n> \tCan't locate IO/String.pm in @INC (@INC contains:\n> /home/lea/G/t/../perl/blib/lib\n> /home/lea/G/t/../perl/blib/arch/auto/Git /home/lea/.perl/lib /etc/perl\n> /usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5\n> /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10\n> /usr/local/lib/site_perl .) at ../t9700/test.pl line 12.\n> \tBEGIN failed--compilation aborted at ../t9700/test.pl line 12.\n> \t# Looks like your test died before it could output anything.\n> * failed 2 among 3 test(s)\n\nYeah, I do see \"Can't locate IO/String.pm\".  Thanks.\n"},{"id":"80249","messageId":"48596EE7.90202@free.fr","threadId":"13995","inReplyTo":"d94c2a62edfdec22c32ef5d9649078430b30ecfd.1213685306.git.LeWiemann@gmail.com","subject":"Re: [PATCH 1/2 v2] t/test-lib.sh: add test_external and test_external_without_stderr","fromName":"Olivier Marin","fromEmail":"dkr+ml.git@free.fr","sentAt":"2008-06-18T20:24:07Z","receivedAt":"2008-06-18T20:24:07Z","isPatch":true,"sender":{"key":"dkr+ml.git@free.fr","avatar":null},"body":"Hi,\n\nLea Wiemann a écrit :\n> +# Like test_external, but in addition tests that the command generated\n> +# no output on stderr.\n> +test_external_without_stderr () {\n> +\t# The temporary file has no (and must have no) security\n> +\t# implications.\n> +\ttmp=\"$TMPDIR\"; if [ -z \"$tmp\" ]; then tmp=/tmp; fi\n> +\tstderr=\"$tmp/git-external-stderr.$$.tmp\"\n> +\ttest_external \"$@\" 4> \"$stderr\"\n> +\t[ -f \"$stderr\" ] || eror \"Internal error: $stderr disappeared.\"\n\nJust a typo here: s/eror/error/\n\nOlivier.\n"},{"id":"80251","messageId":"485970D0.8020104@free.fr","threadId":"13995","inReplyTo":"4db23d5b625de1aa026cf4630d49b57fd3a09d07.1213685306.git.LeWiemann@gmail.com","subject":"Re: [PATCH 2/2 v4] Git.pm: add test suite","fromName":"Olivier Marin","fromEmail":"dkr+ml.git@free.fr","sentAt":"2008-06-18T20:32:16Z","receivedAt":"2008-06-18T20:32:16Z","isPatch":true,"sender":{"key":"dkr+ml.git@free.fr","avatar":null},"body":"Lea Wiemann a écrit :\n> \n> diff --git a/t/t9700-perl-git.sh b/t/t9700-perl-git.sh\n> new file mode 100755\n> index 0000000..592d79a\n> --- /dev/null\n> +++ b/t/t9700-perl-git.sh\n> @@ -0,0 +1,39 @@\n> +#!/bin/sh\n> +#\n> +# Copyright (c) 2008 Lea Wiemann\n> +#\n> +\n> +test_description='perl interface (Git.pm)'\n> +. ./test-lib.sh\n> +\n> +# set up test repository\n> +\n> +test_expect_success \\\n> +    'set up test repository' \\\n> +    'echo \"test file 1\" > file1 &&\n> +     echo \"test file 2\" > file2 &&\n> +     mkdir directory1 &&\n> +     echo \"in directory1\" >> directory1/file &&\n> +     mkdir directory2 &&\n> +     echo \"in directory2\" >> directory2/file &&\n> +     git add . &&\n> +     git commit -m \"first commit\" &&\n> +\n> +     echo \"changed file 1\" > file1 &&\n> +     git commit -a -m \"second commit\" &&\n> +\n> +     git-config --add color.test.slot1 green &&\n> +     git-config --add test.string value &&\n> +     git-config --add test.dupstring value1 &&\n> +     git-config --add test.dupstring value2 &\n\nWhile I was running the whole test suite, your test cases randomly\nfailed. I did not understand until I see the missing & here. ;-)\n\nOlivier.\n"},{"id":"80344","messageId":"d5ac06cabb7eb235ca82525fad2e96cdab205469.1213899000.git.LeWiemann@gmail.com","threadId":"13995","inReplyTo":"48596EE7.90202@free.fr","subject":"[PATCH 1/2 v3] t/test-lib.sh: add test_external and test_external_without_stderr","fromName":"Lea Wiemann","fromEmail":"lewiemann@gmail.com","sentAt":"2008-06-19T18:18:03Z","receivedAt":"2008-06-19T18:18:03Z","isPatch":true,"sender":{"key":"lewiemann@gmail.com","avatar":null},"body":"This is for running external test scripts in other programming\nlanguages that provide continuous output about their tests.  Using\ntest_expect_success (like \"test_expect_success 'description' 'perl\ntest-script.pl'\") doesn't suffice here because test_expect_success\neats stdout in non-verbose mode, which is not fixable without major\nfile descriptor trickery.\n\nSigned-off-by: Lea Wiemann <LeWiemann@gmail.com>\n---\nOlivier Marin wrote:\n> Just a typo here: s/eror/error/\n\nThanks for spotting this, and also the missing ampersand in the other\npatch!\n\n(This typo is the only change since v2.)\n\n t/test-lib.sh |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 58 insertions(+), 0 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 3ac8755..dc2736e 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -304,6 +304,64 @@ test_expect_code () {\n \techo >&3 \"\"\n }\n \n+# test_external runs external test scripts that provide continuous\n+# test output about their progress, and succeeds/fails on\n+# zero/non-zero exit code.  It outputs the test output on stdout even\n+# in non-verbose mode, and announces the external script with \"* run\n+# <n>: ...\" before running it.  When providing relative paths, keep in\n+# mind that all scripts run in \"trash directory\".\n+# Usage: test_external description command arguments...\n+# Example: test_external 'Perl API' perl ../path/to/test.pl\n+test_external () {\n+\ttest \"$#\" -eq 3 ||\n+\terror >&5 \"bug in the test script: not 3 parameters to test_external\"\n+\tdescr=\"$1\"\n+\tshift\n+\tif ! test_skip \"$descr\" \"$@\"\n+\tthen\n+\t\t# Announce the script to reduce confusion about the\n+\t\t# test output that follows.\n+\t\tsay_color \"\" \" run $(expr \"$test_count\" + 1): $descr ($*)\"\n+\t\t# Run command; redirect its stderr to &4 as in\n+\t\t# test_run_, but keep its stdout on our stdout even in\n+\t\t# non-verbose mode.\n+\t\t\"$@\" 2>&4\n+\t\tif [ \"$?\" = 0 ]\n+\t\tthen\n+\t\t\ttest_ok_ \"$descr\"\n+\t\telse\n+\t\t\ttest_failure_ \"$descr\" \"$@\"\n+\t\tfi\n+\tfi\n+}\n+\n+# Like test_external, but in addition tests that the command generated\n+# no output on stderr.\n+test_external_without_stderr () {\n+\t# The temporary file has no (and must have no) security\n+\t# implications.\n+\ttmp=\"$TMPDIR\"; if [ -z \"$tmp\" ]; then tmp=/tmp; fi\n+\tstderr=\"$tmp/git-external-stderr.$$.tmp\"\n+\ttest_external \"$@\" 4> \"$stderr\"\n+\t[ -f \"$stderr\" ] || error \"Internal error: $stderr disappeared.\"\n+\tdescr=\"no stderr: $1\"\n+\tshift\n+\tsay >&3 \"expecting no stderr from previous command\"\n+\tif [ ! -s \"$stderr\" ]; then\n+\t\trm \"$stderr\"\n+\t\ttest_ok_ \"$descr\"\n+\telse\n+\t\tif [ \"$verbose\" = t ]; then\n+\t\t\toutput=`echo; echo Stderr is:; cat \"$stderr\"`\n+\t\telse\n+\t\t\toutput=\n+\t\tfi\n+\t\t# rm first in case test_failure exits.\n+\t\trm \"$stderr\"\n+\t\ttest_failure_ \"$descr\" \"$@\" \"$output\"\n+\tfi\n+}\n+\n # This is not among top-level (test_expect_success | test_expect_failure)\n # but is a prefix that can be used in the test script, like:\n #\n-- \n1.5.6.149.g06c04.dirty\n"},{"id":"80343","messageId":"1244a3347b6f15120e57f6b9223a4e2db06479df.1213899000.git.LeWiemann@gmail.com","threadId":"13995","inReplyTo":"d5ac06cabb7eb235ca82525fad2e96cdab205469.1213899000.git.LeWiemann@gmail.com","subject":"[PATCH 2/2 v5] Git.pm: add test suite","fromName":"Lea Wiemann","fromEmail":"lewiemann@gmail.com","sentAt":"2008-06-19T18:18:04Z","receivedAt":"2008-06-19T18:18:04Z","isPatch":true,"sender":{"key":"lewiemann@gmail.com","avatar":null},"body":"Add a shell script (t/t9700-perl-git.sh) that sets up a git repository\nand a perl script (t/t9700/test.pl) that runs the actual tests.\n\nSigned-off-by: Lea Wiemann <LeWiemann@gmail.com>\n---\nChanges since v4:\n\n- Added missing ampersand (thanks Olivier!).\n- Use 5.006002 (lowest possible version for Test::More).\n- Use File::Temp instead of the external IO::String.\n\nTested with Perl 5.6, 5.8, 5.10.  Diff against v4 of this patch:\n\nindex 592d79a..b2fb9ec 100755\n--- a/t/t9700-perl-git.sh\n+++ b/t/t9700-perl-git.sh\n@@ -25,7 +25,7 @@ test_expect_success \\\n      git-config --add color.test.slot1 green &&\n      git-config --add test.string value &&\n      git-config --add test.dupstring value1 &&\n-     git-config --add test.dupstring value2 &\n+     git-config --add test.dupstring value2 &&\n      git-config --add test.booltrue true &&\n      git-config --add test.boolfalse no &&\n      git-config --add test.boolother other &&\ndiff --git a/t/t9700/test.pl b/t/t9700/test.pl\nindex 8318fec..4d23125 100755\n--- a/t/t9700/test.pl\n+++ b/t/t9700/test.pl\n@@ -1,6 +1,7 @@\n #!/usr/bin/perl\n use lib (split(/:/, $ENV{GITPERLLIB}));\n \n+use 5.006002;  # Test::More was introduced in 5.6.2\n use warnings;\n use strict;\n \n@@ -9,7 +10,6 @@ use Test::More qw(no_plan);\n use Cwd;\n use File::Basename;\n use File::Temp;\n-use IO::String;\n \n BEGIN { use_ok('Git') }\n \n@@ -69,20 +69,21 @@ is($r->ident_person(\"Name\", \"email\", \"123 +0000\"), \"Name <email>\",\n \n # objects and hashes\n ok(our $file1hash = $r->command_oneline('rev-parse', \"HEAD:file1\"), \"(get file hash)\");\n-our $iostring = IO::String->new;\n-is($r->cat_blob($file1hash, $iostring), 15, \"cat_blob: size\");\n-is(${$iostring->string_ref}, \"changed file 1\\n\", \"cat_blob: data\");\n-our $tmpfile = File::Temp->new();\n-print $tmpfile ${$iostring->string_ref};\n+our $tmpfile = File::Temp->new;\n+is($r->cat_blob($file1hash, $tmpfile), 15, \"cat_blob: size\");\n+our $blobcontents;\n+{ local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }\n+is($blobcontents, \"changed file 1\\n\", \"cat_blob: data\");\n+seek $tmpfile, 0, 0;\n is(Git::hash_object(\"blob\", $tmpfile), $file1hash, \"hash_object: roundtrip\");\n $tmpfile = File::Temp->new();\n print $tmpfile my $test_text = \"test blob, to be inserted\\n\";\n-$tmpfile->close;\n like(our $newhash = $r->hash_and_insert_object($tmpfile), qr/[0-9a-fA-F]{40}/,\n      \"hash_and_insert_object: returns hash\");\n-$iostring = IO::String->new;\n-is($r->cat_blob($newhash, $iostring), length $test_text, \"cat_blob: roundtrip size\");\n-is(${$iostring->string_ref}, $test_text, \"cat_blob: roundtrip data\");\n+$tmpfile = File::Temp->new;\n+is($r->cat_blob($newhash, $tmpfile), length $test_text, \"cat_blob: roundtrip size\");\n+{ local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }\n+is($blobcontents, $test_text, \"cat_blob: roundtrip data\");\n \n # paths\n is($r->repo_path, \"./.git\", \"repo_path\");\n\n\n\n\n\n t/t9700-perl-git.sh |   39 ++++++++++++++++++++\n t/t9700/test.pl     |  100 +++++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 139 insertions(+), 0 deletions(-)\n create mode 100755 t/t9700-perl-git.sh\n create mode 100755 t/t9700/test.pl\n\ndiff --git a/t/t9700-perl-git.sh b/t/t9700-perl-git.sh\nnew file mode 100755\nindex 0000000..b2fb9ec\n--- /dev/null\n+++ b/t/t9700-perl-git.sh\n@@ -0,0 +1,39 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2008 Lea Wiemann\n+#\n+\n+test_description='perl interface (Git.pm)'\n+. ./test-lib.sh\n+\n+# set up test repository\n+\n+test_expect_success \\\n+    'set up test repository' \\\n+    'echo \"test file 1\" > file1 &&\n+     echo \"test file 2\" > file2 &&\n+     mkdir directory1 &&\n+     echo \"in directory1\" >> directory1/file &&\n+     mkdir directory2 &&\n+     echo \"in directory2\" >> directory2/file &&\n+     git add . &&\n+     git commit -m \"first commit\" &&\n+\n+     echo \"changed file 1\" > file1 &&\n+     git commit -a -m \"second commit\" &&\n+\n+     git-config --add color.test.slot1 green &&\n+     git-config --add test.string value &&\n+     git-config --add test.dupstring value1 &&\n+     git-config --add test.dupstring value2 &&\n+     git-config --add test.booltrue true &&\n+     git-config --add test.boolfalse no &&\n+     git-config --add test.boolother other &&\n+     git-config --add test.int 2k\n+     '\n+\n+test_external_without_stderr \\\n+    'Perl API' \\\n+    perl ../t9700/test.pl\n+\n+test_done\ndiff --git a/t/t9700/test.pl b/t/t9700/test.pl\nnew file mode 100755\nindex 0000000..4d23125\n--- /dev/null\n+++ b/t/t9700/test.pl\n@@ -0,0 +1,100 @@\n+#!/usr/bin/perl\n+use lib (split(/:/, $ENV{GITPERLLIB}));\n+\n+use 5.006002;\n+use warnings;\n+use strict;\n+\n+use Test::More qw(no_plan);\n+\n+use Cwd;\n+use File::Basename;\n+use File::Temp;\n+\n+BEGIN { use_ok('Git') }\n+\n+# set up\n+our $repo_dir = \"trash directory\";\n+our $abs_repo_dir = Cwd->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+ok(our $r = Git->repository(Directory => \".\"), \"open repository\");\n+\n+# config\n+is($r->config(\"test.string\"), \"value\", \"config scalar: string\");\n+is_deeply([$r->config(\"test.dupstring\")], [\"value1\", \"value2\"],\n+\t  \"config array: string\");\n+is($r->config(\"test.nonexistent\"), undef, \"config scalar: nonexistent\");\n+is_deeply([$r->config(\"test.nonexistent\")], [], \"config array: nonexistent\");\n+is($r->config_int(\"test.int\"), 2048, \"config_int: integer\");\n+is($r->config_int(\"test.nonexistent\"), undef, \"config_int: nonexistent\");\n+ok($r->config_bool(\"test.booltrue\"), \"config_bool: true\");\n+ok(!$r->config_bool(\"test.boolfalse\"), \"config_bool: false\");\n+our $ansi_green = \"\\x1b[32m\";\n+is($r->get_color(\"color.test.slot1\", \"red\"), $ansi_green, \"get_color\");\n+# Cannot test $r->get_colorbool(\"color.foo\")) because we do not\n+# control whether our STDOUT is a terminal.\n+\n+# Failure cases for config:\n+# Save and restore STDERR; we will probably extract this into a\n+# \"dies_ok\" method and possibly move the STDERR handling to Git.pm.\n+open our $tmpstderr, \">&\", STDERR or die \"cannot save STDERR\"; close STDERR;\n+eval { $r->config(\"test.dupstring\") };\n+ok($@, \"config: duplicate entry in scalar context fails\");\n+eval { $r->config_bool(\"test.boolother\") };\n+ok($@, \"config_bool: non-boolean values fail\");\n+open STDERR, \">&\", $tmpstderr or die \"cannot restore STDERR\";\n+\n+# ident\n+like($r->ident(\"aUthor\"), qr/^A U Thor <author\\@example.com> [0-9]+ \\+0000$/,\n+     \"ident scalar: author (type)\");\n+like($r->ident(\"cOmmitter\"), qr/^C O Mitter <committer\\@example.com> [0-9]+ \\+0000$/,\n+     \"ident scalar: committer (type)\");\n+is($r->ident(\"invalid\"), \"invalid\", \"ident scalar: invalid ident string (no parsing)\");\n+my ($name, $email, $time_tz) = $r->ident('author');\n+is_deeply([$name, $email], [\"A U Thor\", \"author\\@example.com\"],\n+\t \"ident array: author\");\n+like($time_tz, qr/[0-9]+ \\+0000/, \"ident array: author\");\n+is_deeply([$r->ident(\"Name <email> 123 +0000\")], [\"Name\", \"email\", \"123 +0000\"],\n+\t  \"ident array: ident string\");\n+is_deeply([$r->ident(\"invalid\")], [], \"ident array: invalid ident string\");\n+\n+# ident_person\n+is($r->ident_person(\"aUthor\"), \"A U Thor <author\\@example.com>\",\n+   \"ident_person: author (type)\");\n+is($r->ident_person(\"Name <email> 123 +0000\"), \"Name <email>\",\n+   \"ident_person: ident string\");\n+is($r->ident_person(\"Name\", \"email\", \"123 +0000\"), \"Name <email>\",\n+   \"ident_person: array\");\n+\n+# objects and hashes\n+ok(our $file1hash = $r->command_oneline('rev-parse', \"HEAD:file1\"), \"(get file hash)\");\n+our $tmpfile = File::Temp->new;\n+is($r->cat_blob($file1hash, $tmpfile), 15, \"cat_blob: size\");\n+our $blobcontents;\n+{ local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }\n+is($blobcontents, \"changed file 1\\n\", \"cat_blob: data\");\n+seek $tmpfile, 0, 0;\n+is(Git::hash_object(\"blob\", $tmpfile), $file1hash, \"hash_object: roundtrip\");\n+$tmpfile = File::Temp->new();\n+print $tmpfile my $test_text = \"test blob, to be inserted\\n\";\n+like(our $newhash = $r->hash_and_insert_object($tmpfile), qr/[0-9a-fA-F]{40}/,\n+     \"hash_and_insert_object: returns hash\");\n+$tmpfile = File::Temp->new;\n+is($r->cat_blob($newhash, $tmpfile), length $test_text, \"cat_blob: roundtrip size\");\n+{ local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }\n+is($blobcontents, $test_text, \"cat_blob: roundtrip data\");\n+\n+# paths\n+is($r->repo_path, \"./.git\", \"repo_path\");\n+is($r->wc_path, $abs_repo_dir . \"/\", \"wc_path\");\n+is($r->wc_subdir, \"\", \"wc_subdir initial\");\n+$r->wc_chdir(\"directory1\");\n+is($r->wc_subdir, \"directory1\", \"wc_subdir after wc_chdir\");\n+TODO: {\n+\tlocal $TODO = \"commands do not work after wc_chdir\";\n+\t# Failure output is active even in non-verbose mode and thus\n+\t# annoying.  Hence we skip these tests as long as they fail.\n+\ttodo_skip 'config after wc_chdir', 1;\n+\tis($r->config(\"color.string\"), \"value\", \"config after wc_chdir\");\n+}\n-- \n1.5.6.149.g06c04.dirty\n"},{"id":"80364","messageId":"1213907569-6393-1-git-send-email-LeWiemann@gmail.com","threadId":"13995","inReplyTo":"1244a3347b6f15120e57f6b9223a4e2db06479df.1213899000.git.LeWiemann@gmail.com","subject":"[PATCH 2/2 v5] Git.pm: add test suite","fromName":"Lea Wiemann","fromEmail":"lewiemann@gmail.com","sentAt":"2008-06-19T20:32:49Z","receivedAt":"2008-06-19T20:32:49Z","isPatch":true,"sender":{"key":"lewiemann@gmail.com","avatar":null},"body":"Add a shell script (t/t9700-perl-git.sh) that sets up a git repository\nand a perl script (t/t9700/test.pl) that runs the actual tests.\n\nSigned-off-by: Lea Wiemann <LeWiemann@gmail.com>\n---\n[Resent with fixed diff to v4 so git-am doesn't get confused. ;-)]\n\nChanges since v4:\n\n- Added missing ampersand (thanks Olivier!).\n- Use 5.006002 (lowest possible version for Test::More).\n- Use File::Temp instead of the external IO::String.\n\nTested with Perl 5.6, 5.8, 5.10.  Diff against v4 of this patch:\n\n    index 592d79a..b2fb9ec 100755\n    --- a/t/t9700-perl-git.sh\n    +++ b/t/t9700-perl-git.sh\n    @@ -25,7 +25,7 @@ test_expect_success \\\n          git-config --add color.test.slot1 green &&\n          git-config --add test.string value &&\n          git-config --add test.dupstring value1 &&\n    -     git-config --add test.dupstring value2 &\n    +     git-config --add test.dupstring value2 &&\n          git-config --add test.booltrue true &&\n          git-config --add test.boolfalse no &&\n          git-config --add test.boolother other &&\n    diff --git a/t/t9700/test.pl b/t/t9700/test.pl\n    index 8318fec..4d23125 100755\n    --- a/t/t9700/test.pl\n    +++ b/t/t9700/test.pl\n    @@ -1,6 +1,7 @@\n     #!/usr/bin/perl\n     use lib (split(/:/, $ENV{GITPERLLIB}));\n\n    +use 5.006002;  # Test::More was introduced in 5.6.2\n     use warnings;\n     use strict;\n\n    @@ -9,7 +10,6 @@ use Test::More qw(no_plan);\n     use Cwd;\n     use File::Basename;\n     use File::Temp;\n    -use IO::String;\n\n     BEGIN { use_ok('Git') }\n\n    @@ -69,20 +69,21 @@ is($r->ident_person(\"Name\", \"email\", \"123 +0000\"), \"Name <email>\",\n\n     # objects and hashes\n     ok(our $file1hash = $r->command_oneline('rev-parse', \"HEAD:file1\"), \"(get file hash)\");\n    -our $iostring = IO::String->new;\n    -is($r->cat_blob($file1hash, $iostring), 15, \"cat_blob: size\");\n    -is(${$iostring->string_ref}, \"changed file 1\\n\", \"cat_blob: data\");\n    -our $tmpfile = File::Temp->new();\n    -print $tmpfile ${$iostring->string_ref};\n    +our $tmpfile = File::Temp->new;\n    +is($r->cat_blob($file1hash, $tmpfile), 15, \"cat_blob: size\");\n    +our $blobcontents;\n    +{ local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }\n    +is($blobcontents, \"changed file 1\\n\", \"cat_blob: data\");\n    +seek $tmpfile, 0, 0;\n     is(Git::hash_object(\"blob\", $tmpfile), $file1hash, \"hash_object: roundtrip\");\n     $tmpfile = File::Temp->new();\n     print $tmpfile my $test_text = \"test blob, to be inserted\\n\";\n    -$tmpfile->close;\n     like(our $newhash = $r->hash_and_insert_object($tmpfile), qr/[0-9a-fA-F]{40}/,\n          \"hash_and_insert_object: returns hash\");\n    -$iostring = IO::String->new;\n    -is($r->cat_blob($newhash, $iostring), length $test_text, \"cat_blob: roundtrip size\");\n    -is(${$iostring->string_ref}, $test_text, \"cat_blob: roundtrip data\");\n    +$tmpfile = File::Temp->new;\n    +is($r->cat_blob($newhash, $tmpfile), length $test_text, \"cat_blob: roundtrip size\");\n    +{ local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }\n    +is($blobcontents, $test_text, \"cat_blob: roundtrip data\");\n\n     # paths\n     is($r->repo_path, \"./.git\", \"repo_path\");\n\n\n\n t/t9700-perl-git.sh |   39 ++++++++++++++++++++\n t/t9700/test.pl     |  100 +++++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 139 insertions(+), 0 deletions(-)\n create mode 100755 t/t9700-perl-git.sh\n create mode 100755 t/t9700/test.pl\n\ndiff --git a/t/t9700-perl-git.sh b/t/t9700-perl-git.sh\nnew file mode 100755\nindex 0000000..b2fb9ec\n--- /dev/null\n+++ b/t/t9700-perl-git.sh\n@@ -0,0 +1,39 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2008 Lea Wiemann\n+#\n+\n+test_description='perl interface (Git.pm)'\n+. ./test-lib.sh\n+\n+# set up test repository\n+\n+test_expect_success \\\n+    'set up test repository' \\\n+    'echo \"test file 1\" > file1 &&\n+     echo \"test file 2\" > file2 &&\n+     mkdir directory1 &&\n+     echo \"in directory1\" >> directory1/file &&\n+     mkdir directory2 &&\n+     echo \"in directory2\" >> directory2/file &&\n+     git add . &&\n+     git commit -m \"first commit\" &&\n+\n+     echo \"changed file 1\" > file1 &&\n+     git commit -a -m \"second commit\" &&\n+\n+     git-config --add color.test.slot1 green &&\n+     git-config --add test.string value &&\n+     git-config --add test.dupstring value1 &&\n+     git-config --add test.dupstring value2 &&\n+     git-config --add test.booltrue true &&\n+     git-config --add test.boolfalse no &&\n+     git-config --add test.boolother other &&\n+     git-config --add test.int 2k\n+     '\n+\n+test_external_without_stderr \\\n+    'Perl API' \\\n+    perl ../t9700/test.pl\n+\n+test_done\ndiff --git a/t/t9700/test.pl b/t/t9700/test.pl\nnew file mode 100755\nindex 0000000..4d23125\n--- /dev/null\n+++ b/t/t9700/test.pl\n@@ -0,0 +1,100 @@\n+#!/usr/bin/perl\n+use lib (split(/:/, $ENV{GITPERLLIB}));\n+\n+use 5.006002;\n+use warnings;\n+use strict;\n+\n+use Test::More qw(no_plan);\n+\n+use Cwd;\n+use File::Basename;\n+use File::Temp;\n+\n+BEGIN { use_ok('Git') }\n+\n+# set up\n+our $repo_dir = \"trash directory\";\n+our $abs_repo_dir = Cwd->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+ok(our $r = Git->repository(Directory => \".\"), \"open repository\");\n+\n+# config\n+is($r->config(\"test.string\"), \"value\", \"config scalar: string\");\n+is_deeply([$r->config(\"test.dupstring\")], [\"value1\", \"value2\"],\n+\t  \"config array: string\");\n+is($r->config(\"test.nonexistent\"), undef, \"config scalar: nonexistent\");\n+is_deeply([$r->config(\"test.nonexistent\")], [], \"config array: nonexistent\");\n+is($r->config_int(\"test.int\"), 2048, \"config_int: integer\");\n+is($r->config_int(\"test.nonexistent\"), undef, \"config_int: nonexistent\");\n+ok($r->config_bool(\"test.booltrue\"), \"config_bool: true\");\n+ok(!$r->config_bool(\"test.boolfalse\"), \"config_bool: false\");\n+our $ansi_green = \"\\x1b[32m\";\n+is($r->get_color(\"color.test.slot1\", \"red\"), $ansi_green, \"get_color\");\n+# Cannot test $r->get_colorbool(\"color.foo\")) because we do not\n+# control whether our STDOUT is a terminal.\n+\n+# Failure cases for config:\n+# Save and restore STDERR; we will probably extract this into a\n+# \"dies_ok\" method and possibly move the STDERR handling to Git.pm.\n+open our $tmpstderr, \">&\", STDERR or die \"cannot save STDERR\"; close STDERR;\n+eval { $r->config(\"test.dupstring\") };\n+ok($@, \"config: duplicate entry in scalar context fails\");\n+eval { $r->config_bool(\"test.boolother\") };\n+ok($@, \"config_bool: non-boolean values fail\");\n+open STDERR, \">&\", $tmpstderr or die \"cannot restore STDERR\";\n+\n+# ident\n+like($r->ident(\"aUthor\"), qr/^A U Thor <author\\@example.com> [0-9]+ \\+0000$/,\n+     \"ident scalar: author (type)\");\n+like($r->ident(\"cOmmitter\"), qr/^C O Mitter <committer\\@example.com> [0-9]+ \\+0000$/,\n+     \"ident scalar: committer (type)\");\n+is($r->ident(\"invalid\"), \"invalid\", \"ident scalar: invalid ident string (no parsing)\");\n+my ($name, $email, $time_tz) = $r->ident('author');\n+is_deeply([$name, $email], [\"A U Thor\", \"author\\@example.com\"],\n+\t \"ident array: author\");\n+like($time_tz, qr/[0-9]+ \\+0000/, \"ident array: author\");\n+is_deeply([$r->ident(\"Name <email> 123 +0000\")], [\"Name\", \"email\", \"123 +0000\"],\n+\t  \"ident array: ident string\");\n+is_deeply([$r->ident(\"invalid\")], [], \"ident array: invalid ident string\");\n+\n+# ident_person\n+is($r->ident_person(\"aUthor\"), \"A U Thor <author\\@example.com>\",\n+   \"ident_person: author (type)\");\n+is($r->ident_person(\"Name <email> 123 +0000\"), \"Name <email>\",\n+   \"ident_person: ident string\");\n+is($r->ident_person(\"Name\", \"email\", \"123 +0000\"), \"Name <email>\",\n+   \"ident_person: array\");\n+\n+# objects and hashes\n+ok(our $file1hash = $r->command_oneline('rev-parse', \"HEAD:file1\"), \"(get file hash)\");\n+our $tmpfile = File::Temp->new;\n+is($r->cat_blob($file1hash, $tmpfile), 15, \"cat_blob: size\");\n+our $blobcontents;\n+{ local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }\n+is($blobcontents, \"changed file 1\\n\", \"cat_blob: data\");\n+seek $tmpfile, 0, 0;\n+is(Git::hash_object(\"blob\", $tmpfile), $file1hash, \"hash_object: roundtrip\");\n+$tmpfile = File::Temp->new();\n+print $tmpfile my $test_text = \"test blob, to be inserted\\n\";\n+like(our $newhash = $r->hash_and_insert_object($tmpfile), qr/[0-9a-fA-F]{40}/,\n+     \"hash_and_insert_object: returns hash\");\n+$tmpfile = File::Temp->new;\n+is($r->cat_blob($newhash, $tmpfile), length $test_text, \"cat_blob: roundtrip size\");\n+{ local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }\n+is($blobcontents, $test_text, \"cat_blob: roundtrip data\");\n+\n+# paths\n+is($r->repo_path, \"./.git\", \"repo_path\");\n+is($r->wc_path, $abs_repo_dir . \"/\", \"wc_path\");\n+is($r->wc_subdir, \"\", \"wc_subdir initial\");\n+$r->wc_chdir(\"directory1\");\n+is($r->wc_subdir, \"directory1\", \"wc_subdir after wc_chdir\");\n+TODO: {\n+\tlocal $TODO = \"commands do not work after wc_chdir\";\n+\t# Failure output is active even in non-verbose mode and thus\n+\t# annoying.  Hence we skip these tests as long as they fail.\n+\ttodo_skip 'config after wc_chdir', 1;\n+\tis($r->config(\"color.string\"), \"value\", \"config after wc_chdir\");\n+}\n-- \n1.5.6.149.g06c04.dirty\n"},{"id":"80366","messageId":"m3lk11m9j7.fsf@localhost.localdomain","threadId":"13995","inReplyTo":"1213907569-6393-1-git-send-email-LeWiemann@gmail.com","subject":"Re: [PATCH 2/2 v5] Git.pm: add test suite","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-06-19T20:53:20Z","receivedAt":"2008-06-19T20:53:20Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Lea Wiemann <lewiemann@gmail.com> writes:\n\n> Changes since v4:\n> \n> - Use 5.006002 (lowest possible version for Test::More).\n\n[...]\n>      #!/usr/bin/perl\n>      use lib (split(/:/, $ENV{GITPERLLIB}));\n> \n>     +use 5.006002;  # Test::More was introduced in 5.6.2\n\nIsn't \"use Test::More\" enough, so this line is not strictly\nnecessary?\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"80368","messageId":"485AC7C8.5040100@gmail.com","threadId":"13995","inReplyTo":"m3lk11m9j7.fsf@localhost.localdomain","subject":"Re: [PATCH 2/2 v5] Git.pm: add test suite","fromName":"Lea Wiemann","fromEmail":"lewiemann@gmail.com","sentAt":"2008-06-19T20:55:36Z","receivedAt":"2008-06-19T20:55:36Z","isPatch":true,"sender":{"key":"lewiemann@gmail.com","avatar":null},"body":"Jakub Narebski wrote:\n> Lea Wiemann <lewiemann@gmail.com> writes:\n>>     +use 5.006002;  # Test::More was introduced in 5.6.2\n> \n> Isn't \"use Test::More\" enough, so this line is not strictly\n> necessary?\n\nI'd prefer to have a 'wrong Perl version' error instead of 'module not \nfound'.  Also it's good to document what we support, to remind me that I \nhave to run it with perl5.6.\n\n-- Lea\n"},{"id":"80418","messageId":"7vr6atq8t7.fsf@gitster.siamese.dyndns.org","threadId":"13995","inReplyTo":"1213907569-6393-1-git-send-email-LeWiemann@gmail.com","subject":"Re: [PATCH 2/2 v5] Git.pm: add test suite","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-06-19T23:55:16Z","receivedAt":"2008-06-19T23:55:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.\n\nThese two Perl-ish test patches will be part of 'next' tonight.\n\nWhen sending further improvements, if necessary, please make them relative\nto the copy there.\n"}]}