git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] t9700/test.pl: backwards compatibility improvements

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
Jul 22, 2008, 21:16 UTC
Message-ID
<k-pcfapbFwwISYvjf34W3d-E7j-DCb9tf-MW1z8rFObaPKgPJEmD7Q@cipher.nrlssc.navy.mil>
In-Reply-To
<0GfECozN3g0ZvAESKMi76RyOVHEb2OhhwET9GWmEm7pbzYQJub50UlWpZtBa7MGn1UGb-7mzbzE@cipher.nrlssc.navy.mil>

Some versions of perl complain when 'STDERR' is used as the third argument in the 3-argument form of open(). Convert to the 2-argument form which is described for duping STDERR in my second edition camel book.

The object oriented version of File::Temp is a rather new incarnation it seems. The File::Temp man page for v5.8.0 says "(NOT YET IMPLEMENTED)" in the 'Objects' section. These can be converted to use File::Temp::tempfile().

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 t/t9700/test.pl |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/t/t9700/test.pl b/t/t9700/test.pl
index 4d23125..70f9836 100755
--- a/t/t9700/test.pl
+++ b/t/t9700/test.pl
@@ -38,7 +38,7 @@ is($r->get_color("color.test.slot1", "red"), $ansi_green, "get_color");
 # Failure cases for config:
 # Save and restore STDERR; we will probably extract this into a
 # "dies_ok" method and possibly move the STDERR handling to Git.pm.
-open our $tmpstderr, ">&", STDERR or die "cannot save STDERR"; close STDERR;
+open our $tmpstderr, ">&STDERR" or die "cannot save STDERR"; close STDERR;
 eval { $r->config("test.dupstring") };
 ok($@, "config: duplicate entry in scalar context fails");
 eval { $r->config_bool("test.boolother") };
@@ -69,18 +69,18 @@ is($r->ident_person("Name", "email", "123 +0000"), "Name <email>",
 
 # objects and hashes
 ok(our $file1hash = $r->command_oneline('rev-parse', "HEAD:file1"), "(get file hash)");
-our $tmpfile = File::Temp->new;
+our ($tmpfile, $tmpnam) = File::Temp::tempfile();
 is($r->cat_blob($file1hash, $tmpfile), 15, "cat_blob: size");
 our $blobcontents;
 { local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }
 is($blobcontents, "changed file 1\n", "cat_blob: data");
 seek $tmpfile, 0, 0;
-is(Git::hash_object("blob", $tmpfile), $file1hash, "hash_object: roundtrip");
-$tmpfile = File::Temp->new();
+is(Git::hash_object("blob", $tmpnam), $file1hash, "hash_object: roundtrip");
+($tmpfile, $tmpnam) = File::Temp::tempfile();
 print $tmpfile my $test_text = "test blob, to be inserted\n";
-like(our $newhash = $r->hash_and_insert_object($tmpfile), qr/[0-9a-fA-F]{40}/,
+like(our $newhash = $r->hash_and_insert_object($tmpnam), qr/[0-9a-fA-F]{40}/,
      "hash_and_insert_object: returns hash");
-$tmpfile = File::Temp->new;
+$tmpfile = File::Temp::tempfile();
 is($r->cat_blob($newhash, $tmpfile), length $test_text, "cat_blob: roundtrip size");
 { local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }
 is($blobcontents, $test_text, "cat_blob: roundtrip data");
-- 
1.6.0.rc0.38.g8b8fb7
Previous: Brandon CaseyNext: Junio C Hamano
Message 6 of 23 in “perl/Makefile: update NO_PERL_MAKEMAKER section”
  1. perl/Makefile: update NO_PERL_MAKEMAKER sectionBrandon Casey, Jul 22, 2008
  2. Petr BaudisJul 22, 2008
  3. Brandon CaseyJul 23, 2008
  4. Junio C HamanoJul 23, 2008
  5. Brandon CaseyJul 23, 2008
  6. t9700/test.pl: backwards compatibility improvementsBrandon Casey, Jul 22, 2008
  7. Junio C HamanoJul 23, 2008
  8. Brandon CaseyJul 24, 2008
  9. t4116-apply-reverse.sh: use $TAR rather than tarBrandon Casey, Jul 22, 2008
  10. Set TAR in t/Makefile and in t4116-apply-reverse.shStephan Beyer, Jul 25, 2008
  11. Miklos VajnaJul 25, 2008
  12. Stephan BeyerJul 25, 2008
  13. Junio C HamanoJul 25, 2008
  14. Stephan BeyerJul 25, 2008
  15. Junio C HamanoJul 25, 2008
  16. Stephan BeyerJul 25, 2008
  17. Junio C HamanoJul 25, 2008
  18. t3200,t7201: replace '!' with test_must_failBrandon Casey, Jul 22, 2008
  19. t/: Replace diff [-u|-U0] with test_cmp to allow compilation with old diffBrandon Casey, Jul 22, 2008
  20. Miklos VajnaJul 24, 2008
  21. Brandon CaseyJul 24, 2008
  22. t7502-commit.sh: rearrange test to make more portableBrandon Casey, Jul 22, 2008
  23. t/t4202-log.sh: add newline at end of fileBrandon Casey, Jul 22, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.