|
9 | 9 |
|
10 | 10 | use Cwd; |
11 | 11 | use File::Basename; |
12 | | -use File::Temp; |
13 | 12 |
|
14 | 13 | BEGIN { use_ok('Git') } |
15 | 14 |
|
|
35 | 34 | # Failure cases for config: |
36 | 35 | # Save and restore STDERR; we will probably extract this into a |
37 | 36 | # "dies_ok" method and possibly move the STDERR handling to Git.pm. |
38 | | -open our $tmpstderr, ">&", STDERR or die "cannot save STDERR"; close STDERR; |
| 37 | +open our $tmpstderr, ">&STDERR" or die "cannot save STDERR"; close STDERR; |
39 | 38 | eval { $r->config("test.dupstring") }; |
40 | 39 | ok($@, "config: duplicate entry in scalar context fails"); |
41 | 40 | eval { $r->config_bool("test.boolother") }; |
|
66 | 65 |
|
67 | 66 | # objects and hashes |
68 | 67 | ok(our $file1hash = $r->command_oneline('rev-parse', "HEAD:file1"), "(get file hash)"); |
69 | | -our $tmpfile = File::Temp->new; |
70 | | -is($r->cat_blob($file1hash, $tmpfile), 15, "cat_blob: size"); |
| 68 | +my $tmpfile = "file.tmp"; |
| 69 | +open TEMPFILE, "+>$tmpfile" or die "Can't open $tmpfile: $!"; |
| 70 | +is($r->cat_blob($file1hash, \*TEMPFILE), 15, "cat_blob: size"); |
71 | 71 | our $blobcontents; |
72 | | -{ local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; } |
| 72 | +{ local $/; seek TEMPFILE, 0, 0; $blobcontents = <TEMPFILE>; } |
73 | 73 | is($blobcontents, "changed file 1\n", "cat_blob: data"); |
74 | | -seek $tmpfile, 0, 0; |
| 74 | +close TEMPFILE or die "Failed writing to $tmpfile: $!"; |
75 | 75 | is(Git::hash_object("blob", $tmpfile), $file1hash, "hash_object: roundtrip"); |
76 | | -$tmpfile = File::Temp->new(); |
77 | | -print $tmpfile my $test_text = "test blob, to be inserted\n"; |
| 76 | +open TEMPFILE, ">$tmpfile" or die "Can't open $tmpfile: $!"; |
| 77 | +print TEMPFILE my $test_text = "test blob, to be inserted\n"; |
| 78 | +close TEMPFILE or die "Failed writing to $tmpfile: $!"; |
78 | 79 | like(our $newhash = $r->hash_and_insert_object($tmpfile), qr/[0-9a-fA-F]{40}/, |
79 | 80 | "hash_and_insert_object: returns hash"); |
80 | | -$tmpfile = File::Temp->new; |
81 | | -is($r->cat_blob($newhash, $tmpfile), length $test_text, "cat_blob: roundtrip size"); |
82 | | -{ local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; } |
| 81 | +open TEMPFILE, "+>$tmpfile" or die "Can't open $tmpfile: $!"; |
| 82 | +is($r->cat_blob($newhash, \*TEMPFILE), length $test_text, "cat_blob: roundtrip size"); |
| 83 | +{ local $/; seek TEMPFILE, 0, 0; $blobcontents = <TEMPFILE>; } |
83 | 84 | is($blobcontents, $test_text, "cat_blob: roundtrip data"); |
| 85 | +close TEMPFILE; |
| 86 | +unlink $tmpfile; |
84 | 87 |
|
85 | 88 | # paths |
86 | 89 | is($r->repo_path, "./.git", "repo_path"); |
|
0 commit comments