YaK:: WebLog #535 Topic : 2006-07-15 20.14.57 matt : getting a C# 2.0-compiled NUnit running under mono [Changes]   [Calendar]   [Search]   [Index]   [PhotoTags]   
  [Back to weblog: pretention]  

getting a C# 2.0-compiled NUnit running under mono

Mono's built-in NUnit can't deal with C# 2.0-compiled binaries. I need this functionality for the Linux and MacOS users in my class. Here's how I went about fixing this.

Luis did his first code drop with the first few customer tests passing and things are looking good -- he's taken pretty well to TDD with his own unit tests and the system tests (objdump output files) I've provided. I'm having some trouble running his MS.NET 2.0-compiled unit tests under mono, though. For some reason, using mono's nunit-console causes it to pull in a 1.1 version of System.dll rather than the 2.0 System.dll referenced in the test assembly's metadata. Weird. It doesn't look like they include an 2.0-compiled nunit.framework.dll in their default GAC, which is probably the problem. I think I mentioned this before in the #mono IRC channel on irc.gimp.net. Besides this fact, we can't use mono NUnit, which is version 2.2.0, because we are using Assert methods not included. Maybe I'll get around to upgrading mono's nunit.framework next week -- they included my nunit.mocks changes in their 1.1.16 release last week.

First, I downloaded the NUnit 2.2.8 2.0-compiled binaries. I unzipped then and ran them on the unit test assemblies that Luis put up on our private wiki. (The private wiki will be made public after the classes.) Running with the 2.0-compiled nunit-console worked, but nunit-gui wouldn't start. There were a couple of 2.0-specific properties that the VS.NET 2005 upgrade of nunit-gui's .resx files must've included. I implemented the missing methods in mono (MinimumSize and MaximumSize, which affect the Size that GetPreferredSize returns). Then, I got an error about parsing the resources in the 2.0-compiled nunit-gui:

System.Runtime.Serialization.SerializationException : Field "m_name" not found in class System.Globalization.CompareInfo
TearDown : System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
  ----> System.NullReferenceException : Object reference not set to an instance of an object
  at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadTypeMetadata (System.IO.BinaryReader reader, Boolean isRuntimeObject, Boolean hasTypeInfo) [0x0029a] in /home/matt/src/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectReader.cs:674
  at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectInstance (System.IO.BinaryReader reader, Boolean isRuntimeObject, Boolean hasTypeInfo, System.Int64 objectId, System.Object value, System.Runtime.Serialization.SerializationInfo info) [0x0000a] in /home/matt/src/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectReader.cs:239
  at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObject (BinaryElement element, System.IO.BinaryReader reader, System.Int64 objectId, System.Object value, System.Runtime.Serialization.SerializationInfo info) [0x0008a] in /home/matt/src/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectReader.cs:161
  at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadNextObject (System.IO.BinaryReader reader) [0x00027] in /home/matt/src/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectReader.cs:124
  at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectGraph (System.IO.BinaryReader reader, Boolean readHeaders, System.Object result, System.Runtime.Remoting.Messaging.Header[] headers) [0x00044] in /home/matt/src/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/ObjectReader.cs:105
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.NoCheckDeserialize (System.IO.Stream serializationStream, System.Runtime.Remoting.Messaging.HeaderHandler handler) [0x00079] in /home/matt/src/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs:172
  at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream) [0x00000] in /home/matt/src/mcs/class/corlib/System.Runtime.Serialization.Formatters.Binary/BinaryFormatter.cs:129
  at System.Resources.ResourceReader.ReadNonPredefinedValue (System.Type exp_type) [0x00000] in /home/matt/src/mcs/class/corlib/System.Resources/ResourceReader.cs:352
  at System.Resources.ResourceReader.ReadValueVer2 (Int32 type_index) [0x001dc] in /home/matt/src/mcs/class/corlib/System.Resources/ResourceReader.cs:311
  at System.Resources.ResourceReader.ResourceValue (Int32 index) [0x00082] in /home/matt/src/mcs/class/corlib/System.Resources/ResourceReader.cs:393
  at System.Resources.ResourceReader+ResourceEnumerator.get_Value () [0x00033] in /home/matt/src/mcs/class/corlib/System.Resources/ResourceReader.cs:483
  at System.Resources.ResourceSet.ReadResources () [0x00045] in /home/matt/src/mcs/class/corlib/System.Resources/ResourceSet.cs:199
  at System.Resources.ResourceSet.GetObject (System.String name, Boolean ignoreCase) [0x00034] in /home/matt/src/mcs/class/corlib/System.Resources/ResourceSet.cs:154
  at System.Resources.ResourceSet.GetString (System.String name, Boolean ignoreCase) [0x00000] in /home/matt/src/mcs/class/corlib/System.Resources/ResourceSet.cs:179
  at System.Resources.ResourceManager.GetString (System.String name, System.Globalization.CultureInfo culture) [0x0003a] in /home/matt/src/mcs/class/corlib/System.Resources/ResourceManager.cs:238
  at System.Resources.ResourceManager.GetString (System.String name) [0x00000] in /home/matt/src/mcs/class/corlib/System.Resources/ResourceManager.cs:220
  at NUnit.Gui.ProjectEditor.InitializeComponent () [0x00000]

Damnit. I filed a bug with the mono folks, but Miguel made it sound like it won't be fixed any time soon. Crap. Wait a minute -- I could compile NUnit 2.2.8 with mono's C# 2.0 compiler (gmcs); that should so what I want, hopefully.

I downloaded the NUnit 2.2.8 sources and unzipped them. I hadn't installed NAnt on my laptop yet, so I went ahead and did that. I then had to fiddle with NUnit's NAnt build files to get them to work with mono's C# 2.0 compiler. Some of it was NAnt kung-fu, but most of it was the fact that the build didn't include nunit-gui, and mono's compiler needs explicit references to the Data, Drawing, Remoting, and Forms assemblies. (The patch is attached to this page for anyone who is curious.) This isn't mono's fault, of course, this is Microsoft's csc compiler cheating for the sake of 'usability'. Yay undocumented side-effects!

I got most of NUnit 2.2.8 to build under mono's 2.0 compiler. I couldn't get the nunit.uikit.tests.dll or nunit-gui.tests.dll to build -- I couldn't make it see the test-utilities.dll reference for some reason.

Anyways, I accomplished what I needed so the mono users in the class can run the tests using nunit-gui. w00t!%


showing all 0 messages    

(No messages)

Post a new message:


(unless otherwise marked) Copyright 2002-2014 YakPeople. All rights reserved.
(last modified 2006-07-15)       [Login]
(No back references.)