Subject: | Win32: t/03-banked-memory-ROM.t does not delete ramfile.ram |
In Win32 a file unlink fails if there is an open file handle on that file.
For this reason, t/03-banked-memory-ROM.t does not delete ramfile.ram and
leaves it behind at the end of the test.
The solution is to add a 'close $fh' just before the unlink.
The attached patch also adds tests to make sure the unlink succeeds.
Thank you.
Paulo Custodio
P.S. tested on perl 5, version 12, subversion 1 (v5.12.1) built for
MSWin32-x86-multi-thread
Subject: | CPU-Emulator-Memory-1.1001-patch01.txt |
diff -cr CPU-Emulator-Memory-1.1001/t/02-file.t CPU-Emulator-Memory-1.1001_01/t/02-file.t
*** CPU-Emulator-Memory-1.1001/t/02-file.t 2008-02-14 13:29:03.000000000 +0000
--- CPU-Emulator-Memory-1.1001_01/t/02-file.t 2010-10-22 14:35:27.745576500 +0100
***************
*** 1,7 ****
use strict;
$^W = 1;
! use Test::More tests => 5;
use CPU::Emulator::Memory;
--- 1,7 ----
use strict;
$^W = 1;
! use Test::More tests => 6;
use CPU::Emulator::Memory;
***************
*** 26,29 ****
my $newmemory = CPU::Emulator::Memory->new(file => 'newfile.ram');
ok($newmemory->peek(0) == 1, "RAM can be initialised correctly from a file");
! unlink 'newfile.ram';
--- 26,29 ----
my $newmemory = CPU::Emulator::Memory->new(file => 'newfile.ram');
ok($newmemory->peek(0) == 1, "RAM can be initialised correctly from a file");
! ok(unlink('newfile.ram'), "newfile.ram deleted");
diff -cr CPU-Emulator-Memory-1.1001/t/03-banked-memory-ROM.t CPU-Emulator-Memory-1.1001_01/t/03-banked-memory-ROM.t
*** CPU-Emulator-Memory-1.1001/t/03-banked-memory-ROM.t 2008-02-28 19:41:29.000000000 +0000
--- CPU-Emulator-Memory-1.1001_01/t/03-banked-memory-ROM.t 2010-10-22 14:34:29.228506700 +0100
***************
*** 1,7 ****
use strict;
$^W = 1;
! use Test::More tests => 19;
undef $/;
--- 1,7 ----
use strict;
$^W = 1;
! use Test::More tests => 21;
undef $/;
***************
*** 91,97 ****
ok($memory->peek(0) == ord('T'), "... and loads the new one");
ok($memory->peek16(0) == ord('T') + 256 * ord('h'), "peek16 reads from ROM too");
! unlink 'ramfile.ram', 'romfile.rom';
$memory->bank(
address => 0,
--- 91,99 ----
ok($memory->peek(0) == ord('T'), "... and loads the new one");
ok($memory->peek16(0) == ord('T') + 256 * ord('h'), "peek16 reads from ROM too");
! close $fh; # Win32: to allow unlink to remove the file
! ok(unlink('ramfile.ram'), "ramfile.ram deleted");
! ok(unlink('romfile.rom'), "romfile.rom deleted");
$memory->bank(
address => 0,