提交 bf557788 编写于 作者: B Brandon Casey 提交者: Junio C Hamano

t9700/test.pl: remove File::Temp requirement

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. Instead of creating a file with a unique name in
the system TMPDIR, we can create our own temporary file with a static
name and use that instead.
Signed-off-by: NBrandon Casey <casey@nrlssc.navy.mil>
Tested-by: Tom G. Christensen <tgc@statsbiblioteket.dk> on RHEL 3, Perl 5.8.0
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 8409bb37
......@@ -9,7 +9,6 @@
use Cwd;
use File::Basename;
use File::Temp;
BEGIN { use_ok('Git') }
......@@ -69,21 +68,25 @@
# objects and hashes
ok(our $file1hash = $r->command_oneline('rev-parse', "HEAD:file1"), "(get file hash)");
our $tmpfile = File::Temp->new;
is($r->cat_blob($file1hash, $tmpfile), 15, "cat_blob: size");
my $tmpfile = "file.tmp";
open TEMPFILE, "+>$tmpfile" or die "Can't open $tmpfile: $!";
is($r->cat_blob($file1hash, \*TEMPFILE), 15, "cat_blob: size");
our $blobcontents;
{ local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }
{ local $/; seek TEMPFILE, 0, 0; $blobcontents = <TEMPFILE>; }
is($blobcontents, "changed file 1\n", "cat_blob: data");
seek $tmpfile, 0, 0;
close TEMPFILE or die "Failed writing to $tmpfile: $!";
is(Git::hash_object("blob", $tmpfile), $file1hash, "hash_object: roundtrip");
$tmpfile = File::Temp->new();
print $tmpfile my $test_text = "test blob, to be inserted\n";
open TEMPFILE, ">$tmpfile" or die "Can't open $tmpfile: $!";
print TEMPFILE my $test_text = "test blob, to be inserted\n";
close TEMPFILE or die "Failed writing to $tmpfile: $!";
like(our $newhash = $r->hash_and_insert_object($tmpfile), qr/[0-9a-fA-F]{40}/,
"hash_and_insert_object: returns hash");
$tmpfile = File::Temp->new;
is($r->cat_blob($newhash, $tmpfile), length $test_text, "cat_blob: roundtrip size");
{ local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; }
open TEMPFILE, "+>$tmpfile" or die "Can't open $tmpfile: $!";
is($r->cat_blob($newhash, \*TEMPFILE), length $test_text, "cat_blob: roundtrip size");
{ local $/; seek TEMPFILE, 0, 0; $blobcontents = <TEMPFILE>; }
is($blobcontents, $test_text, "cat_blob: roundtrip data");
close TEMPFILE;
unlink $tmpfile;
# paths
is($r->repo_path, "./.git", "repo_path");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册