Index: DeleteTest.cs
===================================================================
RCS file: /cvsroot/nant/nant/src/NAnt.Core.Tests/Tasks/DeleteTest.cs,v
retrieving revision 1.2
diff -u -r1.2 DeleteTest.cs
--- DeleteTest.cs	25 Oct 2002 10:18:09 -0000	1.2
+++ DeleteTest.cs	20 Feb 2003 05:16:44 -0000
@@ -46,32 +46,111 @@
                 <delete file='{0}'/>
                 <delete dir='{1}'/>
                 <delete dir='{2}'/>
+                <delete file='{3}'/>
             </project>";
 
         string tempFile;
         string tempDir;
         string tempFileInTempDirDir;
+        string tempFileNonExisting;
+        string tempFileReadOnly;
 
-		[SetUp]
+        [SetUp]
         protected override void SetUp() {
             base.SetUp();
             tempFile = CreateTempFile("a.b");
             tempDir = CreateTempDir("foo");
             tempFileInTempDirDir = CreateTempDir("goo");
             CreateTempFile(Path.Combine(tempFileInTempDirDir, "ha.he"));
+            tempFileNonExisting = CreateTempFile("b.a");
+            tempFileReadOnly = CreateTempFile("c.a");
         }
 
-		[Test]
+        [Test]
         public void Test_Delete() {
             Assertion.Assert("File should have been created:" + tempFile, File.Exists(tempFile));
             Assertion.Assert("Dir should have been created:" + tempDir, Directory.Exists(tempDir));
             Assertion.Assert("Dir should have been created:" + tempFileInTempDirDir, Directory.Exists(tempFileInTempDirDir));
+            Assertion.Assert("File should have been created:" + tempFileNonExisting, File.Exists(tempFileNonExisting));
 
-            string result = RunBuild(String.Format(_xmlProjectTemplate, tempFile, tempDir, tempFileInTempDirDir));
+            // Delete the temporary file, and try to delete it again in the buildfile.
+            // Deleting a file that doesn't exist should never cause an exception to be thrown, 
+            // regardless of the value of the failonerror attribute.
+            File.Delete(tempFileNonExisting);
+
+            string result = RunBuild(String.Format(_xmlProjectTemplate, tempFile, tempDir, tempFileInTempDirDir, tempFileNonExisting));
             
             Assertion.Assert("File should have been deleted:" + result, !File.Exists(tempFile));
             Assertion.Assert("Dir should have been deleted:" + result, !Directory.Exists(tempDir));
             Assertion.Assert("Dir should have been deleted:" + result, !Directory.Exists(tempFileInTempDirDir));
+        }
+
+        /// <summary>
+        /// Tries to delete a read-only file with failonerror set to <c>true</c>.
+        /// </summary>
+        /// <remarks>
+        /// An attempt to delete a read-only file should cause the build to fail when failonerror 
+        /// is set to <c>true</c>.
+        /// </remarks>
+        /// <exception cref="BuildException">Attempt to delete a read-only file.</exception>
+        [Test]
+        [ExpectedException(typeof(BuildException))]
+        public void Test_DeleteReadOnlyFileFailOnError() {
+            string _xmlProjectTemplateNonExisting = @"
+                <project>
+                    <delete file='{0}' quiet='false' failonerror='true' />
+                </project>";
+
+            Assertion.Assert("File should have been created:" + tempFileReadOnly, File.Exists(tempFileReadOnly));
+            File.SetAttributes(tempFileReadOnly, FileAttributes.ReadOnly);
+
+            string result = RunBuild(String.Format(_xmlProjectTemplateNonExisting, tempFileReadOnly));
+        }
+
+        /// <summary>
+        /// Tries to delete a read-only file with failonerror set to <c>false</c>.
+        /// </summary>
+        /// <remarks>
+        /// An attempt to delete a read-only file should NOT cause the build to fail when failonerror 
+        /// is set to <c>false</c>.
+        /// </remarks>
+        public void Test_DeleteReadOnlyFileProceed() {
+            string _xmlProjectTemplateNonExisting = @"
+                <project>
+                    <delete file='{0}' quiet='false' failonerror='false' />
+                </project>";
+
+            Assertion.Assert("File should have been created:" + tempFileReadOnly, File.Exists(tempFileReadOnly));
+            File.SetAttributes(tempFileReadOnly, FileAttributes.ReadOnly);
+
+            string result = RunBuild(String.Format(_xmlProjectTemplateNonExisting, tempFileReadOnly));
+
+            Assertion.Assert("File should still exist:" + tempFileReadOnly, File.Exists(tempFileReadOnly));
+        }
+
+        [TearDown]
+        protected override void TearDown() {
+            base.TearDown();
+
+            if (File.Exists(tempFileReadOnly)) {
+                File.SetAttributes(tempFileReadOnly, FileAttributes.Normal);
+                File.Delete(tempFileReadOnly);
+            }
+            if (File.Exists(tempFileNonExisting)) {
+                File.Delete(tempFileNonExisting);
+            }
+            if (File.Exists(tempFile)) {
+                File.Delete(tempFile);
+            }
+            if (Directory.Exists(tempDir)) {
+                Directory.Delete(tempDir);
+            }
+            if (File.Exists(tempFileInTempDirDir)) {
+                File.Delete(tempFileInTempDirDir);
+            }
+            if (Directory.Exists(tempFileInTempDirDir)) {
+                Directory.Delete(tempFileInTempDirDir);
+            }
         }
     }
 }
