[Mono-list] File IO error
Mike Gray
mike@mikegray.org
Tue, 07 May 2002 16:30:26 -0400
I believe the reason these tests are still not working is that they are
trying to access/create/delete/etc. files in "filetest" directory. Since
this doesn't exist, well, they are failing as expected. :)
Here is a patch to FileTest.cs that uses the "resources" directory you
created instead of "filetest". With this patch, all of the tests written
(which is not many at this point, but I will work on that over time) do run
and work.
Index: FileTest.cs
===================================================================
RCS file: /mono/mcs/class/corlib/Test/System.IO/FileTest.cs,v
retrieving revision 1.2
diff -u -r1.2 FileTest.cs
--- FileTest.cs 7 May 2002 10:27:53 -0000 1.2
+++ FileTest.cs 7 May 2002 20:25:22 -0000
@@ -30,6 +30,7 @@
protected override void TearDown ()
{
+ File.Delete ("resources/baz");
}
public static ITest Suite
@@ -39,40 +40,54 @@
public void TestExists ()
{
- Assert ("File filetest/test should exist", File.Exists
("filetest/test"));
- }
+ Assert ("File resources/AFile.txt should exist", File.Exists
("resources/AFile.txt"));
+ Assert ("File resources/doesnotexist should not
exist", !File.Exists ("resources/doesnotexist"));
+ }
public void TestCreate ()
{
- File.Create ("filetest/foo");
- Assert ("File should exist", File.Exists ("filetest/foo"));
+ FileStream stream = File.Create ("resources/foo");
+ Assert ("File should exist", File.Exists ("resources/foo"));
+ stream.Close ();
}
public void TestCopy ()
{
- File.Copy ("filetest/foo", "filetest/bar", false);
- Assert ("File foo should exist", File.Exists ("filetest/foo"));
- Assert ("File bar should exist", File.Exists ("filetest/bar"));
+ File.Copy ("resources/AFile.txt", "resources/bar", false);
+ Assert ("File AFile.txt should still exist", File.Exists
("resources/AFile.txt"));
+ Assert ("File bar should exist after File.Copy", File.Exists
("resources/bar"));
}
public void TestDelete ()
{
- File.Delete ("filetest/foo");
- Assert ("File should not exist", !File.Exists ("filetest/foo"));
+ Assert ("File resources/foo should exist for
TestDelete to succeed", File.Exists ("resources/foo"));
+ try {
+ File.Delete ("resources/foo");
+ } catch (Exception e) {
+ Fail ("Unable to delete resources/foo: e="
+ e.ToString());
+ }
+ Assert ("File resources/foo should not exist after File.Delete",
!File.Exists ("resources/foo"));
}
public void TestMove ()
{
- Assert ("File filetest/bar should exist", File.Exists ("filetest/bar"));
- File.Move ("filetest/bar", "filetest/baz");
- Assert ("File filetest/bar should not exist", !File.Exists
("filetest/bar"));
- Assert ("File filetest/baz should exist", File.Exists ("filetest/baz"));
+ Assert ("File resources/bar should exist", File.Exists
("resources/bar"));
+ File.Move ("resources/bar", "resources/baz");
+ Assert ("File resources/bar should not exist", !File.Exists
("resources/bar"));
+ Assert ("File resources/baz should exist", File.Exists
("resources/baz"));
}
public void TestOpen ()
{
+ try {
+ FileStream stream = File.Open
("resources/AFile.txt", FileMode.Open);
+ } catch (Exception e) {
+ Fail ("Unable to open resources/AFile.txt:
e=" + e.ToString());
+ }
+
+ /* Exception tests */
try {
- FileStream stream = File.Open("filedoesnotexist", FileMode.Open);
+ FileStream stream = File.Open ("filedoesnotexist", FileMode.Open);
Fail ("File 'filedoesnotexist' should not exist");
} catch (FileNotFoundException) {
// do nothing, this is what we expect
Let me know if this is what you had in mind for the resources directory or
if you had something else going forward...
Mike Gray
>From: "Nick Drochak" <ndrochak@gol.com>
>To: <mike@mikegray.org>, <mono-list@ximian.com>
>Subject: RE: [Mono-list] File IO error
>Date: Wed, 8 May 2002 01:14:47 +0900
>
>| | Anyway, just saw a response from Dan Lewis so I will leave it
>| | to him since
>| | he likely knows way more than I do. Here is the patch to the
>| | unit test:
>| |
>|
>| Mike,
>|
>| Thanks for the patches. I've added them to CVS (slightly modified).
>| These IO tests are using files that are expected to be there, mostly
>| source files in CVS, but this isn't very reliable when tested
>| on Linux.
>|
>
>Also wanted to mention that these tests are reporting errors when run
>against MS.NET, so if you have the SDK it would be helpful if you could
>track down those errors too.
>
>Thanks,
>Nick D.
>
>
_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com