commit e730248585696d0577a453e801d01a576812dbc1
Author: Shawn Laffan <shawnlaffan@gmail.com>
Date:   Wed Oct 28 08:19:00 2015 +1100

    Use a new name for the exec file if we are unable to unlink it.
    
    This avoids issues with antivirus software holding on to the file when we try to overwrite it.

diff --git a/t/flexraw_fortran.t b/t/flexraw_fortran.t
index 6f5cef4..1a97ef3 100644
--- a/t/flexraw_fortran.t
+++ b/t/flexraw_fortran.t
@@ -9,7 +9,7 @@ use Test::More;
 use File::Temp qw(tempfile);
 use File::Spec;
 
-my ($data,$head,$hdr);
+my ($data,$head,$hdr, $prog_iter);
 
 BEGIN {
    (undef, $data) = tempfile("rawXXXX", SUFFIX=>'_data', TMPDIR=>1);
@@ -222,6 +222,20 @@ sub createData {
     $fh->print( $code );
     $fh->close;
 
+    if (-e "$prog$exec") {
+        my $success = unlink "$prog$exec";
+        if (!$success) {
+            #  Antivirus might be holding on to the exec
+            #  file so use a different name
+            #  Poss path length issues?
+            #  See $dalen in 2nd begin block$prog_iter++;
+            warn "Unable to delete $prog$exec, generating new name"
+              if $Verbose;
+            $prog_iter++;
+            $prog .= $prog_iter;
+        };
+    }
+
     system("$F77 $F77flags -o $prog$exec $file".
 	     (($Verbose || $DEBUG)?'': $null));
     
