Wednesday, September 21, 2005

Choose Life

Choose life. Choose inheritance. Choose a job subclassing all the controls you ever built, and all the 3rd party ones you might ever use. Choose combinatorial explosion. Choose painfully recreating designers to work against the subclasses you just built. Choose aggregated proxy-by-reflection just to get the damned sealed classes working, and waking up in a cold sweat in the middle of the night panicking over the grotesqueness of it all. Choose backing yourself into a corner. Choose starting from scratch for the next version. Choose wishing you could call base.base.method() because your immediate subclass overrode the method to do something you didn't want. Choose your future. Choose inheritance.

(me getting wound up on aus-dotnet list again)

Tuesday, September 13, 2005

CruiseControl.NET RC1 Log-merging issues with nmock via nant

Summary: using a strict mock in a unit test run using nant's nunit2
task breaks RC1 CruiseControl's merging of the nant output [update: This is apparently fixed in later builds of nmock - see comments at end]

When we migrated to the latest version of CruiseControl.NET last week
(the RC1 release), one of our builds stopped merging the logs
properly (so we started getting the dreaded 'Log does not contain any
Xml output from NAnt' error).

This was due to cruisecontrol CDATA-wrapping the nant output in the
log, but at the time I didn't understand why it would do that, and
what had changed in RC1.

It turns out that nmock has a known issue ( ) where
strict mocks complain when the mocks are Finalise()'d. Since this
only occurs on a GC, this error is normally swallowed by the host
application closing down, but you can see this behaviour if you run a
test including a strict mock from nunit-console.

Normally nant's XmlLogger catches everything going to StdOut and
StdErr, and wraps them nicely in its xml output to catch this kind of
stuff. Unfortunately nant's nunit2 task runs inside nant, rather than
shelling out, so the GC that causes the nmock issue doesn't happen
until nant is closing down, by which time the XmlLogger has already
closed down.

As a result, nmock writes this kind of output directly to StdErr:

Unhandled Exception: NMock.VerifyException: Finalize() called too
many times
but was:<1>
at NMock.Mock.Invoke(String methodName, Object[] args)
at ProxyDataFormatter.Finalize()

...the <>'s in which cause CruiseControl to wrap nant's output with
CDATA and hence hide it from the dashboard.

And what's changed in RC1? Well since this wasn't an issue before I
can only infer that RC1 now sucks in StdErr *as well as* StdOut from

So... Really what it boils down to is:

- CruseControl should probably CDATA the StdErr from nant (rather
than assuming its valid Xml!)

- nmock needs fixing (seems like they're too busy playing with a v2
generic version to look at existing issues)

- tricky to see how nant's XmlLogger could cope better

- should be a FAQ on 'Log does not contain any output from NAnt'

In the intermediary we've hacked our version of nmock as per the link
up above (somewhere) so as to not raise exceptions on Finalize()

Update: This is apparently fixed in later nmock releases, though we found they also broke something else we were doing (which was probably our fault), so for expediency we kept our hack. Later versions of CruiseControl.NET may also handle this more gracefully now too.

Popular Posts