How to debug and improve Gallio

135 views
Skip to first unread message

Espen Albrektsen

unread,
Sep 10, 2012, 7:40:24 AM9/10/12
to galli...@googlegroups.com
Hi there.

I am struggling with a unit test project where I get a typeloader-exception when Gallio is exploring the tests:
 [error] An exception was thrown while exploring tests.
Location: C:\Users\espen\Documents\AlbrektsenInnovasjon\Customers\Statkraft\Sirdas\SirdasTest\obj\Debug\SirdasTest.DLL
Reference: SirdasTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Details: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at Gallio.Common.Reflection.Impl.NativeAssemblyWrapper.GetTypes() in c:\Server\Projects\MbUnit v3\Work\src\Gallio\Gallio\Common\Reflection\Impl\NativeAssemblyWrapper.cs:line 72
   
Obviously - the interesting stuff is in the LoaderExceptions - so I figured I would go and improve Gallio by printing out that information when this occurs.
So - I checked out Gallio (trunk) and opened up the Gallio.vs2010.sln in VS2012.
When I compiled, it complained that 
2>  Gallio.Host.vs2010 -> C:\Users\espen\Documents\AlbrektsenInnovasjon\Tools\mb-unit\v3\src\Gallio\Gallio.Host\bin\Gallio.Host.exe
2>  '"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\corflags.exe"' is not recognized as an internal or external command,
Other than that, the compilation was OK.
So I executed build.bat like this:
 \mb-unit\v3>Build.bat "packages\Bundle Package.module" 
/p:TargetFrameworkSDKDirectory="C:\Program Files\Microsoft SDKs\Windows\v7.0A" /p:SkipSyncProjects=true /p:SkipSandCastle=true
/p:SkipArchive=true /p:SkipInstaller=true /p:SkipCodeCoverage=true /t:Compile
All was well.

I then noticed that I could not run my tests - so I added Echo and Icarus from the Extensions folder to the solution, and set Echo as my startup project - and used the path to my dll as argument. Gallio.Echo runs fine, but I get the following error message:
[warning] File 'SirdasTest.dll' is not supported by any installed test framework
.  It will be ignored.
        Location: C:\Users\espen\Documents\AlbrektsenInnovasjon\Customers\Statkr
aft\Sirdas\SirdasTest\bin\Debug\SirdasTest.dll
[ignored] Unsupported SirdasTest.dll
Detected a probable test framework assembly version mismatch.
Referenced test frameworks: 'MbUnit, Version=3.4.0.0, Culture=neutral, PublicKey
Token=eb9cfa67ee6ab36e'.
Supported test frameworks: 'MbUnit, Version=0.0.0.0'.
So - I went and updated my test project, and referenced the Gallio and MbUnit dlls that were compiled locally. SirdasTest.dll was now accepted - but I was still not able to reproduce the exception, because Gallio was unable to  start the Gallio.Host process.
After a little more digging, I found the "IsolatedProcessHostFactory" class, and realized that it uses the "wrong" path to Gallio.Host.x86.exe - somewhere, the path to Gallio\Bin\ is selected - instead of the path to Gallio.Host\bin
So I made the following change in DefaultRuntime.cs:
 // Force the runtime path to be set to where the primary Gallio assemblies and Gallio.Host.exe
// are located.
runtimeSetup.RuntimePath = Path.Combine(srcDir, @"Gallio\Gallio.Host\bin");
But now - I get a System.IO.FileLoadException in Gallio.Host.x86.exe :-(

So - I am on the verge of giving up here. Surely there is some trivial change I need to do, but as the amount of code in the Gallio project is pretty large - I am at a loss.

What am I doing wrong? 

All I really wanted to do was to make a small fix to NativeAssemblyWrapper.cs so that it displays more helpfull error messages...

Regards, Espen
 
 
 

Reply all
Reply to author
Forward
0 new messages